<!--#include file="conn.asp"-->
<!-- #include file="inc/const.asp" -->
<!--#include file=inc/char.asp-->
<!--#include file=chkuser.asp-->

<head>

<title><%=ForumName%>--管理页面</title>
<link rel="stylesheet" type="text/css" href="forum.css">

</head>

<BODY <%=ForumBody%>>
<% dim shop 
set rs= server.createobject ("adodb.recordset")
	if instr(session("flag"),"04")=0 then
		Errmsg=Errmsg+"<br>"+"<li>本页面为管理员专用，请<a href=admin_index.asp target=_top>登陆</a>后进入。<br><li>您没有管理本页面的权限。"
		call Error()
	else
		dim body
		call main()
		set rs=nothing
		conn.close
		set conn=nothing
	end if
    sub main()
%>
<table cellpadding=0 cellspacing=0 border=0 width=<%=tablewidth%> bgcolor=<%=tablebackcolor%> align=center>
  <tr>
    <td>
      <table cellpadding=3 cellspacing=1 border=0 width=100%>
        <tr bgcolor='<%=Tabletitlecolor%>'>
        <td><font color="<%=TablefontColor%>">欢迎<b><%=membername%></b>进入管理页面</font>
        </td>
        </tr>
            <tr bgcolor=<%=tablebodycolor%>>
          <td width="100%" valign=top><font color="<%=TableContentColor%>">
<%
	if request("action")="add" then 
		call add()
	elseif request("action")="savenew" then
		call savenew()
	elseif request("action")="del" then
		call del()
	else
rs.open "select * from shop order by id",conn,1,1
%>
<center><a href="admin_shop.asp?action=add">添加物品</a></center>
<% if rs.bof and rs.eof then
response.write "没有商品！"
else
%>
<table border="0" align="center" width="<%=TableWidth%>" cellspacing="1" cellpadding="0" bgcolor="<%=tablebackcolor%>">
  <tr>
    <td width="15%">
      <table border="0" width="100%" align="center" cellspacing="0" cellpadding="6">
	    <tr>
	      <td bgcolor="<%=tabletitlecolor%>" align="center">商品名称</td>
		</tr>
	  </table>
	</td>
	<td width="10%">
      <table border="0" width="100%" align="center" cellspacing="0" cellpadding="6">
	    <tr>
	      <td bgcolor="<%=tabletitlecolor%>" align="center">商品图片</td>
		</tr>
	  </table>
	</td>
	<td width="40%">
      <table border="0" width="100%" align="center" cellspacing="0" cellpadding="6">
	    <tr>
	      <td bgcolor="<%=tabletitlecolor%>" align="center">商品介绍</td>
		</tr>
	  </table>
	</td>
	<td width="15%">
      <table border="0" width="100%" align="center" cellspacing="0" cellpadding="6">
	    <tr>
	      <td bgcolor="<%=tabletitlecolor%>" align="center">商品功能</td>
		</tr>
	  </table>
	</td>
	<td width="10%">
      <table border="0" width="100%" align="center" cellspacing="0" cellpadding="6">
	    <tr>
	      <td bgcolor="<%=tabletitlecolor%>" align="center">商品价格</td>
		</tr>
	  </table>
	</td>
	<td width="10%">
      <table border="0" width="100%" align="center" cellspacing="0" cellpadding="6">
	    <tr>
	      <td bgcolor="<%=tabletitlecolor%>" align="center">删除商品</td>
		</tr>
	  </table>
	</td>
  </tr>
<% 
   do while not rs.eof 
   shop=split(rs("shop"),"|")
