<%
IF (Session("REGISTER")="REGISTED" ) THEN
IF (session("purview")="9999" ) THEN
%>
<%
userid=request("userid")
isedit=false
if request("action")="edit" then
isedit=true
end if
%>
<%
if request("action")="modify" then '*****************修改用户*****************
if trim(request("userpassword"))="" then
response.write "错误!密码不能为空!
返回"
response.end
end if
sql="update admin set username='" & cstr(trim(request("username"))) & "',password='" & cstr(trim(request("userpassword"))) & "',purview=" & cstr(request("purview")) & "where userid=" & cstr(request("userid"))
conn.execute sql
if err.number <> 0 then
response.write "数据库操作出错:" + err.description
else %>
<%end if
end if
%>
<%
if request("action")="add" then '*******************添加新用户****************
if trim(request("username"))="" or trim(request("userpassword"))="" then
response.write "错误!用户名或密码不能为空!
返回"
response.end
end if
set rs=server.createobject("adodb.recordset") '检查用户是否重名
rs.open "select * from admin where username='" & cstr(trim(request("username"))) & "'",conn,1,1
if err.number <> 0 then
response.write "数据库出错"
else if not rs.bof and not rs.eof then
response.write "错误!该用户名已存在!
返回"
response.end
end if
end if
rs.close
set rs=nothing
sql="insert into admin(username,password,purview) values('" & cstr(trim(request("username"))) & "','" & cstr(trim(request("userpassword"))) & "'," & cstr(request("purview")) & ")"
conn.execute sql
if err.number <> 0 then
response.write "数据库操作出错:" + err.description
else %>
<%end if
end if %>
<%
if request("action")="del" then '*******************删除用户******************
sql="delete from admin where userid=" + cstr(userid)
conn.execute sql
if err.number <> 0 then
response.write "数据库操作错误:" + err.description
err.clear
else %>
<% end if
end if
%>
用户管理
-----用 户 名----- |
-----权 限----- |
操作 |
<%
set rs=server.createobject("adodb.recordset")
rs.open "select * from admin",conn,1,1
if err.number <> 0 then
response.write "数据库出错"
else
if rs.bof and rs.eof then
rs.close
response.write "目前没有用户"
else
do while not rs.eof %>
|
<% if rs("purview")="9999" then response.write "系统管理员" else set rsc=server.createobject("adodb.recordset") rsc.open "select typename from type where typeid=" & rs("purview"),conn,1,1 if err.number <> 0 then response.write "数据库出错" else if rsc.bof and rsc.eof then response.write "无效用户" else response.write rsc("typename")&"管理员" end if end if rsc.close set rsc=nothing end if %> |
|
<% rs.movenext
loop
end if
end if
rs.close
set rs=nothing %>
<% if isedit then %>
编 辑 用 户
<% set rs=server.createobject("adodb.recordset")
set rsc=server.createobject("adodb.recordset")
rs.open "select * from admin where userid=" & cstr(request("userid")),conn,1,1
rsc.open "select * from type where typeid=" & cstr(rs("purview")),conn,1,1
%>
<% else %>
添 加 新 用 户 <% end if %>
<%
else
response.redirect "usermanage.asp"
response.end
END IF
else
response.redirect "login.asp"
response.end
end if
%>