Public Sub Startup() Me.Caption = CST_SYSTEM_TITLE & "登录" txtDBPath.Text = ReadPath Me.Show 1 End SubPrivate Sub cmdCancel_Click() G_IsLogin = False Unload Me End SubPrivate Sub cmdOK_Click()
On Error GoTo ErrHandle:
Dim sSQL As String Dim rs As ADODB.Recordset
'检验数据库文件是否存在 If G_FSO.FileExists(txtDBPath) = False Then MsgBox "没有找到数据库文件,请重新设置数据库路径", vbOKOnly, CST_SYSTEM_TITLE Exit Sub End If If IsFileExist(txtDBPath) = False Then Exit Sub '保存留数据库路径 G_DBPath = txtDBPath.Text WriteFile G_DBPath
G_User = txtUser
If CheckingConn = False Then Exit Sub
'检验用户是否存在 G_IsLogin = IsUserExist(txtUser, txtPWD, G_IsAdv) If G_IsLogin = False Then MsgBox "用户不存在或密码错误!", vbOKOnly, CST_SYSTEM_TITLE Else Unload Me End If Exit Sub ErrHandle: MsgBox Err.Description Err.Clear G_IsLogin = False End SubPrivate Sub cmdSetting_Click() On Error Resume Next '查找数据库路径 With dlgOpen .Filter = "*.mdb|数据库文件;*.*|所有文件" .ShowOpen If .FileName <> "" Then txtDBPath.Text = .FileName End With End SubPrivate Sub txtPWD_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Call cmdOK_Click End SubPrivate Sub txtUser_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Call cmdOK_Click End Sub
Me.Caption = CST_SYSTEM_TITLE & "登录"
txtDBPath.Text = ReadPath
Me.Show 1
End SubPrivate Sub cmdCancel_Click()
G_IsLogin = False
Unload Me
End SubPrivate Sub cmdOK_Click()
On Error GoTo ErrHandle:
Dim sSQL As String
Dim rs As ADODB.Recordset
'检验数据库文件是否存在
If G_FSO.FileExists(txtDBPath) = False Then
MsgBox "没有找到数据库文件,请重新设置数据库路径", vbOKOnly, CST_SYSTEM_TITLE
Exit Sub
End If
If IsFileExist(txtDBPath) = False Then Exit Sub
'保存留数据库路径
G_DBPath = txtDBPath.Text
WriteFile G_DBPath
G_User = txtUser
If CheckingConn = False Then Exit Sub
'检验用户是否存在
G_IsLogin = IsUserExist(txtUser, txtPWD, G_IsAdv)
If G_IsLogin = False Then
MsgBox "用户不存在或密码错误!", vbOKOnly, CST_SYSTEM_TITLE
Else
Unload Me
End If
Exit Sub
ErrHandle:
MsgBox Err.Description
Err.Clear
G_IsLogin = False
End SubPrivate Sub cmdSetting_Click()
On Error Resume Next
'查找数据库路径
With dlgOpen
.Filter = "*.mdb|数据库文件;*.*|所有文件"
.ShowOpen
If .FileName <> "" Then txtDBPath.Text = .FileName
End With
End SubPrivate Sub txtPWD_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Call cmdOK_Click
End SubPrivate Sub txtUser_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Call cmdOK_Click
End Sub
將text1的PasswordChar寫成 *