手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>网络编程>Asp编程>列表

ASP通用分页类

来源:互联网 作者:west263.com 时间:2008-02-23
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!

' 类型: 属性
' 目的: 设定或显示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_strTleWidth:单元格宽度字符串
' 返回: 无
'*****************************************
Public Property Let TleWidth(a_strWidth)
SW_strTleWidth = a_strWidth
End Property

'*****************************************
' 类型: 属性
' 目的: 设置显示标题时单元格分隔线的类型
' 输入: a_intBDType 单元格分隔线的类型
' 返回: 无
'*****************************************
Public Property Let TleBDType(a_intBDType)
SW_intTleBDType = a_intBDType
End Property

'*****************************************
' 类型: 过程
' 目的: 统计总记录数、计算总页数
' 输入: 无
' 返回: 无
'*****************************************
Sub Init()
Dim intPostion,strError,i,objRSTemp,lngTotalRecord

If Not (SW_blnConn and SW_blnOpenRS and SW_blnPageSize and SW_blnGetURL) Then
Call ShowErrors()
Exit Sub
End If

If SW_objRS.Eof And SW_objRS.Bof Then
strError = strError & "<br>库中无任何记录"
End If

'计算总计录数
Set objRSTemp = SW_objConn.Execute("SELECT * FROM SW_RecCount")
lngTotalRecord = CLng(objRSTemp("SW_RecCount").Value)
SW_lngTotalRecord = lngTotalRecord
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 = LCase("," & 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>字段数据相应对齐方式项目不能小于字段个数"

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!