<!--#include file="Admin_check.asp"-->
<%On Error Resume Next 
Select Case Request.querystring("Action")
case"setp"
dim js1,prname,jzrs,jname,jid,jzname,jzid,jzpic,jzpicurl,jz1,jz2,jz3,jz4,jz5,jz6,jz7,jz8,jz9,jz10,jzdata,i,jzpicurl1
%>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#F4F6FC" width="100%">
<%prname=replace(request.form("setpname"),"'","''")
if prname="" then%>
<form action="adminright_jzsetp.asp?action=setp" method="POST">
  <tr>
    <td class=td2 width="100%" bgcolor="#F4F6FC" height="28">
    <p style="margin: 4">用户奖章设置</p></td></tr>
<td width="100%" height="28"><P style="MARGIN: 5px">请输入用户名：<input type="text" name="setpname" size="20"></p><P style="MARGIN: 5px"><input type="submit" value=" 确 定 " name="B1"> <input type="reset" value=" 重 置 " name="B2"></p></td></tr>
</form>
<%
else 
set js1=conn.execute("select [jzdata] from [KK_user] where name='"&prname&"'")
if not js1.eof then
%>
<tr><td class=td2 width="100%" bgcolor="#F4F6FC" height="28">社区奖章颁发</td></tr>
<form action="adminright_jzsetp.asp?action=savepr" method="post">
<input size=45 name="ppname" type=hidden value="<%=prname%>">
<tr>
<td width=80% colspan=10>
第一奖项：<select size=1 name="jzn1">
<%
if js1("jzdata")<>"" then
jzdata=split(js1("jzdata"),"|||")
set js1=nothing
end if
set jzrs=conn.execute("select jzname,jzid,jzpicurl from kk_jzdata")
jzdata=split(js1("jzdata"),"|||")
response.write "<option value=0>请选择勋章"&ubound(jzdata)&"</option>"
	select case ubound(jzdata)
	case 0
	    jz1=jzdata(0)
 	case 1
 	    jz1=jzdata(0)
 	    jz2=jzdata(1)
 	case 2
 		jz1=jzdata(0)
 	    jz2=jzdata(1)
 	    jz3=jzdata(2)
 	case 3
 		jz1=jzdata(0)
 	    jz2=jzdata(1)
 	    jz3=jzdata(2)
 	    jz4=jzdata(3)
 	case 4
 		jz1=jzdata(0)
 	    jz2=jzdata(1)
 	    jz3=jzdata(2)
 	    jz4=jzdata(3)
 	    jz5=jzdata(4)
 	case 5
 		jz1=jzdata(0)
 	    jz2=jzdata(1)
 	    jz3=jzdata(2)
 	    jz4=jzdata(3)
 	    jz5=jzdata(4)
 	    jz6=jzdata(5)
 	case 6
 		jz1=jzdata(0)
 	    jz2=jzdata(1)
 	    jz3=jzdata(2)
 	    jz4=jzdata(3)
 	    jz5=jzdata(4)
 	    jz6=jzdata(5)
 	    jz7=jzdata(6)
 	case 7
 		jz1=jzdata(0)
 	    jz2=jzdata(1)
 	    jz3=jzdata(2)
 	    jz4=jzdata(3)
 	    jz5=jzdata(4)
 	    jz6=jzdata(5)
 	    jz7=jzdata(6)
 	    jz8=jzdata(7)
 	case 8
 		jz1=jzdata(0)
 	    jz2=jzdata(1)
 	    jz3=jzdata(2)
 	    jz4=jzdata(3)
 	    jz5=jzdata(4)
 	    jz6=jzdata(5)
 	    jz7=jzdata(6)
 	    jz8=jzdata(7)
 	    jz9=jzdata(8)
 	case 9
 		jz1=jzdata(0)
 	    jz2=jzdata(1)
 	    jz3=jzdata(2)
 	    jz4=jzdata(3)
 	    jz5=jzdata(4)
 	    jz6=jzdata(5)
 	    jz7=jzdata(6)
 	    jz8=jzdata(7)
 	    jz9=jzdata(8)
 	    jz10=jzdata(9)
 	case 10
 		jz1=jzdata(0)
 	    jz2=jzdata(1)
 	    jz3=jzdata(2)
 	    jz4=jzdata(3)
 	    jz5=jzdata(4)
 	    jz6=jzdata(5)
 	    jz7=jzdata(6)
 	    jz8=jzdata(7)
 	    jz9=jzdata(8)
 	    jz10=jzdata(9)
	end select
