<% Rem ================================================================= Rem = RCSfile:Cls_Pages.asp Rem ================================================================= Class Cls_Pages Rem Const Private Showo_RecPerPage,Showo_CurrPage Private Showo_Conn,Showo_CookieName,Showo_PageUrl,Showo_Term Private Showo_Sql,Showo_Field,Showo_Table,Showo_Where,Showo_OrderBy,Showo_Id Private iRecCount,iPageCount,iCurrPage,ResultSet_Sql,Showo_Mm '================================================================ ' Class_Initialize 类的初始化 '================================================================ Private Sub Class_Initialize Showo_RecperPage=10 '设定每页记录条数的默认值为10 Showo_CurrPage=CheckNum(Trim(request("Page")),1,-1) '获取当前面的值 End Sub '================================================================ ' Conn 得到数据库连接 '================================================================ Public Property Let Conn(obj_conn) Set Showo_Conn=obj_conn End Property '================================================================ ' RecperPage 设置每一页记录条数,默认10记录 '================================================================ Public Property Let RecPerPage(ByVal int_recperpage) Showo_RecPerPage=CheckNum(int_recperpage,10,-1) End Property '================================================================ ' CookieName 取得cookiename '================================================================ Public Property Let CookieName(ByVal str_cookiename) Showo_CookieName=str_cookiename End Property '================================================================ ' PageUrl 取得showo_page.js的路径 '================================================================ Public Property Let PageUrl(ByVal str_pageurl) Showo_PageUrl=str_pageurl End Property '================================================================ ' Term 搜索条件是否变化(0无变化,1有变化) '================================================================ Public Property Let Term(ByVal int_term) Showo_Term=CheckNum(int_term,0,1) End Property '================================================================ ' Sql 取得sql所需表字段条件排序,输入:字段,表,条件,排序,主ID '================================================================ Public Property Let Sql(ByVal str_sql) Showo_Sql=Split(str_sql,"$") Showo_Field=Showo_Sql(0) Showo_Table=Showo_Sql(1) Showo_Where=Showo_Sql(2) Showo_OrderBy=Showo_Sql(3) Showo_Id=Showo_Sql(4) End Property '================================================================ ' RecCount 取得记录总数 '================================================================ Public Property Get RecCount() If Showo_Term=0 Then RecCount=Request.Cookies("ShowoPage")(Showo_CookieName) RecCount=CheckNum(RecCount,0,-1) If RecCount=0 Then RecCount=Showo_Conn.execute("SELECT Count("&Showo_Id&") FROM "&Showo_Table&" "&Showo_Where,0,1)(0) Response.Cookies("ShowoPage")(Showo_CookieName)=RecCount End If ElseIf Showo_Term=1 Then RecCount=Showo_Conn.execute("SELECT Count("&Showo_Id&") FROM "&Showo_Table&" "&Showo_Where,0,1)(0) Response.Cookies("ShowoPage")(Showo_CookieName)=RecCount Else RecCount=Showo_Conn.execute("SELECT Count("&Showo_Id&") FROM "&Showo_Table&" "&Showo_Where,0,1)(0) End If End Property '================================================================ ' ResultSet 返回分页后的记录集 '================================================================ Public Property Get ResultSet() ResultSet=Null '记录总数 iRecCount=RecCount() '当前页 If iRecCount>0 Then '页数 If (iRecCount mod Showo_RecPerPage)=0 Then iPageCount=iRecCount\Showo_RecPerPage Else iPageCount=iRecCount\Showo_RecPerPage+1 End If '当前页 iCurrPage=CheckNum(Showo_CurrPage,1,iPageCount) Set Showo_Rs = server.CreateObject ("adodb.RecordSet") ResultSet_Sql="SELECT "&Showo_Field&" FROM "&Showo_Table&" "&Showo_Where&" "&Showo_OrderBy Showo_Rs.Open ResultSet_Sql,Showo_Conn,1,1,&H0001 '&H0001表示adCmdText,将执行一段sql,&H0002表示adCmdTable,将操作一个表 Showo_Rs.AbsolutePosition=(iCurrPage-1)*Showo_RecPerPage+1 ResultSet=Showo_Rs.GetRows(Showo_RecPerPage) Showo_Rs.close Set Showo_Rs=nothing End If End Property '================================================================ ' 输入:检查字段,开始数字(默认数字),结束数字(为-1则不检查大小) '================================================================ Private Function CheckNum(byval iStr,byval iStartNum,byval iEndNum) If IsNumeric(iStr) Then CheckNum=Clng(iStr) Else CheckNum=iStartNum End If If iEndNum>-1Then If CheckNumiEndNum Then CheckNum=iEndNum End If End Function '================================================================ ' Class_Terminate 类注销 '================================================================ Private Sub Class_Terminate() If IsObject(Showo_Conn) Then Showo_Conn.Close Set Showo_Conn = Nothing End If End Sub '================================================================ ' 上下页部分 '================================================================ Public Sub ShowPage()%> <%End Sub End Class %>