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

📄 mdlvar.bas

📁 Visual Basic开发实用编程200例 数据库编程实例
💻 BAS
字号:
Attribute VB_Name = "mdlVar"
'声明全局变量
Public g_CurUserID As Long
Public g_bLogin As Boolean
Public g_bAdmin As Boolean
Public g_bStudent As Boolean

'查找用户
Public Function IsExistUser(strUserName As String, strpwd As String) As Boolean
    Dim cmd As Command
    Dim rs As Recordset
    
    Set cmd = New Command
    '打开连接
    If DataE.conLibrary.State = adStateClosed Then
        DataE.conLibrary.Open
    End If
    cmd.ActiveConnection = DataE.conLibrary
    
    '注册
    cmd.CommandText = "select * from usertable where username='" & strUserName & "'"
    If strpwd <> "" Then
    '登录
        cmd.CommandText = cmd.CommandText + "and pwd='" & strpwd & " '"
    End If
    '有无重复
    Set rs = cmd.Execute
    If rs.RecordCount <> 0 Then
        IsExistUser = True
        If g_bLogin Then
            g_CurUserID = rs!userid
            '为管理员
            If rs!Usertype = Manager Then
                g_bAdmin = True
            End If
            If CurUserID = Student Then
                g_bStudent = True
            End If
        End If
    Else
        IsExistUser = False
    End If
End Function

'查找某特定学生
Public Function IsExistStudent(strStudentname As String, intIndex As Integer) As Boolean
    '打开连接
    DataE.conLibrary.Close
    DataE.conLibrary.Open
    DataE.cmdRegStudent strStudentname, intIndex
    If DataE.rscmdRegStudent.RecordCount <> 0 Then
        IsExistStudent = True
    Else
        IsExistStudent = False
    End If
    
End Function

Public Sub CloseWin()
    Dim frm As Form
    On Error GoTo wrong
    Set frm = mdiFrm.ActiveForm
    Unload frm
wrong:
    Exit Sub
End Sub

⌨️ 快捷键说明

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