Private Sub cmdOK_Click()
'检查正确的密码
Set db = New Connection
Set mRs = New Recordset
If db.State = adStateOpen Then db.Close
db.CursorLocation = adUseClient
db.Open "Provider=SQLOLEDB.1;Password=helloworld;Persist Security Info=True;User ID=sa;Initial Catalog=ncoa;Data Source=lly"
If mRs.State = adStateOpen Then mRs.Close
mRs.CursorLocation = adUseClient
mRs.Open "select * from usertable where abname='" & txtUserName.Text & "'", db, adOpenStatic, adLockReadOnly
If mRs.RecordCount < 1 Then
MsgBox "无效的用户名,请重试!", , "登录"
txtPassword.Text = ""
txtUserName.SetFocus
SendKeys "{home}+{end}"
Else
If txtPassword = mRs!abPassword Then
'=========login success process
LoginSucceeded = True
CurrentUserName = txtUserName
CurrentUserLevel = mRs!ablevel
frmMain.mlogin.Enabled = False
frmMain.mlogout.Enabled = True
Select Case CurrentUserLevel
Case 2
frmMain.mAccount.Visible = True
frmMain.mStockManage.Visible = True
Case 0
frmMain.mStockManage.Visible = True
Case Else
End Select
mRs.Close
db.Close
frmMain.Show
Me.Hide
Else
MsgBox "无效的密码,请重试!", , "登录"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
End If
If mRs.State = adStateOpen Then mRs.Close
If db.State = adStateOpen Then db.Close
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
End