jzpic="rempty|||"
  ' jname=jname&jzrs("jzname")&"|||"
  ' jid=jid&jzrs("jzid")&"|||"
do while not jzrs.eof
   jname=jname&jzrs("jzname")&"|||"
   jid=jid&jzrs("jzid")&"|||"
   jzpic=jzpic&jzrs("jzpicurl")&"|||"
   jzrs.movenext
loop

jzid=split(jid,"|||")
jzname=split(jname,"|||")
jzpicurl1=split(jzpic,"|||")
response.write "<option value=0>请选择勋章</option>"
for i=0 to ubound(jzname)-1
    response.write "<option value="&jzid(i)
    if trim(jzpicurl1(i+1))=jz1 then response.write " selected "
    response.write ">"&jzname(i)&"</option>"
next

jzrs.close
set jzrs=nothing
%>
</select></td>
</tr>
<tr>
<td width=80% colspan=10>
第二奖项：<select size=1 name="jzn2">
<%
response.write "<option value=0>请选择勋章</option>"
for i=0 to ubound(jzname)-1
    response.write "<option value="&jzid(i)
    if jzpicurl1(i+1)=trim(jz2) then response.write " selected "
    response.write ">"&jzname(i)&"</option>"
next
%>
</select></td>
</tr>
<tr>
<td width=80% colspan=10>
第三奖项：<select size=1 name="jzn3">
<%
response.write "<option value=0>请选择勋章</option>"
for i=0 to ubound(jzname)-1
    response.write "<option value="&jzid(i)
    if trim(jzpicurl1(i+1))=jz3 then response.write " selected "
    response.write ">"&jzname(i)&"</option>"
next
%>
</select></td>
</tr><br>
<tr>
<td width=80% colspan=10>
第四奖项：<select size=1 name="jzn4">
<%
response.write "<option value=0>请选择勋章</option>"
for i=0 to ubound(jzname)-1
    response.write "<option value="&jzid(i)
    if jzpicurl1(i+1)=jz4 then response.write " selected "
    response.write ">"&jzname(i)&"</option>"
next
%>
</select></td>
</tr>
<tr>
<td width=80% colspan=10>
第五奖项：<select size=1 name="jzn5">
<%
response.write "<option value=0>请选择勋章</option>"
for i=0 to ubound(jzname)-1
    response.write "<option value="&jzid(i)
    if jzpicurl1(i+1)=jz5 then response.write " selected "
    response.write ">"&jzname(i)&"</option>"
next
%>
</select></td>
</tr>
<tr>
<td width=80% colspan=10>
第六奖项：<select size=1 name="jzn6">
<%
response.write "<option value=0>请选择勋章</option>"
for i=0 to ubound(jzname)-1
    response.write "<option value="&jzid(i)
    if jzpicurl1(i+1)=jz6 then response.write " selected "
    response.write ">"&jzname(i)&"</option>"
next
%>
</select></td>
</tr><br>
<tr>
<td width=80% colspan=10>
第七奖项：<select size=1 name="jzn7">
<%
response.write "<option value=0>请选择勋章</option>"
for i=0 to ubound(jzname)-1
    response.write "<option value="&jzid(i)
    if jzpicurl1(i+1)=jz7 then response.write " selected "
    response.write ">"&jzname(i)&"</option>"
