<%qx="01"%>
<!--#include file="0.asp"-->
<!--#include file="menu.asp"-->
<!--#include file="../../mycartconn/md5.asp" -->
<!--#include file="../../mycartconn/conn.asp"-->
<link href="../../mycartconn/admin.css" rel="stylesheet" type="text/css">
<body>
<%
Select case request("abc")
case "del"
conn.execute("Delete admin where adminid="&request("id")&"")
response.redirect"?"
case "xiu_ok"
conn.execute("Update admin set qx='"&request("qx")&"' where adminid="&request("id")&"")
Response.Write("<script>alert(""修改权限成功"");location.href=""?"";</script>")
case "add_ok"  
adminname = request("adminname")
adminpass = md5(request("adminpass"))
qx = request("qx")
sql = "Select * From admin Where adminname = '"&adminname&"'"
set rs = conn.Execute(sql)
If Not rs.EOF Then
Response.Write "<br><br><font color=#ff6666>您填写的用户名已经有人使用了。</font>"
Response.End
End If
rs.close
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "admin", conn, 1, 2
rs.AddNew
rs("adminname") = adminname
rs("adminpass") = adminpass
rs("qx") = qx
rs.Update
rs.close
Response.Write("<br><br>&nbsp;&nbsp;&nbsp;&nbsp;管理员添加成功！")
case "add" %>
<script language="JavaScript">
function CheckAll(form) {
for (var i=0;i<form.elements.length;i++) {
var e = form.elements[i];
if (e.name != 'chkall') e.checked = form.chkall.checked; 
}
}
function checksignup() {
		if ( document.form.adminname.value == '' ) {
			window.alert('请输入名称!!');
			document.form.adminname.focus();
			return false;
		}
		if ( document.form.adminpass.value == '' ) {
			window.alert('请输入密码!!');
			document.form.adminpass.focus();
			return false;
		}
		if ( document.form.adminpass2.value == '' ) {
			window.alert('请输入确认密码!!');
			document.form.adminpass2.focus();
			return false;
		}
		if ( document.form.adminpass2.value != document.form.adminpass.value) {
			window.alert('密码与确认密码不一致!!');
			document.form.adminpass2.focus();
			return false;
		}
			return true;
			}
</script>
  <form action="?abc=add_ok" method="post" name="form" id="form">
    <table width="650" align="center">
      <tr> 
        <td height="25" colspan="2" align="center" valign="middle" bgcolor="#CCCCCC"><b><font
      color="#FF9966">增加管理员</font></b></td>
      </tr>
      <tr> 
        <td width="100" height="25" align="center" valign="middle" bgcolor="#f1f1f1">管理账号</td>
        <td width="550" valign="middle" bgcolor="#f1f1f1">
<input name="adminname" type="text" class="wenbenkuang" id="adminpass3" size="25" maxlength="20"></td>
      </tr>
      <tr> 
        <td width="100" height="25" align="center" valign="middle" bgcolor="#f1f1f1">管理密码</td>
        <td width="550" valign="middle" bgcolor="#f1f1f1"> 
          <input name="adminpass" type="password" class="wenbenkuang" id="adminpass" size="25" maxlength="20"></td>
      </tr>
      <tr> 
        <td width="100" height="25" align="center" valign="middle" bgcolor="#f1f1f1">密码确认</td>
        <td width="550" valign="middle" bgcolor="#f1f1f1">
<input name="adminpass2" type="password" class="wenbenkuang" id="adminpass2" size="25" maxlength="20"></td>
      </tr>
      <tr>
        <td width="100" height="25" align="center" valign="top" bgcolor="#f1f1f1"><p>&nbsp;</p>
          <p>管理权限</p></td>
        <td width="550" valign="middle" bgcolor="#f1f1f1"> 
<%admin_add()%>
        </td>
      </tr>
      <tr> 
        <td width="100" height="25" align="center" valign="middle" bgcolor="#f1f1f1">&nbsp;</td>
        <td width="550" valign="middle" bgcolor="#f1f1f1"> 
          <input type="submit" name="Submit" value="添加" class="go-wenbenkuang"  ONCLICK="javascript:return checksignup()"> 
          <input type="button" name="Submit2" value="返回" class="go-wenbenkuang" onClick="history.go(-1)">
          &nbsp;&nbsp;
          <input name=chkall type=checkbox value=on onClick=CheckAll(this.form)>
          选择所有权限 </td>
      </tr>
    </table>
    </form>
