⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ute_class.inc

📁 UTE - (U)niversal ASP (T)able (E)ditor 万能数据管理(管理后台)
💻 INC
📖 第 1 页 / 共 4 页
字号:

            ' ---- Filter Values ----
            for j = 1 to i
                Redim Preserve m_FilterValues(UBound(m_FilterValues)+1)
                m_FilterValues(UBound(m_FilterValues)) = Request.QueryString(sParamFilterValue & CStr(j))
            next

            ' ---- Filter Combines ----
            for j = 1 to i - 1
                Redim Preserve m_FilterCombines(UBound(m_FilterCombines)+1)
                m_FilterCombines(UBound(m_FilterCombines)) = Request.QueryString(sParamFilterCombine & CStr(j))
            next
            
        end if

    End Sub


    ''----------------------------------------------------------------------
    '' Name:     AddPrimaryKeyField
    ''           ==================
    '' 
    '' Add's a primary key field to the array
    ''
    '' Parameter:                
    ''      sField      name of field
    ''      nType       type of field
    ''
    '' return value:
    ''      none
    ''
    ''----------------------------------------------------------------------
    Private Sub AddPrimaryKeyField (sField, nType)
        Redim Preserve m_PrimaryKeyFields(UBound(m_PrimaryKeyFields)+1)
        Redim Preserve m_PrimaryKeyTypes(UBound(m_PrimaryKeyFields))
        m_PrimaryKeyFields(UBound(m_PrimaryKeyFields)) = sField
        m_PrimaryKeyTypes(UBound(m_PrimaryKeyTypes)) = nType
    End Sub


    ''----------------------------------------------------------------------
    '' Name:     AddStandardField
    ''           ================
    '' 
    '' Add's a "standard" field to the array
    ''
    '' Parameter: 
    ''      sField      name of field
    ''      nType       type of field
    ''
    '' return value:
    ''      none
    ''
    ''----------------------------------------------------------------------
    Private Sub AddStandardField (sField, nType)
        Redim Preserve m_StandardFields(UBound(m_StandardFields)+1)
        Redim Preserve m_StandardTypes(UBound(m_StandardFields))
        m_StandardFields(UBound(m_StandardFields)) = sField
        m_StandardTypes(UBound(m_StandardTypes)) = nType
    End Sub


    ''----------------------------------------------------------------------
    '' Name:     AddSortField
    ''           ============
    '' 
    '' Add's a field the table should be sorted after to the array
    ''
    '' Parameter:                
    ''      sField      name of field
    ''
    '' return value:
    ''      none
    ''
    ''----------------------------------------------------------------------
    Private Sub AddSortField (sField)
        Redim Preserve m_SortFields(UBound(m_SortFields)+1)
        m_SortFields(UBound(m_SortFields)) = sField
    End Sub


    ''----------------------------------------------------------------------
    '' Name:     AddSortOrder
    ''           ============
    '' 
    '' Add's the sort order of a field to the array
    ''
    '' Parameter:                
    ''      sField      name of field
    ''
    '' return value:
    ''      none
    ''
    ''----------------------------------------------------------------------
    Private Sub AddSortOrder (sOrder)
        Redim Preserve m_SortFieldsOrder(UBound(m_SortFieldsOrder)+1)
        m_SortFieldsOrder(UBound(m_SortFieldsOrder)) = sOrder
    End Sub


    ''----------------------------------------------------------------------
    '' Name:     SetPrimaryKeyFieldType
    ''           ======================
    '' 
    '' Sets the type of a primary key field to the types array if the
    '' current type is -1. This will be used if there are primary keys
    '' being set via URL. In this case we need to set the type afterwards.
    ''
    '' Parameter:                
    ''      sField      Name of the field
    ''      nType       Type of the field
    ''
    '' return value:
    ''      none
    ''
    ''----------------------------------------------------------------------
    Private Sub SetPrimaryKeyFieldType ( sField, nType )
        Dim i
        for i = 1 to UBound(m_PrimaryKeyFields)
            if (m_PrimaryKeyFields(i) = sField) and (m_PrimaryKeyFields(i) = -1) then
                m_PrimaryKeyTypes(i) = nType
            end if
        next
    End Sub


    ''----------------------------------------------------------------------
    '' Name:     IsKnownPrimaryKey
    ''           =================
    '' 
    '' Checks if the given field is already known as primary key
    ''
    '' Parameter: 
    ''      sField      Name of field
    ''
    '' return value:
    ''      boolean
    ''
    ''----------------------------------------------------------------------
    Private Function IsKnownPrimaryKey ( sField ) 
        Dim i
        Dim bReturn
        bReturn = False
        for i = 1 to UBound(m_PrimaryKeyFields)
            if m_PrimaryKeyFields(i) = sField then bReturn = True
        next
        IsKnownPrimaryKey = bReturn
    End Function


    ''----------------------------------------------------------------------
    '' Name:     IsPrimaryKey_inDBSchema
    ''           =======================
    '' 
    '' Checks if the given field is defined in db schema
    ''
    '' Parameter: 
    ''      sField      name of field
    ''
    '' return value:
    ''      boolean
    ''
    ''----------------------------------------------------------------------
    Private Function IsPrimaryKey_inDBSchema ( sField )
        Dim bReturn
        bReturn = False

        Dim rsSchema
        Set rsSchema = Server.CreateObject("ADODB.Recordset")
        rsSchema.CursorType = adOpenDynamic
        
        ' Getting the adSchemaPrimaryKeys will only supported by oledb 
        ' providers, not by simple ODBC connections. They will throw an
        ' error.
        on error resume next
        Set rsSchema = m_DB.openSchema(adSchemaPrimaryKeys)
        if Err = 0 then
            do while (not rsSchema.EOF) and (not bReturn)
                if LCase(rsSchema("TABLE_NAME")) = LCase(m_sTable) then
                    if LCase(rsSchema("COLUMN_NAME")) = LCase(sField) then
                        bReturn = True
                    end if
                end if
                rsSchema.MoveNext
            loop
            rsSchema.Close
        end if
        on error goto 0

        Set rsSchema = Nothing

        IsPrimaryKey_inDBSchema = bReturn
    End Function

    
    ''----------------------------------------------------------------------
    '' Name:     PrintSchema
    ''           ===========
    '' 
    '' For debug purpose only ! Prints the conntents of the given schema.
    ''
    '' Parameter: 
    ''
    '' return value:
    ''
    ''----------------------------------------------------------------------
    Private Sub PrintSchema

        Dim rsSchema, fld
        Set rsSchema = Server.CreateObject("ADODB.Recordset")
        rsSchema.CursorType = adOpenDynamic

        on error resume next
        Set rsSchema = m_DB.openSchema(adSchemaPrimaryKeys)
        'Set rsSchema = m_DB.openSchema(adSchemaIndexes)
        'Set rsSchema = m_DB.openSchema(adSchemaColumns)
        'Set rsSchema = m_DB.openSchema(adSchemaTables)
        'Set rsSchema = m_DB.openSchema(adSchemaProviderTypes)

        if err = 0 then
            while not rsSchema.EOF
                response.write "-----------------------------------------------------------------------<br>" & vbCrLf
                for each fld in rsSchema.Fields
                    response.write fld.name & ": " & fld.value & "<br>" & vbCrLf
                next
                rsSchema.MoveNext
            wend
        end if
        on error goto 0

        response.end

    End Sub

    
    ''----------------------------------------------------------------------
    '' Name:     SortFields
    ''           ==========
    '' 
    '' Sort given array ascending
    ''
    '' Parameter:
    ''      fields      array ho鰀ing the fields to be sorted
    ''      types       array holding the types of the fields
    ''
    '' return value:
    ''      none
    ''
    ''----------------------------------------------------------------------
    Private Sub SortFields ( ByRef fields, ByRef types )
        Dim pa
        Dim pb
        Dim temp
        ' standard bubble sort
        for pa = 1 to UBound(fields) - 1
            for pb = 1 to UBound(fields) - pa
                if fields(pb) > fields(pb + 1) then 
                    ' swap fields
                    temp = fields(pb)
                    fields(pb) = fields(pb + 1)
                    fields(pb + 1) = temp
                    ' swap types
                    temp = types(pb)
                    types(pb) = types(pb + 1)
                    types(pb + 1) = temp
                end if
            next
        next
    End Sub


    ''----------------------------------------------------------------------
    '' Name:     AnalyzeTable
    ''           ============
    '' 
    '' Analyzing Table for Primary Key Fields and "normal" Fields.
    ''
    '' Parameter: 
    ''      none
    ''
    '' return value:
    ''      none
    ''
    ''----------------------------------------------------------------------
    Private Sub AnalyzeTable()

        Dim fld
        Dim rsTemp
        Set rsTemp = Server.CreateObject("ADODB.Recordset")
        rsTemp.Open "[" & m_sTable & "]", m_DB, adOpenStatic, adLockReadOnly, adCmdTable

        for each fld in rsTemp.fields
            if m_bAutoPKDetection then
                ' check if field is in schema marked as primary key
                if IsPrimaryKey_inDBSchema(fld.name) then
                    if Not(IsKnownPrimaryKey(fld.name)) then 
                        AddPrimaryKeyField fld.name, fld.type
                    end if
                ' treat field as primary key field if the following flags are set:
                ' -> (KeyColumn) OR (Fixed and ((not Updateable) and (not UnknownUpdateable)))
                elseif ((fld.attributes and adFldKeyColumn) <> 0) or _
                    ( _
                    ((fld.attributes and adFldFixed) <> 0) and _
                    ( _
                        ((fld.attributes and adFldUpdatable) = 0) and _
                        ((fld.attributes and adFldUnknownUpdatable) = 0)) _
                    ) then
                    if Not(IsKnownPrimaryKey(fld.name)) then 
                        AddPrimaryKeyField fld.name, fld.type
                    end if
                ' this is no primary key field
                else
                    if Not(IsKnownPrimaryKey(fld.name)) then 
                        AddStandardField fld.name, fld.type
                    end if
                end if
            else
                ' the primary keys have been set via URL
                if IsKnownPrimaryKey(fld.name) then 
                    ' we need to set the type since we only got the name from the URL
                    SetPrimaryKeyFieldType fld.name, fld.type
                else
                    AddStandardField fld.name, fld.type
                end if
            end if
        next

        rsTemp.Close
        Set rsTemp = Nothing

        ' sort fields (ascending) in array if wanted
        if m_bSortFields then
            SortFields m_PrimaryKeyFields, m_PrimaryKeyTypes
            SortFields m_StandardFields, m_StandardTypes
        end if

    End Sub


    ''----------------------------------------------------------------------
    '' Name:     getPoweredBy
    ''           ============
    '' 
    '' Returns HTML code for "powered by UTE"
    ''
    '' Parameter: 
    ''      none
    ''
    '' return value:
    ''      string
    ''
    ''----------------------------------------------------------------------
    Private Function getPoweredBy ()
        Dim sReturn
        sReturn = _
            "<a href=""" & sUTELink & """ target=""_blank"" class=""ute_link"" " & _
            "title=""" & sUTELink & """>" & sUTELongName & "</a>"
        sReturn = Replace(STR_POWERED_BY, "%1", sReturn)
        sReturn = Replace(sReturn,        "%2", sUTEVersion)
        getPoweredBy = "<div class=""ute_powered_by"">" & sReturn & "</div>"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -