<!-- #include file="conn.asp" -->
<!-- #include file="cookies.asp" -->
<%'if instr(session("flag"),1)=0 then
  'response.redirect "a_login.asp?t=权限不够！"
  'response.end
'end if%>
<html>
<head>
<title>增加修改管理员</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<BODY><div align="center">
  <table width="96%"  border="0" cellpadding="4" cellspacing="1" bgcolor="#000066">
            <tr>
              <td bgcolor="#FFCC33" style="color:red">&nbsp;&nbsp;&nbsp;<strong>新增一个管理员</strong> </td>
            </tr>
  </table>
		  <%
'增加一个管理员
  set rs2=server.createobject("adodb.recordset")
  sql2="select count(*) from admin where admin='"&request("admin1")&"'"
  rs2.open sql2,conn,3,3
   if rs2(0)<>0 then
  response.redirect "error1.asp?err_on=6"
end if
 if request("types")="addname" then
 if request("admin1")="" or request("psw1")="" then
  response.end
 else
  set rs1=server.createobject("adodb.recordset")
  sql1="select * from admin"
  rs1.open sql1,conn,3,3
  rs1.addnew
  rs1("admin")=request("admin1")
  rs1("psw")=request("psw1")
  rs1("flag")=request("flag1")
  rs1.update
  rs1.close
  set rs1=nothing
 end if
end if
rs2.close
set rs2=nothing
'修改一个管理员
if request("types")="mod" then
  sql4="update admin set admin='"&request("admin")&"',psw='"&request("psw")&"',flag='"&request("flag")&"' where id="&request("id")
  conn.execute(sql4)
end if
 if request("types")="del" then
 sql5="delete from admin where id="&request("id")
 conn.execute(sql5)
 end if
 set rs=server.createobject("adodb.recordset") 
   sql="select count(*) from admin"
   rs.open sql,conn,3,3
   if rs(0)=0 then
   response.write "<center>对不起，还没有任何一个管理员，请新增一个管理员。"
   rs.close
   set rs=nothing
 %>
  <table width="96%" border="1" cellpadding="5" cellspacing="0" bordercolor="f7f7f7">
      <form action="admin.asp" method=post><tr> 
        <td width="15%" align="right"><span style="font-size: 9pt">姓名：</span></td>
        <td width="35%"> 
          <input type="text" name="admin1">      </td>
        <td width="15%" align="right"><span style="font-size: 9pt">密码：</span></td>
        <td width="35%"><input type="password" name="psw1" size="20"></td>
      </tr>
	<tr> 
        <td align="right"><span style="font-size: 9pt">权限：</span></td>
        <td colspan="3">
		<input name="flag1" type="checkbox" value="1" checked>管理报价
		<input name="flag1" type="checkbox" value="2">管理经销商
		<input name="flag1" type="checkbox" value="3">管理产品
		<input name="flag1" type="checkbox" value="4">管理分类
		<input name="flag1" type="checkbox" value="5" checked>管理新闻
		<input name="flag1" type="checkbox" value="6">管理员帐号
		</td>
        </tr>
	<tr align="center">
	  <td colspan="4">&nbsp;
	    <input type="submit" name="addname" value="提交">
	    <input type=hidden name="types" value="addname"></td>
	  </tr> </form>
  </table>  
  <% else %>
  
<table width="96%" border="1" cellpadding="5" cellspacing="0" bordercolor="f7f7f7">
      <form action="admin.asp" method=post><tr> 
        <td width="15%" align="right"><span style="font-size: 9pt">姓名：</span></td>
        <td width="35%"> 
          <input type="text" name="admin1">      </td>
        <td width="15%" align="right"><span style="font-size: 9pt">密码：</span></td>
        <td width="35%"><input type="password" name="psw1" size="20"></td>
      </tr>
	<tr> 
        <td align="right"><span style="font-size: 9pt">权限：</span></td>
        <td colspan="3">
		<input name="flag1" type="checkbox" value="1" checked>管理报价
		<input name="flag1" type="checkbox" value="2">管理经销商
		<input name="flag1" type="checkbox" value="3">管理产品
		<input name="flag1" type="checkbox" value="4">管理分类
		<input name="flag1" type="checkbox" value="5" checked>管理新闻
		<input name="flag1" type="checkbox" value="6">管理员帐号
		</td>
        </tr>
	<tr align="center">
	  <td colspan="4">&nbsp;
	    <input type="submit" name="addname" value="提交">
	    <input type=hidden name="types" value="addname"></td>
	  </tr> </form>
  </table>  <br>

  <table width="96%"  border="0" cellpadding="4" cellspacing="1" bgcolor="#000066">
            <tr>
              <td bgcolor="#FFCC33" style="color:red">&nbsp;&nbsp;&nbsp;<strong>管理帐号</strong> </td>
            </tr>
  </table>
   <% set rs3=server.createobject("adodb.recordset")
    sql3="select * from admin"
    rs3.open sql3,conn,3,3
  %>
 <%rs3.movefirst
   for i=1 to rs3.recordcount
  %>
    <table width="96%" border="1" cellpadding="3" cellspacing="0" bordercolor="f7f7f7">
      <form method=post action="admin.asp">
      <tr>
        <td width="5%" rowspan="2" align="center"><%=trim(rs3("id"))%></td>
        <td width="40%" align="center"> 
          <input type="text" name="admin" value="<%=trim(rs3("admin"))%>" size="20">        </td>
        <td width="40%" align="center"> 
          <input type="password" name="psw" value="<%=trim(rs3("psw"))%>" size="20">        </td>
        <td width="15%" align="center"> 
          <input type="submit" name="modify" value="修改">
		  <input type="hidden" name="id" value="<%=rs3("id")%>">
	    <input type="hidden" name="types" value="mod"></td>
      </tr>
      <tr>
        <td colspan="2">
		<input name="flag" type="checkbox" value="1" <%if instr(rs3("flag"),1)<>0 then Response.Write("checked") end if%>>管理报价
		<input name="flag" type="checkbox" value="2" <%if instr(rs3("flag"),2)<>0 then Response.Write("checked") end if%>>管理经销商
		<input name="flag" type="checkbox" value="3" <%if instr(rs3("flag"),3)<>0 then Response.Write("checked") end if%>>管理产品
		<input name="flag" type="checkbox" value="4" <%if instr(rs3("flag"),4)<>0 then Response.Write("checked") end if%>>管理分类
		<input name="flag" type="checkbox" value="5" <%if instr(rs3("flag"),5)<>0 then Response.Write("checked") end if%>>管理新闻
		<input name="flag" type="checkbox" value="6" <%if instr(rs3("flag"),6)<>0 then Response.Write("checked") end if%>>管理员帐号
		</td>
        <td align="center">
	    <input type="button" name="del" value="删除" onClick="window.location.href=('admin.asp?types=del&id=<%=rs3("id")%>')"></td>
      </tr> </form>
  </table>
    <br>
    <%
 rs3.movenext
 next
 rs3.close
 set rs3=nothing
  end if
 conn.close
 set conn=nothing
%>
  </div>
</body>
</html>

