<% if session("admid")="" or Session("class")<>"1" then response.redirect"login.asp"%>
<!--#include file="conn.asp"-->
<title>管理员设置</title>
<link rel="stylesheet" type="text/css" href="style.css">
<%
function err(strin)                             'err("×　请填写...")
Response.Write("<script language=javascript>")
Response.Write("alert('")
Response.Write(strin)
Response.Write("');")
Response.Write("history.go(-1);")
Response.Write("</script>")
Response.End()
end function
%>
<!--显示-->
<%if request("do")="" then%>
<style type="text/css">
<!--
body,td,th {
	font-size: 12px;
}
-->
</style><br>
<br>
<table width="700" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#006d63" style="border-collapse: collapse">
<tr><td align="center" bgcolor="#006d63" style="border-bottom:1px solid #FFFFFF;"><b><font color="#FFFFFF">管理员设置</font></b></td>
</tr>
<tr><td align="center" bgcolor="#FFFFFF"><table width="700" border="0" align="center" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
  <tr>
    <td bgcolor="#FFFFFF">　</td>
  </tr>
  <tr>
    <td align="center" bgcolor="#FFFFFF"><table border="0" cellpadding="0" style="border-collapse: collapse" width="700">
        <form id="addadmin" method="POST" action="?do=edit">
          <tr>
            <td style="border-bottom-style: dotted; border-bottom-width: 1px; padding: 0" colspan="7">&nbsp;+&nbsp;添加管理员:</td>
          </tr>
          <tr>
            <td width="61" align="right">帐号:</td>
            <td width="125"><input type="text" name="admname" size="15"></td>
            <td width="72" align="right">密码:</td>
            <td width="123"><input type="text" name="admpass" size="15"></td>
            <td width="34" align="right">权限</td>
            <td width="169"><select name="flag" id="flag">
              <option value="1" selected>一般管理员</option>
              <option value="2">校刊管理员</option>
                        </select></td>
            <td width="78" align="center"><input type="submit" value="添加" name="addadmin"></td>
          </tr>
        </form>
    </table></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">　</td>
  </tr>
  <tr>
    <td align="center" bgcolor="#FFFFFF"><table border="0" cellpadding="0" style="border-collapse: collapse" width="700">
        <tr>
          <td colspan="7">&nbsp;--&nbsp;已有管理员:</td>
        </tr>
        <%
sql="select * from jw_admin order by id desc"
rs.open sql,conn,1,1
do while not rs.eof
%>
        <tr>
          <form id="editadmin" method="POST" action="?do=edit&id=<%=rs("id")%>">
            <td width="60" align="right" style="border-top-style: dotted; border-top-width: 1px; border-bottom-style: dotted; border-bottom-width: 1px; padding: 0">帐号:</td>
            <td width="124" style="border-top-style: dotted; border-top-width: 1px; border-bottom-style: dotted; border-bottom-width: 1px; padding: 0"><input type="text" name="admname" size="15" value="<%=rs("u_id")%>"></td>
            <td width="75" align="right" style="border-top-style: dotted; border-top-width: 1px; border-bottom-style: dotted; border-bottom-width: 1px; padding: 0">密码:</td>
            <td width="118" style="border-top-style: dotted; border-top-width: 1px; border-bottom-style: dotted; border-bottom-width: 1px; padding: 0"><input type="password" name="admpass" size="15" value="<%=rs("p_wd")%>"></td>
            <td width="36" align="right" style="border-top-style: dotted; border-top-width: 1px; border-bottom-style: dotted; border-bottom-width: 1px; padding: 0">权限</td>
            <td width="110" style="border-top-style: dotted; border-top-width: 1px; border-bottom-style: dotted; border-bottom-width: 1px; padding: 0"><select name="flag" id="flag">
              <option value="1" <%If Rs("class")="1" Then response.Write("Selected")%>>一般管理员</option>
              <option value="2" <%If Rs("class")="2" Then response.Write("Selected")%>>校刊管理员</option>
                        </select></td>
            <td width="139" align="center" style="border-top-style: dotted; border-top-width: 1px; border-bottom-style: dotted; border-bottom-width: 1px; padding: 0"><input type="submit" value="修改" name="editadmin">
&nbsp;
              <input value="删除" onClick="window.location.href='?do=del&id=<%=rs("id")%>'" type="reset" name="deladmin"></td>
          </form>
        </tr>
        <%
rs.movenext
loop
rs.close
%>
    </table></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">　</td>
  </tr>
</table></td>
</tr>
</table>
<%end if%>
<!--添加修改-->
<%if request("do")="edit" then%>
<%

if request("admname")="" or request("admpass")="" then
err("×　请填写管理员帐号和密码...")
end if
if request("id")<>"" then
	sql="select * from jw_admin where id="&request("id")
	rs.open sql,conn,3,2
else
	sql="select * from jw_admin where u_id='"&request("admname")&"'"
	rs.open sql,conn,3,2
	if rs.eof then
	rs.addnew
	else %>
<script language=javascript>alert("该用户名已存在！");this.location.href='?'</script>
<%end if 
end if
	
	rs("u_id")=request("admname")
	rs("p_wd")=request("admpass")
    rs("class")=request("flag")
	rs.update
	rs.close
response.redirect ("admin_list.asp")
%>
<%end if%>
<!--删除-->
<%if request("do")="del" then%>
<%
sql="select * from jw_admin where id="&request("id")
rs.open sql,conn,1,3
rs.delete
rs.update
rs.close
response.redirect ("admin_list.asp")
%>
<%end if%>
