<!--#include file="Inc.asp"-->
<!--#include file="ydzq.asp"-->
<%Call Head()
call saycarda("勋章自助超市")

dim action
dim userid,ids,TP
userid=myid

if userid="" or IsNumeric(userid)=False then
  Call Error("会员ID无效！")
  end if
'检查ID是否存在


dim username
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "SELECT * FROM users where id="&userid,conn,1,1
if rs.eof then
  rs.close
  set rs=Nothing
  Call Error("会员ID不存在！")
end if
username=rs("name")

votee=split(rs("xuan"),"(img)")

if ubound(votee)>5  Then
Call Error("你的勋章已超过6个，请先清空后再购买！<br/><a href=""xunzhang.asp?TPP=1&amp;saytk="&saytk&"&amp;sid="&sid&""">清空我的全部勋章</a><br/>")
End If


  rs.close
  set rs=Nothing
TP=request("TP")
id=request("id")
action=request("action")
Select Case action
	Case "get"   
		Call xxget()
	Case "del" 
		Call xxdel()
end select 
sub xxget()
if TP<>"" then
TP=clng(TP)
if TP=1 then
tou=request("tou")
if tou="0" then
  Call Error("选择勋章无效！")
  end if
end if
tou="(img)"&tou&"(/img)"
set rs11=Server.CreateObject("ADODB.Recordset")
rs11.Open "select * from xunzhang where id="&id,conn,1,1




if clng(myjb)<rs11("cent") then 
  Call Error("购买失败,您没有"&rs11("cent")&""&getcent&"！")
end if

 response.write "恭喜您购买成功！扣除"&rs11("cent")&""&getcent&"<br/>"
conn.execute("update Users set myjb=myjb-"&rs11("cent")&" where ID="&myid)
rs11.close
set rs11=Nothing
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "SELECT xuan FROM users where id="&userid,conn,1,2
if rs("xuan")<>"" then
rs("xuan")=tou & rs("xuan")
else
rs("xuan")=tou
end if
rs.update
rs.close
set rs=Nothing

ELSE
if saytk>1 then
Response.write "<form name=""form"" method=""post"" action=""goumai.asp?id="&id&"&amp;action=get&amp;saytk="&saytk&"&amp;sid="&sid&""">"
end if

response.write "购买用户"&username&"ID："&userid&"<br/>"
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open "select * from xunzhang where id="&id,conn,1,1
response.write "<img src='"&ubb(rs("tou"))&"' alt='"&ubb(rs("name"))&"'/>"
if saytk>1 Then
response.write "<input type=""hidden"" name=""tou"" value="""&ubb(rs("tou"))&""">"
response.write "<input type=""hidden"" name=""TP"" value=""1"">"
response.write "<input type=""submit"" name=""Submit"" value=""确定购买""></form><br/>"
else

Response.write "<anchor>确定购买<go href='goumai.asp?id="&id&"&amp;action=get&amp;saytk="&saytk&"&amp;sid="&sid&"' method='post' accept-charset='utf-8'>"
Response.write "<postfield name='tou' value='"&ubb(rs("tou"))&"'/>"
Response.write "<postfield name='userid' value='"&userid&"'/>"
Response.write "<postfield name='TP' value='1'/>"
Response.write "</go></anchor><br/>"
END If
End if
end sub
sub xxdel()
if TP<>"" then
conn.Execute("update users set xuan='' where id="&userid)
response.write "操作成功<br/>"
else
 Response.Write "真的要删除该会员的所有用户勋章？<br/>"
 Response.Write "<a href='adminxxx.asp?Action=del&amp;userid="&userid&"&amp;saytk="&saytk&"&amp;sid="&sid&"&amp;TP=1'>是的</a><br/>"
 Response.Write "<anchor>取消<prev/></anchor><br/>"
end if
end sub


conn.close
set conn=Nothing
response.Write"<a href=""show.asp?sid="&sid&"&amp;saytk="&saytk&""">返回小屋</a><br/>"
%>
<!--#include file="fanhui.asp"-->
<%call headsay()%>