<!--#include file="../inc.asp"-->
<!--#include file="../ydzq1.asp"-->
<!--#include file="conn.asp"-->
<%Call head()
call saycardd("礼品管理")
sid=Request.querystring("sid")
dim rsqq,KEYid,keyuser


if keys<>1 then 
call error("权限不足！")
end if



infoppp=request("info")



If infoppp=l Then
id=request("id")
if id="" then 
msg="<a href='admin.asp?info=a&amp;saytk="&saytk&"&amp;sid="&sid&"'>添加分类</a>|<a href='admin.asp?info=e&amp;saytk="&saytk&"&amp;sid="&sid&"'>基本设置</a><br/>"
rsppl="select * from lx order by id desc"
gopage="admin.asp?saytk="&saytk&"&amp;sid="&sid&"&amp;"
else
gopage="admin.asp?saytk="&saytk&"&amp;sid="&sid&"&amp;id="&id&"&amp;"
msg="<a href='admin.asp?info=b&amp;saytk="&saytk&"&amp;sid="&sid&"'>添加产品</a><br/>"
rsppl="select * from txt where Categories="&id&" order by id desc"
end if
Response.Write msg
set rs=Sersaytkr.CreateObject("ADODB.Recordset")
rs.open rsppl,Giftsconn,1,1
If Not rs.eof	Then
	Dim PageSize,i
	PageSize=10						
	Dim Count,page,pagecount,gopage			
	
	Count=rs.recordcount	
	page=int(request.QueryString ("page"))
	if page<=0 or page="" then page=1		
	pagecount=(count+pagesize-1)\pagesize	
        if page>pagecount then page=pagecount
	rs.mosaytk(pagesize*(page-1))
	For i=1 To PageSize     						
	If rs.eof Then Exit For
if id="" then 
mssg="<a href=""admin.asp?id="&rs("id")&"&amp;saytk="&saytk&"&amp;sid="&sid&""">"&ubb(rs("nane"))&"</a>[<a href=""admin.asp?id="&rs("id")&"&amp;info=a&amp;saytk="&saytk&"&amp;sid="&sid&""">修改</a>/<a href=""admin.asp?id="&rs("id")&"&amp;info=c&amp;saytk="&saytk&"&amp;sid="&sid&""">删除</a>]<br/>"
else
mssg=""&ubb(rs("nane"))&"[<a href=""admin.asp?id="&rs("id")&"&amp;info=b&amp;saytk="&saytk&"&amp;sid="&sid&""">修改</a>/<a href=""admin.asp?id="&rs("id")&"&amp;ids="&id&"&amp;info=d&amp;saytk="&saytk&"&amp;sid="&sid&""">删除</a>]<br/>("&rs("Price")&"币/"&rs("Amount")&"件)<br/><img src='"&rs("url")&"' alt='..'/><br/>" 
end if
   Response.write i+(page-1)*PageSize&"."&mssg
	rs.mosaytkNext
 	Next
	if page-pagecount<0 then response.write "<a href="""&gopage&"page="&page+1&""">下页</a>"
	if page>1 then response.write "<a href="""&gopage&"page="&page-1&""">上页</a>"
	if pagecount>1 then response.write "<br/><b>"&page&"</b>/"&pagecount&"页<input name=""page"" format=""*N"" value="""&page&""" type=""text"" maxlength=""5"" emptyok=""true"" size=""3""/><a href="""&gopage&"page=$(page)"">跳转</a><br/>"
Else
   Response.write "暂无记录！<br />"
end if
rs.close
set rs=nothing




'====================
elseIf infoppp=a Then

