当前位置: 源码素材网 » VB教程 » 详情页

包括了数据库连接和用户权限控制的VB数据库操作类

  •   时间:2018-12-31
  • 概述:数据库连接类

这个类中包括了数据库连接的ADODB,判断用户权限、判断用户资料在登陆以后是否修改过等操作,下面来看代码:

Attribute VB_Name = "DIMModule"
Option Explicit
'数据库连接的ADODB
Public ADOconn As New ADODB.Connection
Public ADOrs As New ADODB.Recordset
Public strsql() As String            'SQL命令
Public strConn As String           '连接字符串
Public strcomputername As String  '服务器名称
'------------------------------------------------------
'用来判断用户权限,1 表示管理员,2 表示教师,3表示游客,0表示现在还没登陆
Public intpowervalue As Integer
'用来判断用户资料在登陆以后是否修改过 0表示没修改过
Public intupdatetime As Integer
'定义一个消息的变量Messagevalue
Public Intmessagevalue As Integer
'定义一个变量Inttable 其中1表示使用frm_adminupdatemanage窗体,2表示使用frm_teachermanage窗体,3表示使用frm_coursemanage窗体
Public Inttable As Integer
'-----------------------------------------------------
'用于记录用户登陆的资料
Public Str_log(7) As String
Public Const Strmsg1 As String = "提示"
Public Const Strmsg2 As String = "警告"
'*****************************************************************************************************************************
'获得计算机名称的API函数
Public Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
'****************************************************************************************************************************
'利用Api函数计算Windows从启动后所运行的总时间
Public Declare Function GetTickCount Lib "kernel32" () As Long
'****************************************************************************************************************************
'设计联机帮助的htmlhelp api 通用函数
'***************************************************************************************************
Const HH_DISPLAY_TOPIC = &H0
Const HH_DISPLAY_INDEX = &H2
Const HH_HELP_CONTEXT = &HF
Const HH_DISPLAY_SEARCH = &H3
Const HH_DISPLAY_TEXT_POPUP = &HE
Declare Function Htmlhelp Lib "hhctrl.ocx" Alias "HtmlHelpA" (ByVal hwndCaller As Long, ByVal pszFile As String, ByVal uCommand As Long, ByVal dwData As Any) As Long
'***************************************************************************************************
'使窗口在显示和关闭时出现动态效果
Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type
Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Declare Function SetBkColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
Declare Function Rectangle Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Declare Function SelectObject Lib "user32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
'动态关闭窗体
Public Sub ImplodeForm(f As Form, Direction As Integer, Movement As Integer, ModalState As Integer)
    Dim myRect As RECT
    Dim formWidth%, formHeight%, i%, X%, Y%, Cx%, Cy%
    Dim TheScreen As Long
    Dim Brush As Long
    GetWindowRect f.hwnd, myRect
    formWidth = (myRect.Right - myRect.Left)
    formHeight = myRect.Bottom - myRect.Top
    TheScreen = GetDC(0)
    Brush = CreateSolidBrush(f.BackColor)
    For i = Movement To 1 Step -1
        Cx = formWidth * (i / Movement)
        Cy = formHeight * (i / Movement)
        X = myRect.Left + (formWidth - Cx) / 2
        Y = myRect.Top + (formHeight - Cy) / 2
        Rectangle TheScreen, X, Y, X + Cx, Y + Cy
    Next i
    X = ReleaseDC(0, TheScreen)
    DeleteObject (Brush)
End Sub
'动态打开窗体
Public Sub ExplodeForm(f As Form, Movement As Integer)
    Dim myRect As RECT
    Dim formWidth%, formHeight%, i%, X%, Y%, Cx%, Cy%
    Dim TheScreen As Long
    Dim Brush As Long
    GetWindowRect f.hwnd, myRect
    formWidth = (myRect.Right - myRect.Left)
    formHeight = myRect.Bottom - myRect.Top
    TheScreen = GetDC(0)
    Brush = CreateSolidBrush(f.BackColor)
    For i = 1 To Movement
        Cx = formWidth * (i / Movement)
        Cy = formHeight * (i / Movement)
        X = myRect.Left + (formWidth - Cx) / 2
        Y = myRect.Top + (formHeight - Cy) / 2
        Rectangle TheScreen, X, Y, X + Cx, Y + Cy
    Next i
    X = ReleaseDC(0, TheScreen)
    DeleteObject (Brush)
End Sub

    相关声明:

      若“包括了数据库连接和用户权限控制的VB数据库操作类”有损您的权益,请告之我们删除内容。
      部分文章来源于网络,版权归原作者所有。