<%Option Explicit '/************************************************ '* * '* Name : Asp pagnation class * '* Author : Sunway * '* Version : V2.0 * '* Time : 2003-12-26 * '* Email : sunway8110@126.com * '* HomePage: None (Maybe Soon) * '* Notice : You can use and modify it freely, * '* BUT PLEASE HOLD THIS ITEM. * '* If you modify it that i hope you * '* can send a mail for me. * '* * '************************************************/
'#########声明变量######### 'SWStyle Class Private SW_strBTNClass,SW_strTXTClass,SW_strBGColor,SW_intTBWidth,SW_intBDKind,SW_strBGImage,SW_strFTColor,SW_strBDColor,SW_strShowWidth '#########初始化变量########## SW_strFTColor = "#000000" 'Font color SW_strBGColor = "#FFFFFF" 'Background color SW_intBDKind = 1 'Default border kind is "thin border". SW_intTBWidth = "98%" 'Table's width. SW_strBDColor = "#000000" 'Table's border color.
'SWPage Class Private SW_blnErrorFlag,SW_blnIsHaveRS,SW_strFields '#########初始化变量########## SW_blnErrorFlag = false '设置错误标志为Fasle,就是无错误状态 SW_blnIsHaveRS = false '设置记录集获取标志为Fasle,就是无记录集状态 SW_strShowWidth = "90%" SW_strFields = ""
'定义链接的显示类型 Const SW_intShowChinese = 0 '汉字,如"上一页、下一页" Const SW_intShowEnglish = 1 '英文,如"Back、Next" Const SW_intShowCharacter = 2 '特殊字符 ' Const SW_intShowImage = 3 '图片 '定义数据的显示类型 Const SW_intHorizontalView = 0 '横排 Const SW_intVerticalView = 1 '竖排 '线的显示类型 Const SW_intShowBigBorder = 2 '粗线 Const SW_intShowSmallBorder = 1 '细线 Const SW_intShowNoBorder = 0 '无线
'显示的页数 Const SW_intShowPages = 10
'***************************************** ' 类型: 类 ' 目的: 控制分页信息显示的样式 '***************************************** Class SWStyle '***************************************** ' 类型: 属性 ' 目的: 设定背景颜色 ' 输入: a_strBGColor: 背景颜色。 ' 返回: 无 '***************************************** Public Property Let BGColor(a_strBGColor) SW_strBGColor = a_strBGColor End Property
'***************************************** ' 类型: 属性 ' 目的: 设定背景图像 ' 输入: a_strBGImage: 背景图像 ' 返回: 无 '***************************************** Public Property Let BGImage(a_strBGImage) SW_strBGImage = a_strBGImage End Property
'***************************************** ' 类型: 属性 ' 目的: 设定表格中字体的颜色 ' 输入: a_strFTColor: 字体的颜色 ' 返回: 无 '***************************************** Public Property Let FTColor(a_strFTColor) SW_strFTColor = a_strFTColor End Property
'***************************************** ' 类型: 属性 ' 目的: 设定表格线的颜色 ' 输入: a_strBDColor: 格线的颜色 ' 返回: 无 '***************************************** Public Property Let BDColor(a_strBDColor) SW_strBDColor = a_strBDColor End Property
'***************************************** ' 类型: 属性 ' 目的: 设定表格线的类型 ' 输入: a_intBDKind: 格线的类型 ' 0: 没线 ' 1: 细线 ' 2: 粗线 ' 返回: 无 '***************************************** Public Property Let BDKind(a_intBDKind) SW_intBDKind = a_intBDKind End Property
'***************************************** ' 类型: 属性 ' 目的: 设定表格宽度 ' 输入: a_intTBWidth: 表格的宽度 ' 返回: 无 '***************************************** Public Property Let TBWidth(a_intTBWidth) SW_intTBWidth = a_intTBWidth End Property
'***************************************** ' 类型: 属性 ' 目的: 设定按钮的样式 ' 输入: a_strBNStyle: CSS样式代码 ' 返回: 无 '***************************************** Public Property Let BTNClass(a_strBTNClass) SW_strBTNClass = a_strBTNClass End Property
'***************************************** ' 类型: 属性 ' 目的: 设定文本框的样式 ' 输入: a_strTXTStyle: CSS样式代码 ' 返回: 无 '***************************************** Public Property Let TXTClass(a_strTXTClass) SW_strTXTClass = a_strTXTClass End Property End Class
'***************************************** ' 类型: 类 ' 目的: 给记录集分页 '***************************************** Class SWPage '声明类私有变量 Private SW_objRS,SW_objConn
Private SW_strSQL,SW_strURL,SW_strError,SW_strFormAction,SW_strCSSFile Private SW_strTleBGColor,SW_strTleFTColor,SW_strTleWidth
Private SW_intPageSize Private SW_lngTotalPage,SW_lngTotalRecord,SW_lngPageNo,SW_lngShowType,SW_lngShowPageType Private SW_aryFldName,SW_aryFldNote,SW_aryFldWidth,SW_aryFldAlign Private SW_blnInit,SW_blnGetData,SW_blnGetConn,SW_blnPageSize,SW_blnFieldName,SW_blnGetURL,SW_blnShowType,SW_blnShowPageType
'***************************************** ' 类型: 属性 ' 目的: 设定或显示每页的记录数。 ' 输入: a_intPageSize: 每页显示的记录数。 ' 返回: 每页显示的记录数。 '***************************************** Public Property Let PageSize(a_intPageSize) Dim strError
'PageSize获取失败标志 SW_blnPageSize = false If Trim(a_intPageSize) = "" OR (Not(IsNumeric(a_intPageSize))) Then strError = strError & "<br>非法的pagesize" Else If (a_intPageSize <= 2147483647 And a_intPageSize>=-2147483648) Then SW_intPageSize = CLng(a_intPageSize) Else strError = strError & "<br>PageSize溢出" End If If (SW_intPageSize<=0) Then strError = strError & "<br>PageSize只能是正整数" End If End If If Trim(strError)="" Then SW_blnPageSize = True Else SW_strError = SW_strError & " <tr bgcolor=""#336699"" height=""28""><td><font color=""#FFFFFF"">PageSize属性:</font></td></tr>" & vbcrlf SW_strError = SW_strError & " <tr bgcolor=""#ffffff""><td>" & strError & "</td></tr>" & vbcrlf End If End Property
'***************************************** ' 类型: 属性 ' 目的: 设定或显示SQL语句。 ' 输入: a_strSQL: SQL语句。 ' 返回: SQL语句。 '***************************************** Public Property Let SQL(a_strSQL) Dim strError
SW_blnGetData = false SW_strSQL = a_strSQL If SW_blnIsHaveRS = false Then '创建RecordSet对象 Set SW_objRS = CreateObject("adodb.RecordSet") On Error Resume Next SW_objRS.Open SW_strSQL,SW_objConn,1,1 If Err.Number <> 0 Then strError = "<br>记录集打开失败" On Error Goto 0 End If End If If Trim(strError)="" Then SW_blnGetData = true Else SW_strError = SW_strError & " <tr bgcolor=""#336699"" height=""28""><td><font color=""#FFFFFF"">SQL属性:</font></td></tr>" & vbcrlf SW_strError = SW_strError & " <tr bgcolor=""#ffffff""><td>" & strError & "</td></tr>" & vbcrlf End If End Property '***************************************** ' 类型: 属性 ' 目的: 设定css。 ' 输入: a_strCSSFilePath: 分页文件的样式文件。 ' 返回: 无。 '***************************************** Public Property Let CSSFile(a_strCSSFilePath) SW_strCSSFile = "<link rel=""stylesheet"" href=""" & a_strCSSFilePath & """ type=""text/css"">" End Property
'***************************************** ' 类型: 属性 ' 目的: 设定或显示URL。 ' 输入: a_strURL: 需要分页的文件地址。 ' 返回: 需要分页的文件地址。 '***************************************** Public Property Let URL(a_strURL) Dim strError,objFSO
SW_blnGetURL = false If Trim(a_strURL)="" Then strError = "<br>非法的URL地址" Else Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FileExists(Server.Mappath(a_strURL)) Then SW_strURL = a_strURL Else strError = strError & "<br>你能确定文件 <font color=""#ff0000"">" & a_strURL & "</font> 存在么?" End If Set objFSO = Nothing End If If strError = "" Then SW_blnGetURL = true Else SW_strError = SW_strError & " <tr bgcolor=""#336699"" height=""28""><td><font color=""#FFFFFF"">URL属性:</font></td></tr>" & vbcrlf SW_strError = SW_strError & " <tr bgcolor=""#ffffff""><td>" & strError & "</td></tr>" & vbcrlf End If End Property
'***************************************** ' 类型: 属性 ' 目的: 获取显示的方式 ' 输入: a_intType:显示方式如:1、2 ' 返回: 无 '***************************************** Public Property Let ShowPageType(a_intType) Dim strError
SW_blnShowPageType = false If Trim(a_intType) <> "" And IsNumeric(a_intType) Then If (a_intType <= 2147483647 And a_intType>=-2147483648) Then SW_lngShowPageType = CLng(a_intType) Else strError = "<br>显示类型参数溢出" End If Else SW_lngShowPageType = SW_intHorizontalView End IF If Trim(strError) = "" Then SW_blnShowPageType = true Else SW_strError = SW_strError & " <tr bgcolor=""#336699"" height=""28""><td><font color=""#FFFFFF"">ShowPageType属性:</font></td></tr>" & vbcrlf SW_strError = SW_strError & " <tr bgcolor=""#ffffff""><td>" & strError & "</td></tr>" & vbcrlf End If End Property
'***************************************** ' 类型: 属性 ' 目的: 获取显示的方式 ' 输入: a_intType:显示方式如:1、2 ' 返回: 无 '***************************************** Public Property Let ShowType(a_intType) Dim strError
SW_blnShowType = false If Trim(a_intType) <> "" And IsNumeric(a_intType) Then If (a_intType <= 2147483647 And a_intType>=-2147483648) Then SW_lngShowType = CLng(a_intType) Else strError = "<br>显示类型参数溢出" End If Else SW_lngShowType = SW_intShowChinese End IF If Trim(strError)="" Then SW_blnShowType = true Else SW_strError = SW_strError & " <tr bgcolor=""#336699"" height=""28""><td><font color=""#FFFFFF"">ShowType属性:</font></td></tr>" & vbcrlf SW_strError = SW_strError & " <tr bgcolor=""#ffffff""><td>" & strError & "</td></tr>" & vbcrlf End If End Property
'***************************************** ' 类型: 属性 ' 目的: 获取数据连接 ' 输入: a_objConn:已创建的Connection对象 ' 返回: 无 '***************************************** Public Property Let GetConn(a_objConn) Const adStateOpen = 1 Dim intReturn,strError SW_blnGetConn = false
If IsObject(a_objConn) Then If Not IsObject(SW_objConn) Then On Error Resume Next intReturn =a_objConn.State If err.Number<>0 Then strError = strError & "<br>试图创建非法的Connection对象" On Error Goto 0 Else On Error Goto 0 If Not (intReturn = adStateOpen) Then strError = strError & "<br>Connection对象打开失败" End If End If Set SW_objConn = a_objConn Else strError = strError & "<br>创建Connection对象失败" End If Else strError = strError & "<br>试图创建非法的Connection对象" End If If Trim(strError)="" Then SW_blnGetConn = true Else SW_strError = SW_strError & " <tr bgcolor=""#336699"" height=""28""><td><font color=""#FFFFFF"">GetConn属性:</font></td></tr>" & vbcrlf SW_strError = SW_strError & " <tr bgcolor=""#ffffff""><td>" & strError & "</td></tr>" & vbcrlf End If End Property
'***************************************** ' 类型: 属性 ' 目的: 设置需要显示的数据的字段名 ' 输入: a_strFldName:字段名字符串,多个字段之间以逗号分隔 ' 返回: 无 '***************************************** Public Property Let FldName(a_strFldName) Dim strError
SW_blnFieldName = false If Trim(a_strFldName) <> "" Then SW_aryFldName = Split(a_strFldName,",") Else strError = strError & "<br>你必须设置<font color=""#ff0000"">FldName</font>属性,否则无法显示数据" End If If Trim(strError)="" Then SW_blnFieldName = true Else SW_strError = SW_strError & " <tr bgcolor=""#336699"" height=""28""><td><font color=""#FFFFFF"">FldName属性:</font></td></tr>" & vbcrlf SW_strError = SW_strError & " <tr bgcolor=""#ffffff""><td>" & strError & "</td></tr>" & vbcrlf End If End Property
'***************************************** ' 类型: 属性 ' 目的: 设置显示某些字段的中文说明 ' 输入: a_strFldNote:字段中文说明字符串,多个字段之间以逗号分隔 ' 返回: 无 '***************************************** Public Property Let fldNote(a_strFldNote) If Trim(a_strFldNote) <> "" Then SW_aryFldNote = Split(a_strFldNote,",") End If End Property
'***************************************** ' 类型: 属性 ' 目的: 设置显示某些字段数据时单元格的宽度 ' 输入: a_strFldWidth:单元格宽度字符串,多个字段之间以逗号分隔 ' 返回: 无 '***************************************** Public Property Let fldWidth(a_strFldWidth) If Trim(a_strFldWidth) <> "" Then SW_aryFldWidth = Split(a_strFldWidth,",") End If End Property
'***************************************** ' 类型: 属性 ' 目的: 设置显示某些字段数据时在单元格中的对齐方式 ' 输入: a_strFldAligbn:对齐方式字符串,多个字段之间以逗号分隔 ' 返回: 无 '***************************************** Public Property Let fldAlign(a_strFldAlign) If Trim(a_strFldAlign) <> "" Then SW_aryFldAlign = Split(a_strFldAlign,",") End If End Property
'***************************************** ' 类型: 属性 ' 目的: 设置表格标题栏的背景颜色 ' 输入: a_strTleColor:颜色参数,如#FFFFFF ' 返回: 无 '***************************************** Public Property Let TleBGColor(a_strTleBGColor) SW_strTleBGColor = a_strTleBGColor End Property
'***************************************** ' 类型: 属性 ' 目的: 设置表格标题栏中文字的颜色 ' 输入: a_strTleColor:颜色参数,如#FFFFFF ' 返回: 无 '***************************************** Public Property Let TleFTColor(a_strTleFTColor) SW_strTleFTColor = a_strTleFTColor End Property
'***************************************** ' 类型: 属性 ' 目的: 设置显示标题时单元格的宽度 ' 输入: a_strTleWidth:单元格宽度字符串 ' 返回: 无 '***************************************** Public Property Let TleWidth(a_strTleWidth) SW_strTleWidth = a_strTleWidth End Property
'***************************************** ' 类型: 属性 ' 目的: 设置显示标题时单元格的宽度 ' 输入: a_strTleWidth:单元格宽度字符串 ' 返回: 无 '***************************************** Public Property Let ShowWidth(a_strShowWidth) SW_strShowWidth = a_strShowWidth End Property
'***************************************** ' 类型: 过程 ' 目的: 获取数据记录集 ' 输入: a_objRS:已创建的RecordSet对象 ' 返回: 无 '***************************************** Public Property Let GetRS(a_objRS) Dim intTemp,strError
SW_blnGetData = false If IsObject(a_objRS) Then If Not IsObject(SW_objRS) Then Set SW_objRS = a_objRS On Error Resume Next intTemp = SW_objRS.LockType If err.Number <> 0 Then strError = strError & "<br>试图创建非法的RecordSet对象" On Error Goto 0 Else SW_blnIsHaveRS = true On Error Goto 0 End If End If Else strError = strError & "<br>试图创建Connection对象失败" End If If Trim(strError)="" Then SW_blnGetData = true Else SW_strError = SW_strError & " <tr bgcolor=""#336699"" height=""28""><td><font color=""#FFFFFF"">GetRS属性:</font></td></tr>" & vbcrlf SW_strError = SW_strError & " <tr bgcolor=""#ffffff""><td>" & strError & "</td></tr>" & vbcrlf End If End Property
'***************************************** ' 类型: 过程 ' 目的: 统计总记录数、计算总页数 ' 输入: 无 ' 返回: 无 '***************************************** Sub Init() Dim intPostion,strError
If Not (SW_blnGetConn and SW_blnGetData and SW_blnPageSize and SW_blnGetURL) Then SW_blnErrorFlag = true Call ShowErrors() Exit Sub End If
If SW_objRS.Eof And SW_objRS.Bof Then strError = strError & "<br>库中无任何记录" End If
'计算总计录数 SW_lngTotalRecord = SW_objRS.RecordCount If (SW_lngTotalRecord<=2147483647 AND SW_lngTotalRecord>=-2147483648) Then SW_lngTotalRecord = CLng(SW_lngTotalRecord) Else strError = strError & "<br>分页初始化时:总记录数溢出" End If If SW_lngTotalRecord <=0 Then strError = strError & "<br>分页初始化时:总记录数小于零"
'计算总页数 If SW_lngTotalRecord Mod SW_intPageSize = 0 Then SW_lngTotalPage = CLng(SW_lngTotalRecord SW_intPageSize * -1)*-1 Else SW_lngTotalPage = CLng(SW_lngTotalRecord SW_intPageSize * -1)*-1 + 1 End If
'获取页数 SW_lngPageNo = Trim(Request.QueryString("pageno")) If SW_lngPageNo = "" Then SW_lngPageNo = Trim(Request.Form("PageNo")) If SW_lngPageNo = "" Then SW_lngPageNo = 1 '如果没有选择第几页,则默认显示第一页 If SW_lngPageNo <> "" And IsNumeric(SW_lngPageNo) Then If (SW_lngPageNo <= 2147483647 And SW_lngPageNo>=-2147483648) Then SW_lngPageNo = CLng(SW_lngPageNo) Else strError = strError & "<br>页数溢出,请检查!" End If If (SW_lngPageNo<=0) Then strError = strError & "<br>页数只能是正整数!" Else strError = strError & "<br>你确信此页数 <font color=""#FF0000"">" & SW_lngPageNo & "</font> 存在?" End If
If (SW_lngPageNo > SW_lngTotalPage AND SW_lngTotalPage<>0) Then SW_lngPageNo = SW_lngTotalPage
SW_objRS.PageSize = SW_intPageSize SW_objRS.AbsolutePage = SW_lngPageNo
intPostion = InstrRev(SW_strURL,"?") SW_strFormAction = SW_strURL If intPostion > 0 Then SW_strURL = SW_strURL & "&PageNo=" Else SW_strURL = SW_strURL & "?PageNo=" End If
If Trim(SW_strFields) = "" Then For i = 0 To SW_objRS.Fields.Count-1 SW_strFields = SW_strFields & SW_objRS(i).Name & "," Next End If
SW_strFields = "," & Trim(SW_strFields) If IsArray(SW_aryFldName) Then For i = LBound(SW_aryFldName) To Ubound(SW_aryFldName) If Instr(SW_strFields,"," & SW_aryFldName(i) & ",") = 0 Then strError = strError & "<br>字段名 <font color=""#ff0000"">" & SW_aryFldName(i) & "</font> 正确吗?" Next
If (IsArray(SW_aryFldNote) AND UBound(SW_aryFldName)>UBound(SW_aryFldNote)) Then strError = strError & "<br>字段相应中文说明项目不能小于字段个数"
If (IsArray(SW_aryFldWidth) AND UBound(SW_aryFldName)>UBound(SW_aryFldWidth)) Then strError = strError & "<br>字段相应宽度项目不能小于字段个数" If (IsArray(SW_aryFldAlign) AND UBound(SW_aryFldName)>UBound(SW_aryFldAlign)) Then strError = strError & "<br>字段数据相应对齐方式项目不能小于字段个数" End If
If Trim(strError) = "" Then SW_blnInit = true Else SW_strError = SW_strError & " <tr bgcolor=""#336699"" height=""28""><td><font color=""#FFFFFF"">Init过程:</font></td></tr>" & vbcrlf SW_strError = SW_strError & " <tr bgcolor=""#ffffff""><td>" & strError & "</td></tr>" & vbcrlf End If Response.Write(SW_strCSSFile & vbcrlf) End Sub
'***************************************** ' 类型: 过程 ' 目的: 显示分页信息 ' 输入: 无 ' 返回: 无 '***************************************** Sub Pages() Dim strPages,k,intTemp,intTemp1
If Not(SW_blnInit) Then Call ShowErrors()
If SW_lngTotalPage = 1 Then Exit Sub
SELECT CASE SW_intBDKind CASE SW_intShowNoBorder Response.Write("<table border=""0"" width=""" & SW_intTBWidth & """ cellspacing=""0"" cellpadding=""0"" bgcolor=""" & SW_strBDColor & """ align=""center"">" & vbcrlf) CASE SW_intShowBigBorder Response.Write("<table border=""1"" width=""" & SW_intTBWidth & """ cellspacing=""0"" cellpadding=""0"" bgcolor=""" & SW_strBDColor & """ align=""center"">" & vbcrlf) CASE SW_intShowSmallBorder Response.Write("<table border=""0"" width=""" & SW_intTBWidth & """ cellspacing=""1"" cellpadding=""0"" bgcolor=""" & SW_strBDColor & """ align=""center"">" & vbcrlf) End SELECT
Response.Write(" <tr bgcolor=""" & SW_strBGColor & """>" & vbcrlf) Response.Write(" <td>" & vbcrlf) Response.Write(" <table width=""100%"">" & vbcrlf) Response.Write(" <tr>" & vbcrlf & " <td align=""center"" valign=""middle"">" & vbcrlf) If SW_lngTotalPage >= 1 Then SELECT CASE SW_lngShowPageType Case SW_intShowChinese If SW_lngPageNo <= 1 Then Response.Write ("<font color=""" & SW_strFTColor & """>首页 前页 <a href=""" & SW_strURL & SW_lngPageNo+1 & """>后页</a> <a href=""" & SW_strURL & SW_lngTotalPage & """>末页</a>" & vbcrlf) Else If SW_lngPageNo >= SW_lngTotalPage Then Response.Write ("<font color=""" & SW_strFTColor & """><a href=""" & SW_strURL & "1"">首页</a> <a href=""" & SW_strURL & SW_lngPageNo -1 & """>前页</a> " & "后页 末页" & vbcrlf) Else Response.Write ("<font color=""" & SW_strFTColor & """><a href=""" & SW_strURL & "1"">首页</a> <a href=""" & SW_strURL & SW_lngPageNo -1 & """>前页</a> " & "<a href=""" & SW_strURL & SW_lngPageNo+1 & """>后页</a> <a href=""" & SW_strURL & SW_lngTotalPage & """>末页</a>" & vbcrlf) End If End If Response.Write (" 页次:<b>" & SW_lngPageNo & "</b>/" & SW_lngTotalPage & "页 共<b>" & SW_lngTotalRecord & "</b>条记录 <b>" & SW_intPageSize & "</b>条/页</td>" & vbcrlf) Response.Write(" <form name=""gopage"" action=""" & SW_strFormAction & """ method=""post"">" & vbcrlf) Response.Write(" <td> 第") Response.Write(" <input type=""text"" name=""pageno"" size=""3"" class=""" & SW_strTXTClass & """ maxlength=4 title=""请输入页号,然后回车"">页 " & vbcrlf) Response.Write("<input type=""submit"" value=""GO"" class=""" & SW_strBTNClass & """></td></form></font>" & vbcrlf) Case SW_intShowEnglish If SW_lngPageNo <= 1 Then Response.Write ("<font color=""" & SW_strFTColor & """>First Prev <a href=""" & SW_strURL & SW_lngPageNo+1 & """>Next</a> <a href=""" & SW_strURL & SW_lngTotalPage & """>Last</a>" & vbcrlf) Else If SW_lngPageNo >= SW_lngTotalPage Then Response.Write ("<font color=""" & SW_strFTColor & """><a href=""" & SW_strURL & "1"">First</a> <a href=""" & SW_strURL & SW_lngPageNo -1 & """>Prev</a> " & "Next Last" & vbcrlf) Else Response.Write ("<font color=""" & SW_strFTColor & """><a href=""" & SW_strURL & "1"">First</a> <a href=""" & SW_strURL & SW_lngPageNo -1 & """>Prev</a> " & "<a href=""" & SW_strURL & SW_lngPageNo+1 & """>Next</a> <a href=""" & SW_strURL & SW_lngTotalPage & """>Last</a>" & vbcrlf) End If End If Response.Write (" Page No:<b>" & SW_lngPageNo & "</b>/" & SW_lngTotalPage & " Total Records:<b>" & SW_lngTotalRecord & "</b> PageSize:<b>" & SW_intPageSize & "</b></td>" & vbcrlf) Response.Write(" <form name=""gopage"" action=""" & SW_strFormAction & """ method=""post"">" & vbcrlf) Response.Write(" <td> ") Response.Write(" <input type=""text"" name=""pageno"" size=""3"" class=""" & SW_strTXTClass & """ maxlength=4 title=""Please input pageno then enter""> " & vbcrlf) Response.Write("<input type=""submit"" value=""GO"" class=""" & SW_strBTNClass & """></td></form></font>" & vbcrlf) Case SW_intShowCharacter strPages = "" intTemp = (SW_lngPageNo SW_intShowPages) * SW_intShowPages For k = 1 To SW_intShowPages intTemp1 = intTemp + k
If intTemp1 > SW_lngTotalPage Then Exit For If SW_lngPageNo = intTemp1 Then If Len(Trim(CStr(intTemp1)))<2 Then strPages = strPages & " 0" & CStr(intTemp1) Else strPages = strPages & " " & CStr(intTemp1) End If Else strPages = strPages & " <a href=""" & SW_strURL & CStr(intTemp1) & """>" If Len(Trim(CStr(intTemp1)))<2 Then strPages = strPages & "0" & CStr(intTemp1) Else strPages = strPages & CStr(intTemp1) End If strPages = strPages & "</a>" End If Next If SW_lngPageNo <= 1 Then Response.Write ("<font face=""Webdings"">9 7</font>" & strPages & " <a href=""" & SW_strURL & SW_lngPageNo+1 & """><font face=""Webdings"">8</font></a> <a href=""" & SW_strURL & SW_lngTotalPage & """><font face=""Webdings"">:</font></a>" & vbcrlf) Else If SW_lngPageNo >= SW_lngTotalPage Then Response.Write ("<a href=""" & SW_strURL & "1""><font face=""Webdings"">9</font></a> <a href=""" & SW_strURL & SW_lngPageNo -1 & """><font face=""Webdings"">7</font></a>" & strPages & " <font face=""Webdings"">8 :</font>" & vbcrlf) Else Response.Write ("<font ><a href=""" & SW_strURL & "1""><font face=""Webdings"">9</font></a> <a href=""" & SW_strURL & SW_lngPageNo -1 & """><font face=""Webdings"">7</font></a> " & strPages & " <a href=""" & SW_strURL & SW_lngPageNo+1 & """><font face=""Webdings"">8</font></a> <a href=""" & SW_strURL & SW_lngTotalPage & """><font face=""Webdings"">:</font></a>" & vbcrlf) End If End If
Response.Write ("</td>" & vbcrlf) Response.Write(" <form name=""gopage"" action=""" & SW_strFormAction & """ method=""post"">" & vbcrlf) Response.Write(" <td> ") Response.Write(" <input type=""text"" name=""pageno"" size=""3"" class=""" & SW_strTXTClass & """ maxlength=10 title=""Please input pageno then enter""> " & vbcrlf) Response.Write("<input type=""submit"" value=""GO"" class=""" & SW_strBTNClass & """></td></form></font>" & vbcrlf) Case SW_intShowImage Case Else Response.Write("<br>对不起,你设置的显示方式SWPage不支持。") Response.End End Select End If Response.Write(" </table>" & vbcrlf) Response.Write(" </td>" & vbcrlf) Response.Write(" </tr>" & vbcrlf) Response.Write("</table>" & vbcrlf) End Sub
Sub ShowData() Dim i,j
If Not(SW_blnInit) Then Call ShowError()
j = 0 If SW_objRS.Eof And SW_objRS.Bof Then Response.Write("库中无任何记录<br>") Response.End Else '空行 Response.Write("<table><tr><td height=""5""></td></tr></table>" & vbcrlf)
SELECT CASE SW_lngShowType Case SW_intHorizontalView '横排 Do While (Not SW_objRS.Eof AND j<SW_intPageSize) Response.Write(" <table border=""0"" Cellpadding=""0"" cellspacing=""1"" bgcolor=""#000000"" width=""" & SW_strShowWidth & """ align=""center"">" & vbcrlf) For i = LBound(SW_aryFldName) To UBound(SW_aryFldName) Response.Write(" <tr bgcolor=""#FFFFFF"" height=""28"">" & vbcrlf) Response.Write(" <td bgcolor=""" & SW_strTleBGColor & """ width=""" & SW_strTleWidth & """ align=""center"">" & vbcrlf & " ") If (IsArray(SW_aryFldNote)) Then Response.Write("<font color=""" & SW_strTleFTColor & """>" & SW_aryFldNote(i) & "</font>" & vbcrlf) Else Response.Write("<font color=""" & SW_strTleFTColor & """>" & SW_aryFldName(i) & "</font>" & vbcrlf) End If
Response.Write(" </td>" & vbcrlf & " <td")
If (IsArray(SW_aryFldWidth)) Then Response.Write(" width=""" & SW_aryFldWidth(i) & """")
If (IsArray(SW_aryFldAlign)) Then Response.Write(" align=""" & SW_aryFldAlign(i) & """")
Response.Write(">" & vbcrlf)
Response.Write(SW_objRS(SW_aryFldName(i)) & "</td>" & vbcrlf)
Response.Write(" </tr>" & vbcrlf) Next Response.Write(" </table>" & vbcrlf) '空行 Response.Write("<table><tr><td height=""5""></td></tr></table>" & vbcrlf) SW_objRS.MoveNext j = j + 1 Loop CASE SW_intVerticalView '竖排 Response.Write(" <table border=""0"" Cellpadding=""0"" cellspacing=""1"" bgcolor=""#000000"" width=""" & SW_strShowWidth & """ align=""center"">" & vbcrlf) Response.Write(" <tr bgcolor=""" & SW_strTleBGColor & """>" & vbcrlf) For i = LBound(SW_aryFldName) To UBound(SW_aryFldName) Response.Write(" <td align=""center""") If (IsArray(SW_aryFldWidth)) Then Response.Write(" width=""" & SW_aryFldWidth(i) & """>") If (IsArray(SW_aryFldNote)) Then Response.Write("<font color=""" & SW_strTleFTColor & """>" & SW_aryFldNote(i) & "</font>" & vbcrlf) Else Response.Write("<font color=""" & SW_strTleFTColor & """>" & SW_aryFldName(i) & "</font>" & vbcrlf) End If Response.Write(" </td>" & vbcrlf) Next Response.Write(" </tr>" & vbcrlf)
Do While (Not SW_objRS.Eof AND j<SW_intPageSize) Response.Write(" <tr bgcolor=""" & SW_strBGColor & """ height=""28"">" & vbcrlf) For i = LBound(SW_aryFldName) To UBound(SW_aryFldName) Response.Write( "<td") If (IsArray(SW_aryFldAlign)) Then Response.Write(" align=""" & SW_aryFldAlign(i) & """>") Response.Write(SW_objRS(SW_aryFldName(i)) & "</td>" & vbcrlf) Next
Response.Write(" </tr>" & vbcrlf) SW_objRS.MoveNext j = j + 1 Loop Response.Write(" </table>" & vbcrlf) Response.Write("<table><tr><td height=""5""></td></tr></table>" & vbcrlf) CASE ELSE Response.Write("<br>你还没设置数据的显示方式?或者你的设置的显示方式SWPage不支持!<br>") Response.End End SELECT End If End Sub
'***************************************** ' 类型: 过程 ' 目的: 显示分页类中出现的错误信息 ' 输入: 无 ' 返回: 无 '***************************************** Private Sub ShowErrors() If SW_strError <> "" Then SW_strError = "<table bgcolor=""#0000"" cellspacing=""1"" cellpadding=""0"" width=""90%"" align=""center"">" & vbcrlf & " <tr bgcolor=""#ff9900"" height=""30""><td align=""center"" valign=""middle""><b>SWPage分页类错误信息<b></td></tr>" & vbcrlf & SW_strError & "</table>" & vbcrlf Response.Write(SW_strError) Response.End End If End Sub
'***************************************** ' 类型: 过程 ' 目的: 释放资源 ' 输入: 无 ' 返回: 无 '***************************************** Sub Close() Set SW_objRS = Nothing Set SW_objConn = Nothing End Sub End Class %>
|