<!--#include virtual="inc/General.inc.asp"-->
<%
CheckManageUser()
code = replace(request("code"),"'","''")
set rs = server.createobject("adodb.recordset")
p = cint("0"&request("p"))
if p<1 then p=1
pagesize=12
rs.open "select count(MenuCode) from Menu",conn,1,1
totalcount=rs(0)
rs.cancel:rs.close
pagecount=totalcount \ pagesize
if totalcount mod pagesize>0 then pagecount=pagecount+1
if p=1 then
strsql = "select top " & pagesize & " * from Menu order by MenuCode"
else
strsql = "select top " & pagesize & " * from Menu where MenuCode not in (select top " & ((p-1)*pagesize) & " MenuCode from Menu order by MenuCode) order by MenuCode"
end if
rs.open strsql,conn,1,1
dim listtype(3)
listtype(0)=""
listtype(1)="文本内容"
listtype(2)="文字列表"
listtype(3)="图片列表"
%>
<html>

<head>
<title>后台管理系统</title>
<link rel="stylesheet" href="../../css/main.css">
<script language="javascript" src="../../js/yzqm.js.asp"></script>
</head>

<body topmargin="0" leftmargin="0">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tr>
	<td height="25" bgcolor="#EFEFEF" class="dtd" style="color:#FF6600">&nbsp;当前位置：菜单管理</td>
  </tr>
  <tr>
	<td>
	  <table border="0" cellpadding="1" cellspacing="0" width="99%" align="right">
		<form name="AddForm" method="post" action="SaveMenu.asp" onsubmit="if(this.MenuCode.value==''){alert('请输入编号！');this.MenuCode.focus();return false;}else if(this.MenuName.value==''){alert('请输入名称！');this.MenuName.focus();return false;}else{return true;}">
		<tr>
		  <td height="25">编号：<input type="text" name="MenuCode" onchange="this.value=this.value.replace(/\D/gi,'')" size="6" class="inbox">　　名称：<input type="text" name="MenuName" onchange="this.value=this.value.replace(/(^\s*)|(\s*$)|[\']/gi,'')" size="10" class="inbox">　类型：<select name="ListType" class="inbox">
				  <%for i=0 to ubound(listtype)%>
				  <option value="<%=i%>"<%if cint("0"&rs("ListType"))=i then Response.write " selected" end if%>><%=listtype(i)%></option>
				  <%next%>
				  </select>　　<input type="submit" value=" 添加 " class="in1"></td>
		</tr>
		</form>
		<tr>
		  <td height="25"></td>
		</tr>
		<tr>
		  <td>
			<table border="0" cellpadding="1" cellspacing="1" width="100%" bgcolor="#00599C">
			  <tr bgcolor="#A5CCFF">
				<td height="23" align="center">编号</td>
				<td align="center">名称</td>
				<td align="center">类型</td>
				<td align="center">是否显示</td>
				<td align="center">修改</td>
				<td align="center">操作</td>
			  </tr>
			  <%while not rs.eof%>
			  <%if code=rs("MenuCode")&"" then%>
			  <form name="EditForm" method="get" action="SaveMenu.asp">
			  <tr bgcolor="#FFFFFF">
				<td height="25" align="center">&nbsp;<input type="hidden" name="MenuCode" value="<%=rs("MenuCode")%>"><%=rs("MenuCode")%>&nbsp;&nbsp;</td>
				<td align="center">&nbsp;<input type="text" onchange="this.value=this.value.replace(/(^\s*)|(\s*$)|[\']/gi,'')" name="MenuName" value="<%=rs("MenuName")%>">&nbsp;&nbsp;</td>
				<td align="center"><%if rs("SubKey")&""="0" then%><select name="ListType" class="inbox">
				  <%for i=0 to ubound(listtype)%>
				  <option value="<%=i%>"<%if cint("0"&rs("ListType"))=i then Response.write " selected" end if%>><%=listtype(i)%></option>
				  <%next%>
				  </select><%end if%>
				</td>
				<td align="center"><select name="IsStop" class="inbox">
				  <option value="0"<%if cint("0"&rs("IsStop"))=0 then Response.write " selected" end if%>>是</option>
				  <option value="1"<%if cint("0"&rs("IsStop"))=1 then Response.write " selected" end if%>>否</option>
				  </select></td>
				<td align="center"><a href="#" onclick="javascirpt:if(EditForm.MenuName.value==''){alert('请输入名称！');EditForm.MenuName.focus();}else{EditForm.submit();}">确定</a></td>
				<td align="center"><a href="Menu.asp">取消</a></td>
			  </tr>
			  </form>
			  <%else%>
			  <tr bgcolor="#FFFFFF">
				<td height="25" align="center">&nbsp;<%=rs("MenuCode")%>&nbsp;&nbsp;</td>
				<td align="center">&nbsp;<%=rs("MenuName")%>&nbsp;&nbsp;</td>
				<td align="center"><%if rs("SubKey")&""="0" then%><%=listtype(rs("listtype"))%><%end if%></td>
				<td align="center"><%if rs("IsStop")&""="0" then response.write "是" else response.write "否" end if%></td>
				<td align="center"><a href="Menu.asp?p=<%=p%>&code=<%=rs("MenuCode")%>">修改</a></td>
				<td align="center"><a href="javascript:if(confirm('你确定要删除此菜单吗？')) window.location.href='DeleteMenu.asp?MenuCode=<%=rs("MenuCode")%>'">删除</a></td>
			  </tr>
			  <%end if%>
			  <%rs.movenext
			  wend%>
			</table>
			<%rs.cancel:rs.close%>
		  </td>
		</tr>
		<tr>
		  <td height="25" align="right"><%if p>1 then%><a href="Menu.asp?p=1">首页</a>　<a href="Menu.asp?p=<%=p-1%>">上一页</a>　<%end if%><%if p<pagecount then%><a href="Menu.asp?p=<%=p+1%>">下一页</a>　<a href="Menu.asp?p=<%=pagecount%>">末页</a><%end if%></td>
		</tr>
	  </table>
	</td>
  </tr>
</table>
</body>

<html>
<%CloseConnection()%>