<%case "xiu"%>
<script language="JavaScript">
function CheckAll(form) {
for (var i=0;i<form.elements.length;i++) {
var e = form.elements[i];
if (e.name != 'chkall') e.checked = form.chkall.checked; 
}
}
</script>
  <form action="?abc=xiu_ok&id=<%=request("id")%>" method="post" name="form" id="form">
    
  <table width="650" align="center">
    <tr> 
      <td height="25" align="center" valign="middle" bgcolor="#CCCCCC"><b><font
      color="#FF9966">修改管理员管理权限</font></b></td>
    </tr>
    <tr> 
      <td height="25" valign="middle" bgcolor="#f1f1f1"> 
<%admin_xiu()%> </td>
    </tr>
    <tr> 
      <td width="550" height="25" valign="middle" bgcolor="#f1f1f1"> <input type="submit" name="Submit" value="修改" class="go-wenbenkuang"> 
        <input type="button" name="Submit2" value="返回" class="go-wenbenkuang" onClick="history.go(-1)"> 
        &nbsp;&nbsp; <input name=chkall type=checkbox value=on onClick=CheckAll(this.form)>
        选择所有权限 </td>
    </tr>
  </table>
    </form>
<%case else%>
  <p>&nbsp;</p>
<table width="350" align="center">
  <tr valign="middle" bgcolor="#CCCCCC"> 
    <td width="100" align="center">自动编号</td>
    <td width="200" height="25">管理员名称</td>
    <td width="150" align="center">修改权限丨删除</td>
  </tr>
  <%set rs = conn.execute("select adminid,adminname from admin order by adminid")
  do while not rs.eof%>
    <tr valign="middle" bgcolor="#f1f1f1"> 
      <td width="100" align="center">ID: 
        <% =rs("adminid")%> <input name="adminid" type="hidden" id="adminid2" value="<%=rs("adminid")%>"></td>
      <td width="200" height="25"> <%=rs("adminname")%> </td>
      <td width="150" align="center"> <input name="Submit32" type="button" class="go-wenbenkuang" value="修改权限" onClick=" window.location='?abc=xiu&id=<% =rs("adminid")%>'"> 
        <input name="Submit" type="button" class="go-wenbenkuang" id="Submit" value="删除" onClick=" window.location='?abc=del&id=<% =rs("adminid")%>'"> 
      </td>
    </tr>
<%rs.movenext
loop
rs.close
%>
</table>
<%End Select
sub admin_xiu()
qx=conn.execute("select qx from admin where adminid="&request("id")&"")(0)
for i=0 to ubound(menu,1)
Response.Write("<b>"&menu(i,0)&"</b><br>")
for j=1 to ubound(menu,2)
if isempty(menu(i,j)) then exit for
tmpmenu=split(menu(i,j),",")
menuname=tmpmenu(0)
Response.Write("<input type=checkbox name=qx value=")
Response.Write i&j
if instr(qx,i&j)<>0 then
response.write " checked"
end if
Response.Write(">")
Response.Write menuname
Response.Write "&nbsp;&nbsp;" 
next
Response.Write("<br><br>")
next
end sub

sub admin_add()
for i=0 to ubound(menu,1)
Response.Write("<b>"&menu(i,0)&"</b><br>")
for j=1 to ubound(menu,2)
if isempty(menu(i,j)) then exit for
tmpmenu=split(menu(i,j),",")
menuname=tmpmenu(0)
Response.Write "<input type=checkbox name=qx value="
Response.Write i&j
Response.Write ">"
Response.Write menuname
Response.Write "&nbsp;&nbsp;"

'xs=" <input type=checkbox name=qx value="&i&j&">"&menuname&"&nbsp;&nbsp;"
'Response.Write xs
next
Response.Write("<br><br>")
next
end sub
conn.close
set conn=nothing

%>