?? frmlogin.frm
字號:
VERSION 5.00
Begin VB.Form frmLogin
BorderStyle = 3 'Fixed Dialog
Caption = "登錄"
ClientHeight = 4545
ClientLeft = 2835
ClientTop = 3480
ClientWidth = 7395
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
Picture = "frmLogin.frx":0000
ScaleHeight = 2685.336
ScaleMode = 0 'User
ScaleWidth = 6943.504
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.ComboBox cmbType
Height = 360
ItemData = "frmLogin.frx":5E98
Left = 3195
List = "frmLogin.frx":5E9A
Style = 2 'Dropdown List
TabIndex = 6
Top = 2160
Width = 1935
End
Begin VB.TextBox txtUserName
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 345
Left = 3240
TabIndex = 1
Top = 960
Width = 2325
End
Begin VB.CommandButton cmdOK
Caption = "確定"
Default = -1 'True
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2280
Picture = "frmLogin.frx":5E9C
Style = 1 'Graphical
TabIndex = 4
Top = 3360
Width = 1140
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消"
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 390
Left = 3960
Picture = "frmLogin.frx":1CC08
Style = 1 'Graphical
TabIndex = 5
Top = 3360
Width = 1140
End
Begin VB.TextBox txtPassword
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 345
IMEMode = 3 'DISABLE
Left = 3210
PasswordChar = "*"
TabIndex = 3
Top = 1605
Width = 2325
End
Begin VB.Label Label3
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "身 份:"
Height = 240
Left = 1560
TabIndex = 7
Top = 2160
Width = 1035
End
Begin VB.Label lblLabels
BackColor = &H00C0C000&
BackStyle = 0 'Transparent
Caption = "用戶名稱(&U):"
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 0
Left = 1680
TabIndex = 0
Top = 960
Width = 1440
End
Begin VB.Label lblLabels
BackColor = &H00C0C000&
BackStyle = 0 'Transparent
Caption = "密碼(&P):"
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 1
Left = 1680
TabIndex = 2
Top = 1560
Width = 1440
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Const MaxLogTimes As Integer = 3 '定義允許嘗試登錄的最大次數
Private Sub cmdCancel_Click()
If MsgBox("你選擇了退出系統登錄,退出將不能啟動管理系統!" & vbCrLf _
& "是否真的退出?", vbYesNo + vbQuestion, "登錄驗證") = vbYes Then
Unload Me '卸載登錄窗體
End If
End Sub
Private Sub cmdOk_Click()
Dim objCn As Connection, objRs As Recordset, strSQL$
If Trim(txtusername) = "" Then '檢驗是否輸入用戶名
MsgBox "請輸入用戶名!", vbExclamation, "登錄驗證"
txtusername = ""
txtusername.SetFocus
Exit Sub
End If
If Trim(txtpassword) = "" Then '檢驗是否輸入登錄口令
MsgBox "請輸入登錄口令!", vbExclamation, "登錄驗證"
txtpassword = ""
txtpassword.SetFocus
Exit Sub
End If
'靜態常量intLogTimes用于保存用戶請求驗證的次數
Static intLogTimes As Integer
intLogTimes = intLogTimes + 1 '保存當前登錄次數
If intLogTimes > MaxLogTimes Then
'超過允許的登錄次數,顯示提示信息
MsgBox "你已經超過允許的登錄驗證次數!" & vbCr _
& "應用程序將結束!", vbCritical, "登錄驗證"
End '結束應用程序
End If
'輸入合法,進一步檢驗正確性
'創建與數據庫的聯接
Set objCn = New Connection '實例化聯接對象
With objCn '建立數據庫聯接
.Provider = "SQLOLEDB"
.ConnectionString = "User ID=sa;PWD=;Data Source=(local);" & _
"Initial Catalog=datatushu"
.Open
End With
'根據用戶身份創建SQL Select命令
Dim objLog As New Recordset
Select Case cmbType
Case "1"
strSQL = "select 密碼 as 密碼 from 管理者信息 where 權限=1"
Case "2"
strSQL = "select 密碼 as 密碼 from 管理者信息 where 權限=2"
Case "3"
strSQL = "select 密碼 as 密碼 from 管理者信息 where 權限=3"
End Select
'執行查詢獲得用戶登陸密碼
Set objRs = New Recordset
With objRs
Set .ActiveConnection = objCn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open strSQL
If .RecordCount < 1 Then
MsgBox "用戶名輸入錯誤!", vbCritical, "登錄驗證"
txtusername.SetFocus
txtusername.SelStart = 0
txtusername.SelLength = Len(txtusername)
Else
If txtpassword.Text = "" Then
MsgBox "口令錯誤,請重新輸入!", vbCritical, "登錄驗證"
txtpassword.SetFocus
txtpassword = ""
Else
'保存當前用戶信息
CurrentUserName = Trim(txtusername)
CurrentUserPassword = Trim(txtpassword)
CurrentUserType = cmbType
'顯示登錄成功信息
MsgBox "歡迎使用圖書管理系統!", vbInformation, "登錄成功"
Unload Me '關閉登錄窗體
zhuye.Show '顯示系統主窗體
End If
End If
End With
objCn.Close '關閉數據庫連接
Set objCn = Nothing '釋放數據庫連接
Set objRs = Nothing
End Sub
Private Sub Form_Load()
'清空用戶名和口令文本框
txtusername = ""
txtpassword = ""
'創建身份列表
cmbType.AddItem "1"
cmbType.AddItem "2"
cmbType.AddItem "3"
cmbType.ListIndex = 0
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -