www.pudn.com > stu_rag.rar > LoginUser.cls, change:2003-03-30,size:3391b


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 
Public Property Let UserType(ByVal vData As LogType) 
    mvarUserType = vData 
End Property 
 
 
Public Property Get UserType() As LogType 
    UserType = mvarUserType 
End Property 
 
Public Property Let UserPassword(ByVal vData As String) 
    mvarUserPassword = vData 
End Property 
 
 
Public Property Get UserPassword() As String 
    UserPassword = mvarUserPassword 
End Property 
 
Public Property Let LogTime(ByVal vData As Date) 
    mvarLogTime = vData 
End Property 
 
Public Property Get LogTime() As Date 
    LogTime = mvarLogTime 
End Property 
 
Public Property Let UserName(ByVal vData As String) 
    mvarUserName = vData 
End Property 
 
Public Property Get UserName() As String 
Attribute UserName.VB_UserMemId = 0 
    UserName = mvarUserName 
End Property 
 
Public Property Let LogFail(ByVal vData As Boolean) 
    mvarLogFail = vData 
End Property 
 
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 
    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 
            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 
            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 
            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