Page class

zhaozj2021-02-16  57

Automatically generate lists and pagins according to the ADO record set, need to be converted to Recordset: RS_GRID

<%

'==================================================== ==========

'Page class, generally from .NET's DataGrid's way

'Features: Automatically generate DataGrid list heads and content, as well as paging columns

'According to the netizen bubuy (湃 nomoneytobuy) score page function modified to class

'Example of use:

'DIM DG

'DIM URL

'DIM FLD (2)

'DIM FLDNAME (2)

'Dim Fldwidth (2)

'Fld (0) = "id"

'FLD (1) = "Title"

'FLD (2) = "Input_date"

'FldName (0) = "number"

'FLDNAME (1) = "Title"

'FldName (2) = "Entry Date"

'Fldwidth (0) = "10%"

'Fldwidth (1) = "60%"

'Fldwidth (2) = "30%"

'set DG = New DataGrid

'DG.DataSource = RS_GRID

'DG.TITLECOLOR = "# DCE19D"

'DG.PageSize = 1

'DG.fields = FLD

'DG.fieldsname = fldname

'DG.fieldWidth = FldWidth

'URL = Request.serverVariables ("URL") & "? Param = TestParameter" // There is an original parameter

'DG.URL = URL

'DG.Generate ()

'============= Designed by window WINDANCER 2003.10.17 ================

Class DataGrid

Private obj_recordset 'Recordset

Private int_pagesize 'per page record number

'Two arrays save database field name and Chinese name

Private Arr_field 'Database field

Private arr_fieldname 'field display name ()

Private arr_fieldwidth 'field display width

Private str_titlecolor 'Header Color #EFFFCE

Private str_url 'request URLPRIVATE STR_ERROR' Error Information

Private sub coplass_initialize ()

INT_PAGESIZE = 10

Str_titlecolor = "#fffff"

STR_ERROR = "" "

End Sub

'==================================================== ==============

'Attribute information

'==================================================== ================

'-----------------------------------

'Data Source, I only support Recordset

'-----------------------------------

Public property Let DataSource (OBJ)

Set obj_recordset = OBJ

End Property

Public Property Let PageSize (int

Value

INT_PAGESIZE = INT

Value

End Property

Public property Get Pagesize

PageSize = int_categoryID

End Property

Public Property Let Fields (Arr)

Arr_field = arr

End Property

Public property Get Fields

Fields = arr_field

End Property

Public Property Let FieldsName (Arr)

Arr_fieldname = arr

End Property

Public property Get FieldsName

FieldsName = arr_fieldname

End Property

Public Property Let FieldWidth (Arr)

Arr_fieldwidth = arr

End Property

Public property Get FieldWidth

FieldWidth = arr_fieldwidth

End Property

Public Property Let Titlecolor (STR

Value

Str_titlecolor = STR

Value

End Property

Public property Get Titlecolortitlecolor = STR_TITLECOLOR

End Property

'------------------------------------- ----

'This attribute is to save the URL path

'If the current path is with parameters, then use & page = X, otherwise it is used? Page = X

'------------------------------------- -----

Public Property Let Url (STR

Value

STR_URL = STR

Value

End Property

Public property Get URL

URL = STR_URL

End Property

'==================================================== ================

'method

'==================================================== ================

'------------------------------------- ---------------

'Display current error

'------------------------------------- ---------------

Private sub dresslastError ()

Response.write (STR_ERROR)

Response.end ()

End Sub

'------------------------------------- ---------------

'Generate ()

'Using ADO Page

'------------------------------------- ----------------

Public Sub Generate ()

'---- Check parameters --------------------------

CHECK

'--------- Variable Declaration -----------------------------------

Dim FieldCount 'display field

Fieldcount = ubound (arr_field) 1

DIM CurrentPage 'current page

DIM PGCOUNT 'Total Page

DIM Recount 'records, this is originally used to take RS.Recordcount, save the efficiency and the high DIM Hasotherparam' URL contains other parameters.

DIM PageParam 'Current page URL parameter

DIM PageInfomation 'Current Pedestrian Status Information

DIM SEPERATOR 'Sets the separator

SEPERATOR = ""

'------------- Treat URL parameters -------------------------

IF INSTR (STR_URL, "?")> 0 THEN

Hasotherparam = TRUE

PageParam = "& Page ="

Else

Hasotherparam = false

PageParam = "? Page ="

END IF

'---------- Get the current page --------------------------------

CurrentPage = Request.QueryString ("Page")

IF currentpage = "" ""

CurrentPage = 1

Else

CurrentPage = CINT (CURRENTPAGE)

END IF

'----------- Handling data source ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Obj_recordset.pagesize = int_pagesize

Recount = obj_recordset.recordcount

Pgcount = obj_recordset.pagecount

If Obj_Recordset.eof Then

Response.write ("

Sorry, no record! ")

Else

'----------- Treatment ADO Page ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

IF CurrentPage <1 THEN

CurrentPage = 1

Else

IF CurrentPage> Pgcount Then

Currentpage = pgcount

END IF

END IF

Obj_recordset.absolutePage = CURRENTPAGE

Response.write ("

")

'--------------- page link ---------------------------------------------------------------------------------------

DIM firstLINK, Prevlink, NextLink, LastLink 'defines the upward and down-turned variables

'----------------------- Home -------------------------

IF CurrentPage> 1 THEN

FirstLink = "

IF CurrentPage

NextLink = "<" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" [

Lastlink = "

Else

NextLink = "Next page"

LastLink = "Take"

END IF

PageInfomation = FirstLink & Seperator & Seperator & LastLink & Seperator & "INT_PAGESIZE) &" Summary "& Seperator &" Total "& Pgcount &" Page "& SEPERATOR &" Currently & Currentpage & "page" & seperator

Response.write ("

)

Response.write ("

")

'--------------- Set the head -----------------

Response.write ("

DIM I

For i = 0 to Fieldcount -1

Response.write ("

")

For cursor = 0 to Fieldcount -1

Response.write ("

" & arr_fieldname (i) & "< / b> ") Next

Response.write ("")

'--------------------- Output -------------------------- -------

i = 0

While (not obj_recordset.eof) and i

DIM CURSOR

Response.write ("

" & obj_recordset (arr_field (cursor)) & "")

NEXT

Response.write ("")

i = i 1

Obj_recordset.movenext

Wend

'------------------------ Output Page ---------------------- ----------------

Response.write ("

Private sub check ()

IF ubound (arr_field) <> ubound (arr_fieldname) THEN

STR_ERROR = "Fields array and FieldName array must be the same"

END IF

IF obj_recordset = EMPTY THEN

STR_ERROR = "Data source can't be empty, please set the DataSource property"

END IF

IF int_pageSize = "" ""

STR_ERROR = "Data source can't be empty"

END IF

Showlasterror

End Sub

END CLASS

%>

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

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.051, SQL: 9