id=request("id")
action=request("action")
txt=request("txt")
if action<>"ok" then
if id<>"" then
Response.write "请输入新类别名称:<br/>"
else
Response.write "类别名称:<br />"
end if
if mxjy=2 then
response.write "<form action=""admin.asp?saytk="&saytk&"&amp;sid="&sid&""" method=""post"" accept-charset=""UTF-8"">"
end if
Response.write "<input name=""txt"" emptyok=""true"" maxlength=""5""/><br/>"
	if mxjy=2 then
	Response.write "<input type='hidden' name='info' value='a'/>"
	Response.write "<input type='hidden' name='action' value='ok'/>"
	if id<>"" then
	Response.write "<input type='hidden' name='id' value='"&id&"'/>"
	end if
	Response.write "<input type=""submit"" value=""确定提交""/></form><br/>"
	else
response.write "<anchor>确定提交"
response.write "<go href=""admin.asp?saytk="&saytk&"&amp;sid="&sid&""" method=""post"" accept-charset=""utf-8"">"
response.write "<postfield name=""txt"" value=""$(txt)""/>"
response.write "<postfield name=""info"" value=""a""/>"
response.write "<postfield name=""action"" value=""ok""/>"
if id<>"" then
response.write "<postfield name=""id"" value="""&id&"""/>"
end if
response.write "</go></anchor><br/>"
	end if
else
	if txt="" then
	call error("名称不能为空！")
	end if
	set rs1=Sersaytkr.CreateObject("ADODB.Recordset")
	rs1.open"select * from lx where nane='"&txt&"'",Giftsconn,1,2
	if not rs1.eof then
	call error("该分类名称已存在！")
	end if
	if id="" then
	msgg="添加成功！"
	rs1.addnew
	rs1("nane")=txt
	rs1.update
	else
	msgg="修改成功！"
	set rs2=Sersaytkr.CreateObject("ADODB.Recordset")
	rs2.open"select * from lx where id="&id,Giftsconn,1,2
	if rs2.eof then
	call error("类别不存在！")
	end if
	rs2("nane")=txt
	rs2.update
	rs2.close
	set rs2=nothing
	end if
	rs1.close
	set rs1=nothing
	Response.Write msgg
	Response.Write "<a href='admin.asp?saytk="&saytk&"&amp;sid="&sid&"'>返回</a><br/>"
end if


elseIf infoppp=b Then

action=request("action")
id=request("id")
ids=request("ids")
about=request("about")
about2=request("about2")
about1=request("about1")
paycent=request("paycent")
paycent1=request("paycent1")

if action<>"ok" then
	if id<>"" then
	set rs=Sersaytkr.CreateObject("ADODB.Recordset")
	rs.open"select * from txt where id="&id,Giftsconn,1,1
	if rs.eof then
	call error("该产品不存在！")
	end if
	response.write "修改礼品["&rs("nane")&"]<br/>"
	rs.close
	set rs=nothing
	end if
if mxjy=2 then
response.write "<form action=""admin.asp?saytk="&saytk&"&amp;sid="&sid&""" method=""post"" accept-charset=""UTF-8"">"
end if
response.write "选择分类:<select name='ids'><option>分类列表</option>"
set rs=sersaytkr.createobject("ADODB.Recordset")
rs.open"select * from lx order by id desc",Giftsconn,1,1
dim j
j=1
do while not rs.eof
Response.write "<option value='" & ubb(rs("id")) & "'>" & ubb(rs("nane")) & "</option>"
j=j+1
rs.mosaytknext
loop
rs.close
set rs=nothing
Response.write "</select><br/>"
Response.write "产品名称:<input name=""about"" emptyok=""true""  maxlength=""10"" /><br/>"
Response.write "产品简介:<input name=""about2"" emptyok=""true""  maxlength=""30""/><br/>"
if id="" then
Response.write "图片路径:<input name=""about1"" emptyok=""true""/><br/>"
end if
Response.write "销售金额:<input name=""paycent"" emptyok=""true"" format=""*N"" size=""6"" value=""0""/>"&getcent&"<br/>"
Response.write "销售数量:<input name=""paycent1"" emptyok=""true"" format=""*N"" size=""6"" value=""0""/>件<br/>"
	if mxjy=2 then
	Response.write "<input type='hidden' name='action' value='ok'/>"
	Response.write "<input type='hidden' name='info' value='b'/>"
	if id<>"" then
	Response.write "<input type='hidden' name='id' value='"&id&"'/>"
	end if
	Response.write "<input type=""submit"" value=""确定提交""/></form><br/>"
	else
