Private Sub txtPass_KeyPress(KeyAscii As Integer)
'if user press RETURN,then call cmdOk
If KeyAscii = KEY_RETURN Then
Call cmdOk_Click
End If
End Sub
Private Sub Command1_Click()
End Sub
Private Sub cmdExit_Click()
Unload Me
End
End Sub
Private Sub cmdOk_Click()
Dim myDB As Database
Dim MyTable, myTABLE1 As Recordset
Dim Criteria As String
Dim PassWord As String
Dim UserName As String
Dim LNUM As Integer
SetMousePtr (gMOUSE_BUSY%)
Set myDB = Workspaces(0).OpenDatabase("c:\xue\BSM\pw.MDB")
Set MyTable = myDB.OpenRecordset("ACCOUNT", dbOpenDynaset)
Set myTABLE1 = myDB.OpenRecordset("TMP", dbOpenDynaset)
UserName = UCase(txtUserName.Text)
PassWord = UCase(txtPassWord.Text)
gI = gI + 1
Criteria = "[USERNAME]='" & UserName & "' AND [PASSWORD]='" & PassWord & "'"
MyTable.FindFirst Criteria
If MyTable.NoMatch Then
If gI = 3 Then
MsgBox "您输入的口令已三次不正确"
MyTable.Close
myTABLE1.Close
myDB.Close
Unload Me
SetMousePtr (gMOUSE_DEFAULT%)
End
End If
MsgBox "口令不正确, 请重新输入!"
txtPassWord.Text = ""
txtPassWord.SetFocus
SetMousePtr (gMOUSE_DEFAULT%)
Exit Sub
Else
gUser = MyTable("GRADE")
gName = MyTable("NAME")
Criteria = ""
Criteria = "[MODIDB] = TRUE"
myTABLE1.FindFirst Criteria
If Not myTABLE1.NoMatch And UCase(UserName) <> "ADMIN" Then
MsgBox "您输入的口令正确, 但系统正在维护数据库,请稍候再使用!"
MyTable.Close
myTABLE1.Close
myDB.Close
Unload Me
SetMousePtr (gMOUSE_DEFAULT%)
End
ElseIf Not myTABLE1.NoMatch And UCase(UserName) = "ADMIN" Then
MsgBox "您输入的口令正确, 计算机显示有人在维护数据库"
End If
Criteria = ""
Criteria = "([NUMINET])<>0"
myTABLE1.FindFirst Criteria
If myTABLE1.NoMatch Then
myTABLE1.AddNew
myTABLE1("NUMINET") = 1
myTABLE1.Update
Else
LNUM = myTABLE1("NUMINET")
myTABLE1.Edit
myTABLE1("NUMINET") = LNUM + 1
myTABLE1.Update
End If
myTABLE1.Close
MyTable.Close
myDB.Close
Unload Me
frmMain.Show
SetMousePtr (gMOUSE_DEFAULT%)
End If
End Sub
Private Sub Form_Load()
Top = Screen.height / 2 - height / 2
Left = Screen.Width / 2 - Width / 2
gI = 0
End Sub
Private Sub txtPassWord_KeyPress(KeyAscii As Integer)
If KeyAscii = KEY_RETURN Then
Call cmdOk_Click
End If
End Sub