Universal Data Page Class

xiaoxiao2021-03-06  17

ID> 100 "," ID DESC ") '/ *' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '/ * PageCount = mypage.pagecount' Return Page Total '/ * RecordCount = MyPage.RecordCount' Return to the total number of records' / * nextpage = mypage.nextpage 'Back to the next page' / * prepage = mypage.prepage 'Return to the previous page' / *************** ****************************************************************** Class 'external connection object database connection Private Rs Private List_Fields Private Table_Name Private Query_Where Private OrderBy_SQL' PageClass Private connection fields are sorted statement section Private page_Count 'returns the total number of records in the current query page Private Page_Size' is provided a display how many records Private Cur_Page 'provided Current page number private record_count 'Returns the total number of records of the current query' / **************** Setting connections object ***************** *********** PUBLIC Property Let Conn Set Connection = Objconn End Property Public Property Get CONN () SET CONN = Connection End Property '/ *********** ************************************************************** **************** Setting query SQL statement ** ************************************** '' Query Display Field Public Property Let Fields (Byval Value) List_fields = Value End Property Public Property Get Fields () Fields = List_Fields End Property '' look-up table name Public Property Let TableName (ByVal Value) Table_Name = Value End Property Public Property Get TableName () TableName = Table_Name End Property ''

Single ****************************************************************** ************************************************** The Value does not write to the order by .

Such as: [object] .OrderBy = "ID Desc, PostTime Asc" Public Property Let OrderBy (ByVal Value) OrderBy_SQL = Value End Property Public Property Get OrderBy () OrderBy = OrderBy_SQL End Property '/ ********* ******* **************************************************** '/ *************** Return to the current number of pages of the current query result ********************************** PUBLIC Property Get PageCount () PageCount = page_Count End Property Public Property Get RecordCount () RecordCount = Record_Count End Property Public Property Get NextPage () If Cur_Page 1 THEN PREPAGE = CUR_PAGE-1 ELSE PREPAGE = CUR_PAGE END IF End Property '/ ************** * ******************* ************************************ Settled one Number of records ************************************* Public property lettsize (byval value) if not isnumeric (value) or value = " "THEN value = 10 else value = cint (value) end if if value <1 Then value = 10 Page_size = value end p ROPERTY PUBLIC PROPERTY GET PAGESIZE () PAGESIZE = Page_Size End Property '' Setting Current Page Number ************************************ Public Property Let Page ByVal Value) If Not IsNumeric (Value) Or Value = "" Then Value = 1 Else Value = CLng (Value) End If If Value <1 Then Value = 1 Cur_Page = Value End Property Public Property Get Page () Page = Cur_Page End Property '/ *************** ***************************************** ************ Private sub class_initialize 'Initialization Recordset Object Page_size = 10' Default One Page to 10 Data CURPAGE = 1 'Default Currently RECORD_COUNT =

0 Page_Count = 0 End Sub Private Sub Class_Terminate Call CloseRecordSet End Sub '/ *** close the database connection ******* Private Sub CloseRecordSet On Error Resume Next If IsObject (Rs) Then Rs.Close Set Rs = Nothing End IF on error goto 0 end sub '/ ********** Data to return the corresponding page number *********************************** *********************** Public Function ExecuteBy (ByVal oTableName, ByVal oFields, ByVal oCondition, ByVal oOrderBy) Table_Name = oTableName List_Fields = oFields Query_Where = oCondtion OrderBy_SQL = oOrderBy Set ExecuteBy = Execute () End Function 'query and returns the current CurPage the page record Public Function Execute () Call CloseRecordSet On Error Resume Next Dim TSQL, TopMod, sWhere If Not IsObject (Connection) Or Table_Name = "" Or OrderBy_SQL = " "Then Set Execute = Nothing Record_Count = 0 page_Count = 0 Exit Function End If If Trim (Query_Where) <>" "Then sWhere =" Where "& Query_Where Else sWhere =" "End If TSQL =" Select Count (*) From [ " & Table_name & "]" & Swhere Record_count = Connection.execute (TSQL) (0) Get Record Total Number If Err Then Err.Clear Set Execute = Nothing Record_Count = 0 Page_Count = 0 Exit Function End If If Record_Count <1 Then Set Execute = Nothing Record_Count = 0 Page_Count = 0 Exit Function End If 'the total number of acquired pages If Record_Count Mod Page_Size < > 0 Then TopMod = Record_Count Mod Page_Size page_Count = Fix (Record_Count / Page_Size) 1 If Cur_Page

Page_Count Then Cur_Page = Page_Count If Cur_Page <1 Then Cur_Page = 1 If Trim (List_Fields) = "" Then List_Fields = "*" TSQL = "Select * From (Select Top" & TopMod & "* From (Select Top" & (Cur_Page * Page_Size ) & "" & List_Fields & "From [" & Table_Name & "]" & sWhere & "Order By" & OrderBy_SQL & ") Order By" & TransformOrder (OrderBy_SQL) & ") Order By" & OrderBy_SQL Set Rs = Connection.Execute (TSQL) If Err Then Err.Clear Set Execute = Nothing Record_Count = order 0 page_Count = 0 Exit Function End If Set Execute = Rs End Function 'OrderBy conversion of ASC-> DESC DESC-> ASC Private Function TransformOrder (ByVal Value) If Value = "" Then TransformOrder = "" EXIT FUNCTION END IF DIM ORDERRAY, I, RESULT, BYSTRING, FIELDS, INPOS ORDERARRING, FIELDS, INPOS OrderaRray = Split (Value, ",") 'Decomposes each field value for i = 0 to Ubound (Orderay) IF Orderay (i) <> " THEN INPOS = INSTRREV (TRIM (ORDERRAY (I)), "") Finding the order of order if INPOS <1 Then 'If not found, it is ASC sort bystring = "ASC" Fields = OrderaRray (i) "" Else Bystring = TRIM (MID (OrderaRray (I), INPOS 1)) Fields = Left (OrderaRray (I), INPOS) IF Bystring <> "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "", BYSTRING = "asc" damtring = "desc" else bystring = "ASC" end if result = result fields bystring ","

End if Next if result <> "" "" SUB SHOW_LIST DIM PAGE, PAGERS Page = Request ("Page" DIM MYPAGE Set MyPage = New PageClass MyPage.Conn = Conn MyPage.PageSize = 20 MyPage.Page = Page 'MyPage.TableName = "Movie"' MyPage.Fields = "*" 'MyPage.OrderBy = "ID Asc"' Set PageRs = MyPage .Execute set pagers = mypage.executeby ("movie", "*", "," ip ASC ") if Pagers Is Nothing The EXIT SUB DO Until Pagers.eof response.write" " response.write "

"> ") &" response.write "" & PAGERS ("name") & "" response.write " " & Pagers ("URL") & " "response.write" ") &" "" "" "" "" "" "PAGERS.MOVENEXT LOOP PAGERS.C Lose PageCount = mypage.pagecount page = mypage.page 'Number of current page numbers NEXTPAGE = mypage.nextPage prepege = mypage.prepage set Pagers =

转载请注明原文地址:https://www.9cbs.com/read-72568.html

New Post(0)