response.write "<anchor>确定提交"
response.write "<go href=""admin.asp?saytk="&saytk&"&amp;sid="&sid&""" method=""post"" accept-charset=""utf-8"">"
response.write "<postfield name=""paycent"" value=""$(paycent)""/>"
response.write "<postfield name=""about"" value=""$(about)""/>"
response.write "<postfield name=""about2"" value=""$(about2)""/>"
response.write "<postfield name=""paycent1"" value=""$(paycent1)""/>"
response.write "<postfield name=""ids"" value=""$(ids)""/>"
if id<>"" then
response.write "<postfield name=""id"" value="""&id&"""/>"
else
response.write "<postfield name=""about1"" value=""$(about1)""/>"
end if
response.write "<postfield name=""info"" value=""b""/>"
response.write "<postfield name=""action"" value=""ok""/>"
response.write "</go></anchor><br/>"
	end if
if id="" then
if saytk="" then saytk=1
Response.Write "<a href='photofile.asp?saytk="&saytk&"&amp;sid="&sid&"'>2.0上传</a><br/>"
end if
else
	if id="" and about1="" then
	call error("路径不能为空！")
	end if
	if ids="" or about="" or about2="" or paycent="" or paycent1="" then
	call error("各项不能为空！")
	end if
	set rs2=Sersaytkr.CreateObject("ADODB.Recordset")
	rs2.open"select * from txt where nane='"&about&"'",Giftsconn,1,2
	if not rs2.eof then
	call error("该名称已存在！")
	end if
	if id="" then
	rs2.addnew
	rs2("nane")=about
	rs2("url")=about1
	rs2("txta")=about2
	rs2("Price")=paycent
	rs2("Amount")=paycent1
	rs2("Categories")=ids
	rs2.update
	msgg="添加成功！"
	else
	msgg="修改成功！"
	set rs1=Sersaytkr.CreateObject("ADODB.Recordset")
	rs1.open"select * from txt where id="&id,Giftsconn,1,2
	if rs1.eof then
	call error("该产品不存在！")
	end if
	rs1("nane")=about
	rs1("txta")=about2
	rs1("Price")=paycent
	rs1("Amount")=paycent1
	rs1("Categories")=ids
	rs1.update
	rs1.close
	set rs1=nothing
	end if
	rs2.close
	set rs2=nothing
	Response.Write msgg
	Response.Write "<a href='admin.asp?id="&ids&"&amp;saytk="&saytk&"&amp;sid="&sid&"'>返回</a><br/>"
end if


elseIf infoppp=c Then

action=request("action")
id=request("id")
if action<>"ok" then
response.write"真的要删除类别？删除将连分类内的产品一并删除无法恢复！"
Response.Write "<br/><a href='admin.asp?Action=ok&amp;info=c&amp;id="&id&"&amp;saytk="&saytk&"&amp;sid="&sid&"'>决定删除</a><br/>"
Response.Write "<a href='admin.asp?saytk="&saytk&"&amp;sid="&sid&"'>取消返回</a><br/>"
Response.Write "</p></card></wml>"
Response.end 
end if
Giftsconn.Execute("delete from lx where id="&id)
Giftsconn.Execute("delete from txt where Categories="&id)
Response.Write "删除成功!"
Response.Write "<a href='admin.asp?saytk="&saytk&"&amp;sid="&sid&"'>返回</a><br/>"


elseIf infoppp=d Then

action=request("action")
id=request("id")
ids=request("ids")
if action<>"ok" then
response.write"真的要删除产品？删除的产品将无法恢复！"
Response.Write "<br/><a href='admin.asp?Action=ok&amp;info=d&amp;id="&id&"&amp;ids="&ids&"&amp;saytk="&saytk&"&amp;sid="&sid&"'>决定删除</a><br/>"
Response.Write "<a href='admin.asp?id="&ids&"&amp;saytk="&saytk&"&amp;sid="&sid&"'>取消返回</a><br/>"
Response.Write "</p></card></wml>"
Response.end 
end if
dim url
	set rs2=Sersaytkr.CreateObject("ADODB.Recordset")
	rs2.open"select * from txt where id="&id,Giftsconn,1,1
	if rs2.eof then
	call error("该产品不存在！")
	end if
	url=rs2("url")
	rs2.close
	set rs2=nothing
Response.write deletefile(url)
Giftsconn.Execute("delete from txt where id="&id)
Response.Write "删除成功!"
Response.Write "<a href='admin.asp?saytk="&saytk&"&amp;sid="&sid&"'>返回</a><br/>"


Else 

action=request("action")
num=request("num")
paycent=request("paycent")
paycent1=request("paycent1")
	set rs2=Sersaytkr.CreateObject("ADODB.Recordset")
	rs2.open"select * from Seta ",Giftsconn,1,2
if action<>"" then
	if paycent="" or Isnumeric(paycent)=False then
	Call Error("送礼经验无效！")
	end if
	if paycent1="" or Isnumeric(paycent1)=False then
	Call Error("收礼经验无效！")
	end if
	if rs2.eof then
	rs2.addnew
	end if
	rs2("Switch")=num
	rs2("Send")=paycent
	rs2("Closea")=paycent1
	rs2.update
Response.Write "设置成功!"
Response.Write "<a href='admin.asp?saytk="&saytk&"&amp;sid="&sid&"'>返回</a><br/>"

else
	Response.write "〓目前设置〓<br/>"
	if rs2("Switch")=1 then
	Response.write "商城开关:开<br/>"
	else
	Response.write "商城开关:关<br/>"
	end if
	Response.write "送礼经验:"&rs2("Send")&"<br/>"
	Response.write "收礼经验:"&rs2("Closea")&"<br/>"
	Response.write "〓更新设置〓<br/>"
if mxjy=2 then
response.write "<form action=""admin.asp?saytk="&saytk&"&amp;sid="&sid&""" method=""post"" accept-charset=""UTF-8"">"
end if
	Response.write "商城开关:<select name=""num"" value=""1"">"
	Response.write "<option value=""1"">开</option>"
	Response.write "<option value=""2"">关</option>"
	Response.write "</select><br/>"
	Response.write "送礼经验:<input name=""paycent"" emptyok=""true"" format=""*N"" size=""6"" value=""0""/><br/>"
	Response.write "收礼经验:<input name=""paycent1"" emptyok=""true"" format=""*N"" size=""6"" value=""0""/><br/>"
		if mxjy=2 then
	Response.write "<input type='hidden' name='action' value='ok'/>"
	Response.write "<input type='hidden' name='info' value='e'/>"
	Response.write "<input type=""submit"" value=""确定提交""/></form><br/>"
		else
	response.write "<anchor>确定提交"
	response.write "<go href=""admin.asp?saytk="&saytk&"&amp;sid="&sid&""" method=""post"" accept-charset=""utf-8"">"
	response.write "<postfield name=""paycent"" value=""$(paycent)""/>"
	response.write "<postfield name=""num"" value=""$(num)""/>"
	response.write "<postfield name=""paycent1"" value=""$(paycent1)""/>"
	response.write "<postfield name=""info"" value=""e""/>"
	response.write "<postfield name=""action"" value=""ok""/>"
	response.write "</go></anchor><br/>"
		end if
end if
	rs2.close
	set rs2=nothing
end if
Giftsconn.close
set Giftsconn=nothing
conn.close
set conn=nothing
Response.Write "---------------<br/><a href='admin.asp?saytk="&saytk&"&amp;sid="&sid&"'>返回商城管理</a>"

function deletefile(filename) 
if filename<>"" then 
filename=sersaytkr.MapPath(""&fileName&"") 
set fso=sersaytkr.CreateObject("scripting.filesystemobject") 
if fso.FileExists(filename) then 
fso.DeleteFile filename 
else 
Response.Write "该文件不存在<br/>" 
end if 
end if 
end function
%>
<!--#include file="fanhui.asp"-->
<%call head1()%>