usermanage.asp
来自「东滕网站源码」· ASP 代码 · 共 282 行
ASP
282 行
<% option explicit %>
<!--#include file="../function1/DBOpen.asp"-->
<%
if session("purview")<>"99999" then
response.write "错误!!您没有权限或者连接超时,请重新登陆." %>
<a href="../login.asp" target="_top">登陆</a>
<% response.end
end if
dim isedit '是否在编辑状态
dim color '表格颜色
dim userid
dim sql,rs,rsc
userid=request("userid")
color=1
isedit=false
if request("action")="edit" then
isedit=true
end if
if request("action")="modify" then '*****************修改用户*****************
if trim(request("userpassword"))="" then
response.write "错误!密码不能为空! <a href=usermanage.asp>返回</a>"
response.end
end if
sql="update users set name='" & cstr(trim(request("username"))) & "',pwd='" & 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 %>
<script language=vbscript>
msgbox "操作成功!用户 <%=trim(request("username"))%> 的信息已经更新!"
</script>
<%end if
end if
if request("action")="add" then '*******************添加新用户****************
if trim(request("username"))="" or trim(request("userpassword"))="" then
response.write "错误!用户名或密码不能为空! <a href=# onclick='javascript:window.history.go(-1)'>返回</a>"
response.end
end if
set rs=server.createobject("adodb.recordset") '检查用户是否重名
rs.open "select * from users where name='" & 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 "错误!该用户名已存在! <a href=# onclick='javascript:window.history.go(-1)'>返回</a>"
response.end
end if
end if
rs.close
set rs=nothing
sql="insert into users(name,pwd,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 %>
<script language=vbscript>
msgbox "操作成功!新用户 <%=trim(request("username"))%> 的信息添加成功!"
</script>
<%end if
end if
if request("action")="del" then '*******************删除用户******************
sql="delete from users where userid=" + cstr(userid)
conn.execute sql
if err.number <> 0 then
response.write "数据库操作错误:" + err.description
err.clear
else %>
<script language=vbscript>
msgbox "操作成功!用户 <%=trim(request("username"))%> 的信息已删除!"
</script>
<% end if
end if
%><html>
<head>
<title>用户管理</title>
<script language=javascript>
function SureDel(id)
{
if ( confirm("您确定要删除该用户吗?"))
{
window.location.href = "usermanage.asp?action=del&userid=" + id
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<STYLE>TABLE {FONT-SIZE: 12px;COLOR: #000000; FONT-FAMILY: 宋体;LINE-HEIGHT: 180%}
.Shadow_white {FONT-SIZE: 14pt; FILTER: dropshadow(color:black, offx=1, offy=1, positive=1); WIDTH: 70%; COLOR: #000000; FONT-FAMILY: 宋体; POSITION: relative}
.Shadow_white2 {FONT-SIZE: 10pt; FILTER: dropshadow(color:black, offx=1, offy=1, positive=1); WIDTH: 70%; COLOR: #000000; FONT-FAMILY: 宋体; POSITION: relative}
A:link {COLOR: #000000; TEXT-DECORATION: none}
A:active {COLOR: #000000; TEXT-DECORATION: none}
A:visited {COLOR: #000000; TEXT-DECORATION: none}
A:hover {COLOR: #ff0000; TEXT-DECORATION: underline}
</STYLE></head>
<body>
<table border="0" width="70%" bgcolor="#000000" cellpadding="0" cellspacing="1" align="center">
<tr bgcolor="#abb8d6">
<td colspan="3" height="50">
<div align="center"></div>
<div align="center"></div>
<div align="center"><b>用户管理</b></div>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="32%">
<div align="center">-----用 户 名-----</div>
</td>
<td width="58%">
<div align="center">-----权 限-----</div>
</td>
<td width="10%">
<div align="center">操作</div>
</td>
</tr>
<%
set rs=server.createobject("adodb.recordset")
rs.open "select * from users where userid<>1",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 %>
<tr>
<td width="32%" height="21" bgcolor="<% if color mod 2=0 then
response.write "#F0E8F0"
else
response.write "#ffffff"
end if %>">
<div align="center"><a href='usermanage.asp?userid=<%=cstr(rs("userid"))%>&action=edit'><%=rs("name")%></a></div>
</td>
<td width="58%" height="21" bgcolor="<% if color mod 2=0 then
response.write "#F0E8F0"
else
response.write "#ffffff"
end if %>">
<div align="center">
<% if rs("purview")="99999" then
response.write "<b>管理员</b>"
else if rs("purview")="99998" then
response.write "<b>审核员</b>"
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 "<font color=#990099>无效用户</font>"
else
response.write rsc("typename")&"录入员"
end if
end if
rsc.close
set rsc=nothing
end if
end if %>
</div>
</td>
<td width="10%" height="21" bgcolor="<% if color mod 2=0 then
response.write "#F0E8F0"
else
response.write "#ffffff"
end if %>">
<div align="center">
<% if trim(rs("name"))=trim(session("name")) then
response.write "----"
else
response.write "<a href='javascript:SureDel(" & cstr(rs("userid")) & ")'>删除</a>"
end if %>
</div>
</td>
</tr>
<% rs.movenext
color=color+1
loop
end if
end if
'rs.close
set rs=nothing %>
</table>
<table width="70%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#abb8d6" style="border: 1px solid #000000">
<tr>
<td height="40">
<div align="center">
<% if isedit then
set rs=server.createobject("adodb.recordset")
set rsc=server.createobject("adodb.recordset")
rs.open "select * from users where userid=" & cstr(request("userid")),conn,1,1
rsc.open "select * from type where typeid=" & cstr(rs("purview")),conn,1,1
response.write "编 辑 用 户<br>"
else
response.write "添 加 新 用 户<br>"
end if %>
</div>
</td>
</tr>
<tr>
<td>
<form action="usermanage.asp" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="40">
<div align="center">
<input type="Hidden" name="action" value='<% If isedit then%>modify<% Else %>add<% End If %>'>
<%If isedit then%>
<input type="Hidden" name="userid" value='<%=cstr(request("userid"))%>'>
<%End If%>
用户账号:
<input type="text" name="username" class=input maxlength=14 size="16" value='<% if isedit then
response.write trim(rs("name"))
end if %>'
<% if isedit then
response.write " readonly"
end if %>>
用户密码:
<input type="password" name="userpassword" class=input maxlength=12 size="16" value='<% if isedit then
response.write trim(rs("pwd"))
end if %>'>
</div>
</td>
</tr>
<tr>
<td height="40">
<div align="center">用户权限:
<select name="purview" class=select>
<% if isedit then %>
<option value="99999" <% if rs("purview")="99999" then
response.write "selected"
end if %>> 管 理 员</option>
<option value="99998" <% if rs("purview")="99998" then
response.write "selected"
end if %>> 审 核 员</option>
<% if not rsc.bof and not rsc.eof then %>
<option value='<%=rsc("typeid")%>' selected ><%=rsc("typename")%>录入员</option>
<% end if
rsc.close
set rsc=nothing
set rsc=server.createobject("adodb.recordset")
rsc.open "select * from type where typeid<>" & cstr(rs("purview")),conn,1,1
if not rsc.bof and not rsc.eof then
do while not rsc.eof %>
<option value='<%=rsc("typeid")%>'><%=rsc("typename")%>录入员</option>
<% rsc.movenext
loop
end if
rsc.close
set rsc=nothing
rs.close
set rs=nothing
else
set rsc=server.createobject("adodb.recordset")
rsc.open "select * from type",conn,1,1 %>
<option value="99998"> 审 核 员</option>
<option value="99999"> 管 理 员</option>
<% if not rsc.eof and not rsc.bof then
do while not rsc.eof %>
<option value='<%=rsc("typeid")%>'><%=rsc("typename")%>录入员</option>
<% rsc.movenext
loop
end if
rsc.close
set rsc=nothing
end if %>
</select>
<input type=submit value="确 定" class=button name="submit">
<input type="reset" name="Submit" value="重 设">
</div>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<p align="center"> </p>
<p> </p>
</body>
</html>
<!--#include file="../function/DBclose.asp"-->
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?