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

📄 loginuser.cls

📁 Visual Basic管理信息系统开发 学生考试系统(源代码)
💻 CLS
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "LoginUser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Description = "这个类代表了登录的用户"
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"

Private mvarUserName As String
Private mvarLogTime As Date
Private mvarUserPassword As String
Private mvarUserType As LogType
Private mvarLogFail As Boolean
'定义UserType属性的设置方法
Public Property Let UserType(ByVal vData As LogType)
    mvarUserType = vData
End Property

'定义UserType属性的读取方法
Public Property Get UserType() As LogType
    UserType = mvarUserType
End Property
'定义UserPassword属性的设置方法
Public Property Let UserPassword(ByVal vData As String)
    mvarUserPassword = vData
End Property

'定义UserPassword属性的读取方法
Public Property Get UserPassword() As String
    UserPassword = mvarUserPassword
End Property
'定义LogTime属性的设置方法
Public Property Let LogTime(ByVal vData As Date)
    mvarLogTime = vData
End Property
'定义LogTime属性的读取方法
Public Property Get LogTime() As Date
    LogTime = mvarLogTime
End Property
'定义UserName属性的设置方法
Public Property Let UserName(ByVal vData As String)
    mvarUserName = vData
End Property
'定义UserName属性的读取方法
Public Property Get UserName() As String
Attribute UserName.VB_UserMemId = 0
    UserName = mvarUserName
End Property
'定义LogFail属性的设置方法
Public Property Let LogFail(ByVal vData As Boolean)
    mvarLogFail = vData
End Property
'定义LogFail属性的读取方法
Public Property Get LogFail() As Boolean
    LogFail = mvarLogFail
End Property

Public Function Log(ByVal uName As String, ByVal uPass As String, ByVal uType As LogType) As Boolean
    'Log方法的各参数分别是用户所输入的姓名、口令以及用户的类型
    Dim SQLstring As String
    If uName = "" Then    '如果用户名为空则登录失败
        LogFail = True
        Log = LogFail
        Exit Function
    End If
    If uPass = "" Then    '如果用户口令为空则登录失败
        LogFail = True
        Log = LogFail
        Exit Function
    End If
    If uType <> student And uType <> teacher And uType <> administrator Then
    '如果用户类型不是枚举值中的一个,则登录失败。
        LogFail = True
        Log = LogFail
        Exit Function
    End If
    '根据不同的用户类型验证不同的数据集对象
    Select Case uType
       Case student
            '用户类型为学生,验证由命令对象StuTable创建的数据集rsStuTable
            DataEnv.rsStuTable.Open
            DataEnv.rsStuTable.Filter = "studentName = '" & uName & "' And studentPassword = '" & uPass & "'"
            If DataEnv.rsStuTable.RecordCount > 0 Then
              LogFail = False
            End If
            DataEnv.rsStuTable.Filter = ""
            DataEnv.rsStuTable.Close
       Case teacher
            '用户类型为教师,验证由命令对象TchTable创建的数据集rsTchTable
            DataEnv.rsTchTable.Open
            DataEnv.rsTchTable.Filter = "TeacherName = '" & uName & "' And TeacherPassword = '" & uPass & "'"
            If DataEnv.rsTchTable.RecordCount > 0 Then
              LogFail = False
            End If
            DataEnv.rsTchTable.Filter = ""
            DataEnv.rsTchTable.Close
        Case administrator
            '用户类型为管理员,验证由命令对象AdmTable创建的数据集rsAdmTable
            DataEnv.rsAdmTable.Open
            DataEnv.rsAdmTable.Filter = "AdministratorName = '" & uName & "' And AdministratorPassword = '" & uPass & "'"
            If DataEnv.rsAdmTable.RecordCount > 0 Then
              LogFail = False
            End If
            DataEnv.rsAdmTable.Filter = ""
            DataEnv.rsAdmTable.Close
    End Select
    UserName = uName
    UserPassword = uPass
    UserType = uType

End Function



⌨️ 快捷键说明

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