|
<%
'===================================================================
'XDOWNPAGE ASP??
'?? 1.00
'Code by zykj2000
'Email: zykj_2000@163.net
'BBS: http://bbs.513soft.net
'?????????????????????????????
'????????
'
'????
'????????????????????????????????????
'??URL????
'
'????
'??????
'PapgeSize ???????????
'GetRS ???????Recordset?????
'GetConn ???????
'GetSQL ??????
'??????
'ShowPage ???????,???????
'
'?:
'
' '????
'
' Set mypage=new xdownpage '????
' mypage.getconn=conn '???????
' mypage.getsql="select * from productinfo order by id asc"
' mypage.pagesize=5 '????????????5?
' set rs=mypage.getrs() '??Recordset
' mypage.showpage() '???????????????set rs=mypage.getrs()??
' ?????????????
' for i=1 to mypage.pagesize '??????????????Recordset??????
' if not rs.eof then '????????????????
' response.write rs(0) & "
" '?????????????
' rs.movenext
' else
' exit for
' end if
' next
'
'===================================================================
Const Btn_First="<font face="webdings">9</font>" '???????????
Const Btn_Prev="<font face="webdings">3</font>" '???????????
Const Btn_Next="<font face="webdings">4</font>" '???????????
Const Btn_Last="<font face="webdings">:</font>" '????????????
Const XD_Align="Center" '??????????
Const XD_Width="100%" '?????????
Class Xdownpage
Private XD_PageCount,XD_Conn,XD_Rs,XD_SQL,XD_PageSize,Str_errors,int_curpage,str_URL,int_totalPage,int_totalRecord
'=================================================================
'PageSize ??
'??????????
'=================================================================
Public Property Let PageSize(int_PageSize)
If IsNumeric(Int_Pagesize) Then
XD_PageSize=CLng(int_PageSize)
Else
str_error=str_error & " ageSize??????"
ShowError()
End If
End Property
Public Property Get PageSize
If XD_PageSize="" or (not(IsNumeric(XD_PageSize))) Then
PageSize=10
Else
PageSize=XD_PageSize
End If
End Property
'=================================================================
'GetRS ??
'?????????
'=================================================================
Public Property Get GetRs()
Set XD_Rs=Server.createobject("adodb.recordset")
XD_Rs.PageSize=PageSize
XD_Rs.Open XD_SQL,XD_Conn,1,1
If not(XD_Rs.eof and XD_RS.BOF) Then
If int_curpage>XD_RS.PageCount Then
int_curpage=XD_RS.PageCount
End If
XD_Rs.AbsolutePage=int_curpage
End If
Set GetRs=XD_RS
End Property
'================================================================
'GetConn ???????
'
'================================================================
Public Property Let GetConn(obj_Conn)
Set XD_Conn=obj_Conn
End Property
'================================================================
'GetSQL ??????
'
'================================================================
Public Property Let GetSQL(str_sql)
XD_SQL=str_sql
End Property
'==================================================================
'Class_Initialize ?????
'????????
'
'==================================================================
Private Sub Class_Initialize
'========================
'??????????
'========================
XD_PageSize=10 '?????????10
'========================
'???????
'========================
If request("page")="" Then
int_curpage=1
ElseIf not(IsNumeric(request("page"))) Then
int_curpage=1
ElseIf CInt(Trim(request("page")))<1 Then
int_curpage=1
Else
Int_curpage=CInt(Trim(request("page")))
End If
End Sub
'====================================================================
'ShowPage ???????
'?????????????????????
'
'====================================================================
Public Sub ShowPage()
Dim str_tmp
int_totalRecord=XD_RS.RecordCount
If int_totalRecord<=0 Then
str_error=str_error & "????????????"
Call ShowError()
End If
If int_totalRecord int_TotalPage=1
Else
If int_totalRecord mod PageSize =0 Then
int_TotalPage = CLng(int_TotalRecord / XD_PageSize * -1)*-1
Else
int_TotalPage = CLng(int_TotalRecord / XD_PageSize * -1)*-1+1
End If
End If
If Int_curpage>int_Totalpage Then
int_curpage=int_TotalPage
End If
'==================================================================
'???????????????????????
'==================================================================
response.write ""
str_tmp=ShowFirstPrv
response.write str_tmp
str_tmp=showNumBtn
response.write str_tmp
str_tmp=ShowNextLast
response.write str_tmp
str_tmp=ShowPageInfo
response.write str_tmp
response.write ""
End Sub
'====================================================================
'ShowFirstPrv ????????
'
'
'====================================================================
Private Function ShowFirstPrv()
Dim Str_tmp,int_prvpage
If int_curpage=1 Then
str_tmp=Btn_First&" "&Btn_Prev
Else
int_prvpage=int_curpage-1
str_tmp=""&Btn_First&" "& Btn_Prev&""
End If
ShowFirstPrv=str_tmp
End Function
'====================================================================
'ShowNextLast ??????
'
'
'====================================================================
Private Function ShowNextLast()
Dim str_tmp,int_Nextpage
If Int_curpage>=int_totalpage Then
str_tmp=Btn_Next & " " & Btn_Last
Else
Int_NextPage=int_curpage+1
str_tmp=""&Btn_Next&" "& Btn_Last&""
End If
ShowNextLast=str_tmp
End Function
'====================================================================
'ShowNumBtn ????
'
'
'====================================================================
Private Function showNumBtn()
Dim i,str_tmp
For i=1 to int_totalpage
str_tmp=str_tmp & "["&i&"] "
Next
showNumBtn=str_tmp
End Function
'====================================================================
'ShowPageInfo ????
'????????
'
'====================================================================
Private Function ShowPageInfo()
Dim str_tmp
str_tmp="??:"&int_curpage&"/"&int_totalpage&"? ?"&int_totalrecord&"??? "&XD_PageSize&"?/??"
ShowPageInfo=str_tmp
End Function
'==================================================================
'GetURL ?????URL
'??URL????????????
'
'==================================================================
Private Function GetURL()
Dim strurl,str_url,i,j,search_str,result_url
search_str="page="
strurl=Request.ServerVariables("URL")
Strurl=split(strurl,"/")
i=UBound(strurl,1)
str_url=strurl(i)'????????
str_params=Request.ServerVariables("QUERY_STRING")
If str_params="" Then
result_url=str_url & "?page="
Else
If InstrRev(str_params,search_str)=0 Then
result_url=str_url & "?" & str_params &"&page="
Else
j=InstrRev(str_params,search_str)-2
If j=-1 Then
result_url=str_url & "?page="
Else
str_params=Left(str_params,j)
result_url=str_url & "?" & str_params &"&page="
End If
End If
End If
GetURL=result_url
End Function
'====================================================================
' ?? Terminate ???
'
'====================================================================
Private Sub Class_Terminate
XD_RS.close
Set XD_RS=nothing
End Sub
'====================================================================
'ShowError ????
'
'
'====================================================================
Private Sub ShowError()
If str_Error <> "" Then
Response.Write("" & SW_Error & "")
Response.End
End If
End Sub
End class
%> |
|