%>
<form action="shop.asp?action=mai&id=<%=rs("id")%>" method="post">
  <tr>
    <td>
      <table border="0" width="100%" height="40" align="center" cellspacing="0" cellpadding="0">
	    <tr>
	      <td bgcolor="<%=tablebodycolor%>" align="center"><%=shop(0)%></a></td>
		</tr>
	  </table>
	</td>
	<td >
      <table border="0" width="100%" height="40" align="center" cellspacing="0" cellpadding="0">
	    <tr>
	      <td bgcolor="<%=tablebodycolor%>" align="center"><img src="<%=shop(2)%>" alt="<%=shop(1)%>"></td>
		</tr>
	  </table>
	</td>
	<td >
      <table border="0" width="100%" height="40" align="center" cellspacing="0" cellpadding="0">
	    <tr>
	      <td bgcolor="<%=tablebodycolor%>" align="center"><%=shop(3)%></td>
		</tr>
	  </table>
	</td>
	<td >
      <table border="0" width="100%" height="40" align="center" cellspacing="0" cellpadding="0">
	    <tr>
	      <td bgcolor="<%=tablebodycolor%>" align="center">体力+<%=shop(4)%>，魅力+<%=shop(5)%></td>
		</tr>
	  </table>
	</td>
	<td >
      <table border="0" width="100%" height="40" align="center" cellspacing="0" cellpadding="0">
	    <tr>
	      <td bgcolor="<%=tablebodycolor%>" align="center"><%=shop(6)%> ￥</td>
		</tr>
	  </table>
	</td>
	<td >
      <table border="0" width="100%" height="40" align="center" cellspacing="0" cellpadding="0">
	    <tr>
	      <td bgcolor="<%=tablebodycolor%>" align="center"><a href="admin_shop.asp?action=del&id=<%=rs("id")%>">删除</a></td>
		</tr>
	  </table>
	</td>
  </tr>
 </form>
<% rs.movenext
   loop
   rs.close
 %>
 </td></tr>
</table>
<% end if
   end if
   end sub %>
<% sub add() %>
<form method="post" action="admin_shop.asp?action=savenew">
物品名称：<INPUT TYPE="text" NAME="name" size=20><br>
物品单位：<INPUT TYPE="text" NAME="danwei" size=10><br>
图片地址：<INPUT TYPE="text" NAME="picurl" size=20><br>
物品介绍：<INPUT TYPE="text" NAME="jieshao" size=40>不能超过50字符！<br>
物品功能：体力：<INPUT TYPE="text" NAME="userep" size=8> 魅力：<INPUT TYPE="text" NAME="usercp" size=8><br>
物品价格：<INPUT TYPE="text" NAME="jiage" size=10> ￥<br>
<INPUT TYPE="submit" value="添加">
</form>
<% end sub %>
<% sub savenew()
   name=trim(request("name"))
   danwei=trim(request("danwei"))
   picurl=trim(request("picurl"))
   jieshao=trim(request("jieshao"))
   userep=trim(request("userep"))
   usercp=trim(request("usercp"))
   jiage=trim(request("jiage"))
   if name="" or danwei="" or picurl="" or jieshao="" or userep="" or usercp="" or jiage="" then
   response.write "资料填写不完整！ <a href='javascript:history.go(-1)'>返回</a>"
   elseif len(jieshao)>50 then
   response.write "物品介绍不能超过50字符！ <a href='javascript:history.go(-1)'>返回</a>"
   elseif not(isnumeric(userep) and isnumeric(usercp) and isnumeric(jiage)) then
   response.write "物品功能和物品价格都必须为数字！ <a href='javascript:history.go(-1)'>返回</a>"
   else
   rs.open "select * from shop",conn,1,3
   rs.addnew
   rs("shop")=name &"|"& danwei &"|"& picurl &"|"& jieshao &"|"& userep &"|"& usercp &"|" & jiage
   rs.update
   rs.close
   response.write "添加完成！"
   end if
   end sub %>
<% sub del() 
   id=request.querystring("id")
   rs.open "select * from shop where id="&id&"",conn,1,1
   if rs.bof and rs.eof then
   response.write "错误：没有你指定的记录！&nbsp;&nbsp<a href=javascript:history.go(-1)>返回</a></FONT></CENTER>"
   else
   conn.execute ("delete from shop where id="&id&"")
   response.write "删除成功！"
   end if
   end sub 
 %>
