<!--#include file="Inc.asp"-->
<!--#include file="ydzq.asp"-->
<%
call head()
call saycardd("操作勋章")

dim action
dim userid,ids,TP
userid=request("userid")

if userid="" or IsNumeric(userid)=False then
  Call Error("会员ID无效！")
  end if
'检查ID是否存在
dim username
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "SELECT name 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")
  rs.close
  set rs=Nothing
  
TP=request("TP")
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="" then
  Call Error("选择勋章无效！")
  end if
end if
tou="(img)"&tou&"(/img)"
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

response.write "操作成功！<br/>"
ELSE

response.write "授予用户"&username&"ID："&userid&"<br/>"
if saytk>1 then
Response.write "<form name=""form"" method=""post"" action=""adminxx.asp?action=get&amp;sid="&sid&"&amp;saytk="&saytk&""">"
end if
response.write "选择勋章<br/>"
response.write "<select name='tou'><option>勋章列表</option>"
set rs=server.createobject("ADODB.Recordset")
rs.open"select tou,name from XUANZ order by id desc",conn,1,1
dim j
j=1
do while not rs.eof
Response.write "<option value='" & ubb(rs("tou")) & "'>" & ubb(rs("name")) & "</option>"
j=j+1
rs.movenext
loop
rs.close
set rs=nothing
Response.write "</select><br/>"
if saytk>1 then
response.write "<input type=""hidden"" name=""userid"" value="""&userid&"""/>"
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='adminxx.asp?action=get&amp;sid="&sid&"&amp;saytk="&saytk&"' method='post' accept-charset='utf-8'>"
Response.write "<postfield name='tou' value='$(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='adminxx.asp?Action=del&amp;userid="&userid&"&amp;sid="&sid&"&amp;TP=1&amp;saytk="&saytk&"'>是的</a><br/>"
 Response.Write "<anchor>取消<prev/></anchor><br/>"
end if
end sub

Response.write "------------<br/>"
conn.close
set conn=Nothing

response.write"<a href=""show.asp?id="&userid&"&amp;sid="&sid&"&amp;saytk="&saytk&""">[返回上级]</a>"
response.write"<br/><a href=""adminxuan.asp?sid="&sid&"&amp;saytk="&saytk&""">[勋章管理]</a>"
%>
<!--#include file="fanhui.asp"-->
<%response.write""
call headsay()%>
