📄 readerclass.asp
字号:
<%
Class ReaderManagerClass
Public ID '记录ID号
Public readerid '读者ID号
Public readername '读者姓名
Public sex '读者性别
Public ReaderDep '读者单位
Public ReaderType '读者类型
Public Actionconn '数据库连接
Public Keyword '关键字
'ReaderManagerClass的私有属性
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
readerid=""
readername=""
ReaderDep=""
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 colspan="2" bgcolor="#006699">
<p align="center"><font color="#FFFFFF">读者信息<%if Request("action")="add" then
Response.write "添加"
else
Response.write "修改"
end if%></font></td>
</tr>
<tr>
<td width="129">
<p align="right">读者号</td>
<td>
<input type="text" name="readerid" size="20" value="<%=readerid%>"></td>
</tr>
<tr>
<td width="129">
<p align="right">读者姓名</td>
<td>
<input type="text" name="readername" size="20" value="<%=readername%>"></td>
</tr>
<tr>
<td width="129">
<p align="right">性别</td>
<td><select size="1" name="sex" class="FormText"><%SetSelected(0)%></select></td>
</tr>
<tr>
<td width="129">
<p align="right">读者单位</td>
<td>
<input type="text" name="readerdep" size="20" value="<%=readerdep%>"></td>
</tr>
<tr>
<td width="129">
<p align="right">读者类型</td>
<td><select size="1" name="readertype" class="FormText"><%SetSelected(1)%></select></td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value=
<%If action="add" Then
Response.Write "添加读者信息"
ElseIf action="modify" Then
Response.Write "修改读者信息"
End if
%> name="btnsave" class="FormText"> <input type="button" name="btncancel" value="返回列表" onclick="location.href='?action=list';" class="FormText"> </td>
</tr>
</table></form>
</div>
<%
End Function
'# ----------------------------------------------------------------------------
'# 函数:SetSelected
'# 描述:读者性别、读者类型获取函数
'# 参数: -
'# 返回:HTML
'#-----------------------------------------------------------------------------
Private Function SetSelected(op)
if op=0 then
select case sex
case "男" %>
<option value="男" selected>男</option>
<option value="女">女</option>
<%case "女"%>
<option value="男" >男</option>
<option value="女" selected>女</option>
<%end select
end if
if op=1 then
'获取读者类型
Dim Rs,Sql
Set Rs=Server.Createobject("Adodb.Recordset")
Sql="Select ReaderTypeName From ReadertypeInfo"
Rs.Open Sql,Actionconn,3,2
do while not Rs.eof %>
<option value="<%=Rs("ReaderTypeName")%>" <%if ReaderType=Rs("ReaderTypeName") then %>selected<%end if%>><%=Rs("ReaderTypeName")%></option>
<%Rs.movenext
loop
Rs.Close
set Rs=nothing
end if
End Function
'# ----------------------------------------------------------------------------
'# 函数:PageHtmlList
'# 描述:读者信息列表页面
'# 参数: -
'# 返回:HTML
'#-----------------------------------------------------------------------------
Private Function PageHtmlList()
Dim sMathod,sKey,condition
sKey=Request("key")
sMathod=Request("fw")
select Case sMathod
Case "rid" condition=" where ReaderID "
Case "rname" condition=" where ReaderName "
Case "rdep" condition=" where ReaderDep "
Case "rtype" condition=" where ReaderType "
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="rid">读者号</option>
<option value="rname">读者姓名</option>
<option value="rdep">读者单位</option>
<option value="rtype">读者类别</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="80">读者号</td>
<td class="td" height="23" align="center" width="100">读者姓名</td>
<td class="td" height="23" align="center" width="60">性别</td>
<td class="td" height="23" align="center" width="250">读者单位</td>
<td class="td" height="23" align="center" width="80">读者类别</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 ReaderInfo "&condition&" order by ReaderID"
Rs.Open Sql,Actionconn,3,2
Do While not Rs.eof
ID=Rs("ID")
readerid=Rs("ReaderID")
readername=Rs("ReaderName")
sex=Rs("ReaderSex")
readerdep=Rs("ReaderDep")
readertype=Rs("ReaderType")
%>
<tr>
<td class="lefttd" height="20" align="left"><FONT color=#ff9900>·</FONT><%=readerid%></td>
<td class="lefttd" height="20" align="left"><%=Readername%></td>
<td class="lefttd" height="20" align="center"><%=sex%></td>
<td class="lefttd" height="20" align="left"><%=readerdep%></td>
<td class="lefttd" height="20" align="left"><%=readertype%></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"))
readerid=indb(Request.Form("readerid"))
readername=indb(Request.Form("readername"))
sex=indb(Request.Form("sex"))
readerdep=indb(Request.Form("readerdep"))
readertype=indb(Request.Form("readertype"))
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
GetReader(ID)
PageHtmlForm()
End If
End Function
'# ----------------------------------------------------------------------------
'# 函数:listpage
'# 描述:读者列表页面
'# 参数: -
'# 返回:
'# 日期:2005-11-14
'#-----------------------------------------------------------------------------
Public Function ListPage()
PageHtmlList()
End Function
'# ----------------------------------------------------------------------------
'# 函数:setpage
'# 描述:新闻列表页面
'# 参数: -
'# 返回:
'# 作者:Jay
'# 日期:2004-8-30
'#-----------------------------------------------------------------------------
Public Function SetPage()
Dim op
requestform()
op=Request.QueryString("op")
If op="" Or Id="" Or action="" Then
Response.Write "错误的参数"
exit function
End If
SetAttribute Id,op
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 ReaderInfo Where Id="&ID
Else
Sql="Delete From ReaderInfo 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 ReaderInfo (ReaderID,ReaderName,ReaderSex,ReaderDep,ReaderType) Values "&_
"('"&readerid&"','"&readername&"','"&Sex&"','"&ReaderDep&"','"&ReaderType&"')"
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 ReaderInfo Where ID="&ID
Rs.Open Sql,Actionconn,3,2
Rs("ReaderID")=readerid
Rs("ReaderName")=readername
Rs("ReaderSex")=sex
Rs("ReaderDep")=readerdep
Rs("ReaderType")=readertype
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 GetReader(Gid)
Dim Rs
Set Rs=Actionconn.Execute("Select * From ReaderInfo Where ID='"&Gid&"'")
if Not (Rs.eof and Rs.bof) then
ReaderId=Rs("ReaderId")
ReaderName=Rs("ReaderName")
sex=Rs("ReaderSex")
readerdep=Rs("ReaderDep")
readertype=Rs("ReaderType")
end if
Rs.Close
Set Rs=Nothing
End Function
End Class
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -