?? userclass.asp
字號:
<%
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 + -