?? frmlogin.frm
字號(hào):
VERSION 5.00
Begin VB.Form frmLogin
BorderStyle = 3 'Fixed Dialog
Caption = "登錄對(duì)話框"
ClientHeight = 2595
ClientLeft = 2835
ClientTop = 3480
ClientWidth = 4170
Icon = "frmLogin.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1533.212
ScaleMode = 0 'User
ScaleWidth = 3915.404
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消"
Height = 390
Left = 2400
TabIndex = 5
Top = 1800
Width = 1140
End
Begin VB.CommandButton cmdOK
Caption = "確定"
Default = -1 'True
Height = 390
Left = 480
TabIndex = 4
Top = 1800
Width = 1140
End
Begin VB.TextBox txtUserName
DataField = "username"
DataSource = "Adodc1"
Height = 345
Left = 1290
TabIndex = 1
Top = 135
Width = 2325
End
Begin VB.TextBox txtPassword
DataField = "pass"
DataSource = "Adodc1"
Height = 345
IMEMode = 3 'DISABLE
Left = 1290
PasswordChar = "*"
TabIndex = 3
Top = 840
Width = 2325
End
Begin VB.Label lblLabels
Caption = "用戶名稱(&U):"
Height = 270
Index = 0
Left = 105
TabIndex = 0
Top = 150
Width = 1080
End
Begin VB.Label lblLabels
Caption = "密 碼(&P):"
Height = 270
Index = 1
Left = 105
TabIndex = 2
Top = 900
Width = 1080
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL As String
Private Sub cmdCancel_Click()
Dim selevalue As Integer
Dim buttons1 As Integer
buttons1 = vbYesNo + vbQuestion
selevalue = MsgBox("您確認(rèn)要退出管理系統(tǒng)嗎?", buttons1, "退出系統(tǒng)")
Select Case selevalue
Case vbNo
Case vbYes
Unload Me
End Select
End Sub
Private Sub cmdOK_Click()
Dim user As String, pwd As String
user = Trim(txtUserName)
pwd = Trim(txtPassword)
'Set rs = DataEn.rsuser1
strSQL = "select * from user1 where username='" & user & "' and pass='" & pwd & "'"
On Error Resume Next
'查詢DataEnv.rsuser1的狀態(tài),如果已經(jīng)打開(kāi),則先關(guān)閉
If rs.State = adStateOpen Then rs.Close
rs.Open strSQL, cn, 1, 3
'If rs.State = 1 Then
'MsgBox "記錄已經(jīng)打開(kāi)!"
' Else
' MsgBox "已經(jīng)關(guān)閉!"
' End If
Static nTryCount As Integer
If rs.EOF Then '登錄失敗
MsgBox "對(duì)不起,無(wú)此用戶或者密碼不正確!請(qǐng)重新輸入!!", vbCritical, "錯(cuò)誤"
txtUserName.SetFocus
txtUserName.SelStart = 0
txtUserName.SelLength = Len(txtUserName)
nTryCount = nTryCount + 1
If nTryCount >= 3 Then
MsgBox "您無(wú)權(quán)操作本系統(tǒng)!", vbCritical, "錯(cuò)誤"
Unload Me
End If
Else '登陸成功
'顯示MDI窗體, 并將用戶類型和用戶名傳到MDI窗體中的mnUserType, msUserName中
Load Formmain
Formmain.Show
Unload Me
End If
DataEn.rsuser1.Close
End Sub
Private Sub Form_Load()
'根據(jù)目錄所在的位置,改變ADO所使用的的連接字符串
Dim strConn As String
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Password=;Data Source="
'使用相對(duì)路徑
strConn = strConn & App.Path & "\database\manager.mdb" & ";Persist Security Info=True"
cn.ConnectionString = strConn
cn.Open
'判斷是否連接成功!
'If cn.State = 1 Then
'MsgBox "數(shù)據(jù)庫(kù)連接成功!"
'Else
'MsgBox "連接失敗!"
'End If
End Sub
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -