<!-- #include file="include/admin_onlogin.asp" -->
<%
dim nm,Errmsg
index_url="forum"
call admin_master(0,0)
tit_fir="勋章"
tit="勋章管理"
call admin_header(0,0)
%>
<tr><td align=center colspan=2 height=30>
  <table border=0>
  <tr>
  <td><a href='?'>管理首页</a></td>
  <td width=10></td>
  <td><a href='?action=add'>添加勋章</a></td>
<% call joekoe_is_js("",tit_fir) %>
  </tr>
  </table>
</td></tr>
</table>
<%
call admin_table(1)
'----------------------------中间 开始----------------------------
select case action
case "save"
 call savegrade()
case "add"
  call add()
case "savenew"
  call savenew()
case "del"
  call del()
case else
  call gradeinfo()
end select
'----------------------------中间 结束----------------------------
call admin_ender(1)

sub gradeinfo()
%>
<form method="POST" action=admin_xzmanager.asp?action=save>
<tr align=center>
<td class=td width='10%'><%response.write tit_fir%>序号</td>
<td class=td width='20%'><%response.write tit_fir%>名称</td>
<td class=td width='40%'><%response.write tit_fir%>说明</td>
<td class=td width='10%'><%response.write tit_fir%>图片</td>
<td class=td width='10%'><%response.write tit_fir%>演示</td>
<td class=td width='10%'>操作</td>
<%
set rs=conn.execute("select * from xzdata")
nm=1
do while not rs.eof
%>
<tr> 
<td align=center>
<input type=hidden value="<%=nm%>" name="xzcount">
<input size=5 value="<%=rs("xzid")%>" name="xzid" type=text></td>
<td align=center>
<input size=18 value="<%=rs("xzname")%>" name="xzname" type=text></td>
<td>
<input size=50 value="<%=rs("xzsm")%>" name="xzsm" type=text></td>
<td align=center>
<input size=10 value="<%=rs("xzpicurl")%>" name="xzpicurl" type=text></td>
<td align=center><img src='images/xz/<%=rs("xzpicurl")%>'></td>
<td align=center>
<a href="?action=del&xzid=<%=rs("xzid")%>">删除</a></td>
</tr>
<%
nm=nm+1
rs.movenext
loop
rs.close
set rs=nothing
%>
<tr> 
<td colspan=6 align=center> 
<input type="submit" name="Submit" value="提 交">
</td>
</tr>
</form>
<%
end sub
sub savegrade()
	Server.ScriptTimeout=99999999
	dim xzname,xzpicurl,xzsm,xzid
	
	for i=1 to request.form("xzcount").count
	xzname=request.form("xzname")(i)
	xzpicurl=request.form("xzpicurl")(i)
	xzsm=request.form("xzsm")(i)
	xzid=request.form("xzid")(i)
	if isnumeric(xzid) and xzname<>"" and xzpicurl<>"" and xzsm<>"" then
	conn.execute("update xzdata set xzname='"&xzname&"',xzpicurl='"&xzpicurl&"',xzsm='"&xzsm&"' where xzid="&xzid)
	end if
	next
	call admin_msg("奖项设置修改成功，请返回。","?",1)
	set rs=nothing
end sub

sub add()
call admin_td("添加"&tit_fir)
%>
<form method="POST" action=admin_xzmanager.asp?action=savenew>
<table cellpadding=1 cellspacing=4 width="98%" class=table>
    <tr>
      <td >
    <b>注意</b>：<br>
    ①、点击左面导航[<b><font color="#FF0000">奖项管理</font></b>]切换到奖项添加页面。<br>
    ②、请完整填写所有数据，然后进行保存。
    </td>
    </tr>
</table>
<table cellpadding=1 cellspacing=4 width="98%" class=table>
<tr>
<td align="center"><%response.write tit_fir%>名称：</td>
<td><input size=30 name="xzname" type=text><%response.write redx%>不可重复。</td>
</tr>
<tr>
<td align="center"><%response.write tit_fir%>说明：</td>
<td><input size=30 name="xzsm" type=text><%response.write redx%>不可为空。</td>
</tr>
<tr>
<td align="center"><%response.write tit_fir%>图片：</td>
<td><input size=30 name="xzpicurl" type=text><%response.write redx%>不可为空。</td>
</tr>
<tr>
<td align="center" colspan="2"> 
<input type="submit" name="Submit" value="提 交">&nbsp;&nbsp;&nbsp;<input type=reset value='重新填写'></td>
</tr>
</table>
</form>
<%
end sub
sub savenew()
if request.form("xzname")="" then
	call admin_error("请输入 "&tit_fir&"名称 ！")
	exit sub
end if
if request.form("xzsm")="" then
	call admin_error("请输入 "&tit_fir&"描述 ！")
	exit sub
end if
if request.form("xzpicurl")="" then
	call admin_error("请输入 "&tit_fir&"图片 ！")
	exit sub
end if
set rs = server.CreateObject ("Adodb.recordset")
sql="select * from xzdata where xzname='"&request.form("xzname")&"'"
rs.open sql,conn,1,3
if rs.eof and rs.bof then
rs.addnew
rs("xzname")=request.form("xzname")
rs("xzsm")=request.form("xzsm")
rs("xzpicurl")=request.form("xzpicurl")
rs.update
else
	call admin_error(""&tit_fir&"已经存在，请重新输入 ！")
	exit sub
end if
rs.close
set rs=nothing
 call admin_msg("该奖项已被成功添加！建议您到奖项管理器中进行属性操作！","?",1)
end sub
sub del()
Server.ScriptTimeout=99999999
dim xzid
if isnumeric(request("xzid")) then
conn.execute("delete from xzdata where xzid="&request("xzid"))
call admin_msg("删除成功！建议您到奖项属性管理器中进行其他操作！","?",1)
set rs=nothing
end if
end sub
%>