<!--#include file="chklogin.asp"-->
<!--#include file="../conn.asp"-->
<!--#include file="../md5.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>快问管理-管理员管理</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#FF9999">
<br><br>
<br>
<br>
<%
Response.Buffer = True 
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1 
Response.Expires = 0 
Response.CacheControl = "no-cache"

if session("userflag")="编辑管理员" then
response.Write("&nbsp;&nbsp;&nbsp;&nbsp;你没有权限进行此项操作！")
response.End()
end if

dim action,id,username,userflag
action=request.QueryString("action")
id=request.QueryString("id")
username=request.Form("username")
userflag=request.Form("userflag")
userpsd=request.Form("userpsd")

if action="xg" then
call xg()
elseif action="tj" then
call tj()
elseif action="sc" then
call sc()
end if

sub xg()
set rs=server.CreateObject("adodb.recordset")
sql="select * from kw_admin where id="&id
rs.open sql,conn,1,3
rs("username")=username
rs("userflag")=userflag
rs.update
   rs.close
   set rs=nothing
response.write "<script language=javascript>alert('修改成功');history.go(-1);</script>"
response.End
end sub

sub tj()
if username<>"" then
set rs=server.CreateObject("adodb.recordset")
sql="select * from kw_admin where username='"&username&"'"
rs.open sql,conn,1,3
 if rs.eof and rs.bof then
rs.addnew
rs("username")=username
rs("userflag")=userflag
rs("userpsd")=md5(userpsd,16)
rs.update
  else
  response.write "<script language=javascript>alert('已经有该用户');history.go(-1);</script>"
  end if
   rs.close
   set rs=nothing
response.write "<script language=javascript>alert('添加成功');history.go(-1);</script>"
response.End
end if
end sub

sub sc()
sql="delete from kw_admin where id="&id
conn.execute sql
response.write "<script language=javascript>alert('成功删除');history.go(-1);</script>"
response.End
end sub

set rs=server.CreateObject("adodb.recordset")
sql="select * from kw_admin"
rs.open sql,conn,1,1
%>
<table width="680" border="0" align="center" cellpadding="0" cellspacing="1" class="tablebg">
  <tr align="center" bgcolor="#ff6666">
    <td height="25" colspan="3" class="font_bt">系 统 用 户 管 理</td>
  </tr>
  <tr align="center" bgcolor="#ff6666">
    <td width="34%" height="25" bgcolor="#ff6666">管理员名称</td>
    <td width="36%">管理等级</td>
    <td width="30%">管理按钮</td>
  </tr>
  <%for i=1 to rs.recordcount%>
  <form action="manageadmin.asp?action=xg&id=<%=rs("id")%>" method="post">
  <tr align="center" bgcolor="#ff6666">
    <td height="30"><input name="username" type="text" id="username" value="<%=rs("username")%>" size="18" align="absmiddle">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
    <td>
	  <input type="radio" name="userflag" value="超级管理员"<%if rs("userflag")="超级管理员" then%>checked<%end if%>>&nbsp;超级管理员&nbsp;&nbsp;
      <input type="radio" name="userflag" value="编辑管理员"<%if rs("userflag")="编辑管理员" then%>checked<%end if%>>&nbsp;编辑管理员
	  </td>
    <td><input type="submit" name="Submit" value="修 改">&nbsp;&nbsp;&nbsp;&nbsp;<a href="manageadmin.asp?action=sc&id=<%=rs("id")%>" onClick="return confirm('您确定进行删除操作吗？')">删除 ？</a></td>
  </tr>
  </form>
  <%
  rs.movenext
  next
     rs.close
   set rs=nothing
   closedb
  %>
  <form action="manageadmin.asp?action=tj" method="post" name="kstj">
  <tr align="center" bgcolor="#ff6666">
    <td height="30">用户名：
      <input name="username" type="text" id="username" size="18"></td>
    <td rowspan="2">
		  <input type="radio" name="userflag" value="超级管理员">&nbsp;超级管理员&nbsp;&nbsp;
      <input type="radio" name="userflag" value="编辑管理员" checked>&nbsp;编辑管理员
	</td>
    <td rowspan="2"><input type="submit" name="Submit" value=" 添 加 "></td>
  </tr>
  <tr align="center" bgcolor="#ff6666">
    <td height="30">密&nbsp;&nbsp;码：
      <input name="userpsd" type="password" id="userpsd" size="18"></td>
  </tr>
  </form>
</table>
</body>
</html>
