Dim userDB As Database
Dim userRD As Recordset
Dim dbName As String
Dim STRSQL As String
Screen.MousePointer = 11
On Error GoTo errEnd
dbName = App.Path
If Right(dbName, 1) <> "\" Then dbName = dbName + "\"
dbName = dbName + "DataBase\WFSSDataBase.mdb"
STRSQL = "select [用户身份] from [Admin] where [用户ID]=""" & userID & """ and [用户密码]=""" & passwd & """"
'打开数据库
Set userDB = DBEngine.Workspaces(0).OpenDatabase(dbName, False, True)
'检索用户,验证密码
Set userRD = userDB.OpenRecordset(STRSQL, dbOpenSnapshot)
If userRD.RecordCount > 0 Then
'设置用户身份
UserShenFen = userRD![用户身份]
'关闭数据库
userRD.Close
Set userRD = Nothing
userDB.Close
Set userDB = Nothing
'进入用户环境
Load FrmMain
FrmMain.Show
Unload FrmLogIn
logOK = True
userName = userID
Screen.MousePointer = vbDefault
Else
'关闭数据库
userRD.Close
Set userRD = Nothing
userDB.Close
Set userDB = Nothing
logOK = False
Screen.MousePointer = vbDefault
MsgBox "用户名或密码错误!请重新输入!", vbOKOnly + vbExclamation, "登陆失败"
End If
Exit Sub
errEnd:
Screen.MousePointer = vbDefault
MsgBox Err.Description, vbOKOnly + vbExclamation, "登陆错误"
logOK = False
Err.Clear
'关闭数据库
userRD.Close
Set userRD = Nothing
userDB.Close
Set userDB = Nothing
Exit Sub
End Sub
模块名:LogOff
模块原型:Public Sub LogOff()
代码:
Public Sub LogOff()
Dim retVal As Integer
retVal = MsgBox("你确定要注销吗?", vbOKCancel + vbQuestion, "注销当前用户")
If retVal = vbCancel Then Exit Sub
Load FrmLogIn
FrmLogIn.Show
If UserShenFen = "经理" Then
Unload FrmAdminMain
ElseIf UserShenFen = "仓库管理员" Then
Unload FrmCangGuanMain
ElseIf UserShenFen = "售书员" Then
Unload FrmBookSellerMain
ElseIf UserShenFen = "会员" Then
Unload FrmMemberMain
Else
Unload FrmGuestMain
End If
Unload FrmMain
UserShenFen = ""
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>