next
%>
</select></td>
</tr>
<tr>
<td width=80% colspan=10>
第八奖项：<select size=1 name="jzn8">
<%
response.write "<option value=0>请选择勋章</option>"
for i=0 to ubound(jzname)-1
    response.write "<option value="&jzid(i)
    if jzpicurl1(i+1)=jz8 then response.write " selected "
    response.write ">"&jzname(i)&"</option>"
next
%>
</select></td>
</tr>
<tr>
<td width=80% colspan=10>
第九奖项：<select size=1 name="jzn9">
<%
response.write "<option value=0>请选择勋章</option>"
for i=0 to ubound(jzname)-1
    response.write "<option value="&jzid(i)
    if jzpicurl1(i+1)=jz9 then response.write " selected "
    response.write ">"&jzname(i)&"</option>"
next
%>
</select></td>
</tr>
<tr>
<td width=80% colspan=10>
第十奖项：<select size=1 name="jzn10">
<%
response.write "<option value=0>请选择勋章</option>"
for i=0 to ubound(jzname)-1
    response.write "<option value="&jzid(i)
    if jzpicurl1(i+1)=jz10 then response.write " selected "
    response.write ">"&jzname(i)&"</option>"
next%>
</select></td>
</tr><center>
<tr><td>
<input name="submit" type=submit value="更  新"><input size=45 name="picurl" type=hidden value="<%=jzpic%>">
<input size=45 name="jid" type=hidden value="<%=jid%>"></td></tr>
</form>
<%
else 
call Alert("·该用户不存在！·返回重新填写")
end if
end if%>
</table>

<%
case"savepr"
dim kname,jz2id,j
kname=replace(request.form("ppname"),"'","''")
jzid=replace(request.form("jid"),"'","''")
jzpic=replace(request.form("picurl"),"'","''")


jzpicurl=split(jzpic,"|||")
jz2id=split(jzid,"|||")
if kname="" then response.end
dim jzxg
for i=1 to 10
  if cint(request.form("jzn"&i))=0 then
    jzxg=jzxg&jzpicurl(0)&"|||"
 else
   for j=0 to ubound(jz2id)-1
       if cint(request.form("jzn"&i))=cint(jz2id(j)) then
	       jzxg=jzxg&jzpicurl(j+1)&"|||"
		   exit for
		end if
   next
 end if
next
'call alert(jzid&jzpic&"aaaaaaaa"&jzxg)
'jzxg=request.form("jzn1")& "|||" &request.form("jzn2")& "|||" &request.form("jzn3")& "|||" &request.form("jzn4")& "|||" &request.form("jzn5")& "|||" &request.form("jzn6")& "|||" &request.form("jzn7")& "|||" &request.form("jzn8")& "|||" &request.form("jzn9")& "|||" &request.form("jzn10")
'jzxg=jzpicurl(cint(request.form("jzn1")))&"|||"&jzpicurl(cint(request.form("jzn2")))&"|||"&jzpicurl(cint(request.form("jzn3")))&"|||"&jzpicurl(cint(request.form("jzn4")))&"|||"&jzpicurl(cint(request.form("jzn5")))&"|||"&jzpicurl(cint(request.form("jzn6")))&"|||"&jzpicurl(cint(request.form("jzn7")))&"|||"&jzpicurl(cint(request.form("jzn8")))&"|||"&jzpicurl(cint(request.form("jzn9")))&"|||"&jzpicurl(cint(request.form("jzn10")))

conn.execute("update [KK_user] set jzdata='"&jzxg&"' where name='"&kname&"'")
call alert("·更新用户奖章成功。")

%>
<%
Sub Alert(message)
	message = replace(message,"'","\'")
	Response.Write ("<script LANGUAGE='javascript'>alert('" & message & "');window.location.href='adminright_jzsetp.asp?action=setp';</script>")
	Response.End
End Sub
end select%>