📄 userclass.asp
字号:
<%
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
Class UserManagerClass
Public ID '记录ID号
Public userid '用户号
Public username '用户名
Public userpwd '用户密码
Public readermanage '读者管理功能
Public bookmanage '书籍管理功能
Public usermanage '用户管理功能
Public userlimit '登陆限制
Public Actionconn '数据库连接
Public Keyword '关键字
'BookManagerClass的私有属性
Private action
Private idd
'构造函数
Private Sub Class_initialize
Reset()
End Sub
'解析函数
Private Sub Class_terminate
Reset()
ActionConn.close
Set ActionConn=Nothing
End Sub
'重置属性(初始化属性)
Public Sub Reset()
ID=0
userid=""
username=""
userpwd=""
readermanage=""
bookmanage=""
usermanage=""
userlimit=""
Keyword=""
action=Request.QueryString("action")
End Sub
'# ----------------------------------------------------------------------------
'# 函数:pagehtmlForm
'# 描述:显示表单页面
'# 参数: -
'# 返回:html代码
'#-----------------------------------------------------------------------------
Private Function PageHtmlForm()
%>
<div align="center"><form method="POST" action="?action=<%=action%>&id=<%=Id%>" name="myform">
<table border="0" width="300" id="table1" cellspacing="1">
<tr>
<td align="center" colspan="2" bgcolor="#006699">
<font color="#FFFFFF">用户信息<%if Request("action")="add" then
Response.write "添加"
else
Response.write "修改"
end if%></font></td>
</tr>
<tr>
<td align="right" width="105">用户帐号</td>
<td width="186">
<input type="text" name="userid" size="20" value="<%=userid%>"></td>
</tr>
<tr>
<td align="right" width="105">用户姓名</td>
<td width="186">
<input type="text" name="username" size="20" value="<%=username%>"></td>
</tr>
<tr>
<td align="right" width="105">用户密码</td>
<td width="186">
<input type="password" name="userpwd" size="20" value="<%=userpwd%>"></td>
</tr>
<tr>
<td align="right" width="105">读者管理功能</td>
<td width="186">
<input type="checkbox" name="readermanage" value="y" <%If InStr(LCase(readermanage),"y")<>0 Then Response.Write " checked" End If%>></td>
</tr>
<tr>
<td align="right" width="105">书籍管理功能</td>
<td width="186">
<input type="checkbox" name="bookmanage" value="y" <%If InStr(LCase(bookmanage),"y")<>0 Then Response.Write " checked" End If%>></td>
</tr>
<tr>
<td align="right" width="105">用户管理功能</td>
<td width="186">
<input type="checkbox" name="usermanage" value="y" <%If InStr(LCase(usermanage),"y")<>0 Then Response.Write " checked" End If%>></td>
</tr>
<tr>
<td align="right" width="105">登陆控制标志</td>
<td width="186">
<input type="checkbox" name="userlimit" value="y" <%If InStr(LCase(userlimit),"y")<>0 Then Response.Write " checked" End If%>>允许登陆</td>
</tr>
<tr>
<td width="291" colspan="2" align="right">
<input type="submit" value=
<%If action="add" Then
Response.Write "添加用户信息"
ElseIf action="modify" Then
Response.Write "修改用户信息"
End if
%> name="B3" class="FormText"><input type="button" value="返回列表" name="B2" onclick="location.href='?action=list';" class="FormText">
</td>
</tr>
</table></form>
</div>
<%
End Function
'# ----------------------------------------------------------------------------
'# 函数:PageHtmlList
'# 描述:用户信息列表页面
'# 参数: -
'# 返回:HTML
'#-----------------------------------------------------------------------------
Private Function PageHtmlList()
Dim sMathod,sKey,condition
sKey=Request("key")
sMathod=Request("fw")
select Case sMathod
Case "uid" condition=" where userid "
Case "uname" condition=" where username "
end select
if condition<>"" then
condition=condition+" like '%"&sKey&"%'"
end if
%>
<div align="center">
<form method="post" action="?action=list" name="ListForm">
<table width=98% style="border:0px" class="table" cellpadding=0 cellspacing=0>
<tr>
<td class="td" align=right>查询方式:
<select class="select" name="fw" size="1">
<option value="uid">用户号</option>
<option value="uname">用户姓名</option>
</select>
输入关键字:
<input type="text" name="key" class="text" value="">
<input type="submit" class="button" value="搜索">
</td>
</tr>
</table>
</form>
</div>
<form method="post" action="?action=delete" name="delForm">
<div align="center">
<table width=98% border=1 class="table" cellpadding=0 cellspacing=0>
<tr class="headtr">
<td class="td" height="23" align="center" width="100">用户号</td>
<td class="td" height="23" align="center" width="100">用户姓名</td>
<td class="td" height="23" align="center" width="100">读者管理</td>
<td class="td" height="23" align="center" width="100">书籍管理</td>
<td class="td" height="23" align="center" width="100">用户管理</td>
<td class="td" height="23" align="center" width="100">登陆限制</td>
<td class="td" height="23" align="center" width="100" >管理 <input type="submit" class="button" value="删除" name="b1"></td>
</tr>
<%
Dim Rs,Sql
Set Rs=Server.Createobject("Adodb.Recordset")
Sql="Select * From UserInfo "&condition&" order by userid"
Rs.Open Sql,Actionconn,3,2
Do While not Rs.eof
ID=Rs("ID")
userid=Rs("userid")
username=Rs("username")
readermanage=Rs("readermanage")
bookmanage=Rs("bookmanage")
usermanage=Rs("usermanage")
userlimit=Rs("userlimit")
%>
<tr>
<td class="lefttd" height="20" align="left"><FONT color=#ff9900>·</FONT><%=userid%></td>
<td class="lefttd" height="20" align="left"><%=username%></td>
<td class="lefttd" height="20" align="center"><%=readermanage%></td>
<td class="lefttd" height="20" align="center"><%=bookmanage%></td>
<td class="lefttd" height="20" align="center"><%=usermanage%></td>
<td class="lefttd" height="20" align="left"><%=userlimit%></td>
<td class="lefttd" height="20" align="center">
<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr>
<td class="td" align="center"><a title="" href="?action=modify&id=<%=ID%>">修改</a></td>
<td class="td" align="center"><input type="checkbox" class="checkbox" name="idd" value="<%=ID%>"></td>
</tr>
</table>
</td>
</tr>
<%
Rs.movenext
loop
Rs.Close
set Rs=nothing
%>
</table>
<BR>
</div>
</form>
<%
End Function
'# ----------------------------------------------------------------------------
'# 函数:RequestForm
'# 描述:取得传递信息
'# 参数: -
'# 返回:
'# 完成时间:2005-11-14
'#-----------------------------------------------------------------------------
Private Function RequestForm()
action=indb(Request.QueryString("action"))
'需要被删除的记录
idd=indb(Request.Form("idd"))
ID=indb(Request.QueryString("id"))
userid=indb(Request.Form("userid"))
username=indb(Request.Form("username"))
userpwd=indb(Request.Form("userpwd"))
readermanage=indb(Request.Form("readermanage"))
bookmanage=indb(Request.Form("bookmanage"))
usermanage=indb(Request.Form("usermanage"))
userlimit=indb(Request.Form("userlimit"))
End Function
'# ----------------------------------------------------------------------------
'# 函数:Addpage
'# 描述:添加用户信息页面
'# 参数: -
'# 返回:
'# 日期:2005-11-14
'#-----------------------------------------------------------------------------
Public Function AddPage()
If LCase(Request.ServerVariables("request_method"))="post" Then
RequestForm()
pagination()
Else
PageHtmlForm()
End If
End Function
'# ----------------------------------------------------------------------------
'# 函数:Pagination
'# 描述:内容分页的实现--->添加书籍信息
'# 参数: -
'# 返回:
'# 日期:2005-11-14
'#-----------------------------------------------------------------------------
Private Function Pagination()
Add()
If Err Then
Call Go2_Error("书籍信息添加失败")
Else
Call Go_Success("书籍信息添加成功","?action=list")
End If
End Function
'# ----------------------------------------------------------------------------
'# 函数:Modifypage
'# 描述:修改用户信息页面
'# 参数: -
'# 返回:
'# 日期:2005-11-14
'#-----------------------------------------------------------------------------
Public Function ModifyPage()
RequestForm()
If ID="" Then
Response.Write "错误的参数"
exit function
End If
If LCase(Request.ServerVariables("request_method"))="post" Then
RequestForm()
Modify()
Else
GetUser(ID)
PageHtmlForm()
End If
End Function
'# ----------------------------------------------------------------------------
'# 函数:listpage
'# 描述:书籍列表页面
'# 参数: -
'# 返回:
'# 日期:2005-11-14
'#-----------------------------------------------------------------------------
Public Function ListPage()
PageHtmlList()
End Function
'# ----------------------------------------------------------------------------
'# 函数:Deletepage
'# 描述:删除书籍信息页面
'# 参数: -
'# 返回:
'# 日期:2005-11-14
'#-----------------------------------------------------------------------------
Public Function DeletePage()
If LCase(Request.ServerVariables("request_method"))="post" Then
RequestForm()
Delete()
Else
PageHtmlList()
End If
End Function
'# ----------------------------------------------------------------------------
'# 函数:Delete
'# 描述:删除用户
'# 参数: -
'# 返回:
'# 日期:2005-11-14
'#-----------------------------------------------------------------------------
Private Function Delete()
Dim Sql
If ID<>"" Then
Sql="Delete From UserInfo Where Id="&ID
Else
Sql="Delete From UserInfo where Id in ("&idd&")"
End If
Actionconn.Execute(Sql)
If Err Then
Call Go2_Error("书籍删除失败")
Else
Call Go_Success("书籍删除成功","?action=list")
End If
End Function
'# ----------------------------------------------------------------------------
'# 函数:add
'# 描述:添加用户信息
'# 参数: -
'# 返回:
'# 日期:2005-11-14
'#-----------------------------------------------------------------------------
Private Function Add()
if Trim(ID)="" then
Go2_Error("书籍号不能为空!")
End If
sSql="insert into UserInfo (userid,username,userpwd,readermanage,bookmanage,usermanage,userlimit) Values "&_
"('"&userid&"','"&username&"','"&userpwd&"','"&readermanage&"','"&bookmanage&"','"&usermanage&"','"&userlimit&"')"
Actionconn.Execute sSql
End Function
'# ----------------------------------------------------------------------------
'# 函数:Modify
'# 描述:修改用户信息内容
'# 参数: -
'# 返回:
'# 日期:2005-11-14
'#-----------------------------------------------------------------------------
Private Function Modify()
if Trim(ID)="" then
Go2_Error("用户信息不能为空!")
End If
Dim Rs,Sql
Set Rs=Server.Createobject("Adodb.Recordset")
Sql="Select * From UserInfo Where ID="&ID
Rs.Open Sql,Actionconn,3,2
Rs("userid")=userid
Rs("username")=username
Rs("userpwd")=userpwd
Rs("readermanage")=readermanage
Rs("bookmanage")=bookmanage
Rs("usermanage")=usermanage
Rs("userlimit")=userlimit
Rs.Update
Rs.Close
Set Rs=Nothing
If Err Then
Call Go_Error("用户信息修改失败")
Else
Call Go_Success("用户信息修改成功","?action=list")
End If
End Function
'# ----------------------------------------------------------------------------
'# 函数:GetReader
'# 描述:取得单个用户的属性
'# 参数: -
'# 返回:
'# 日期:2005-11-14
'#-----------------------------------------------------------------------------
Public Function GetUser(Gid)
Dim Rs
Set Rs=Actionconn.Execute("Select * From UserInfo Where UserID='"&Gid&"'")
if Not (Rs.eof and Rs.bof) then
userid=Rs("userid")
username=Rs("username")
userpwd=Rs("userpwd")
readermanage=Rs("readermanage")
bookmanage=Rs("bookmanage")
usermanage=Rs("usermanage")
userlimit=Rs("userlimit")
end if
Rs.Close
Set Rs=Nothing
End Function
End Class
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -