?? f重新登錄.frm
字號:
VERSION 5.00
Begin VB.Form F重新登錄
Caption = "重新登錄"
ClientHeight = 2100
ClientLeft = 60
ClientTop = 450
ClientWidth = 3900
LinkTopic = "Form1"
ScaleHeight = 2100
ScaleWidth = 3900
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame1
Caption = "登錄信息"
Height = 2055
Left = 0
TabIndex = 0
Top = 0
Width = 3855
Begin VB.CommandButton CmdCancel
BackColor = &H00C0C0C0&
Caption = "退出(&Q)"
Height = 360
Left = 2040
Style = 1 'Graphical
TabIndex = 6
Top = 1560
Width = 800
End
Begin VB.CommandButton CmdOk
BackColor = &H00C0C0C0&
Caption = "確定(&O)"
Height = 360
Left = 960
Style = 1 'Graphical
TabIndex = 5
Top = 1560
Width = 800
End
Begin VB.ComboBox CboName
Height = 315
Left = 1455
TabIndex = 2
Text = "administrator"
Top = 360
Width = 1920
End
Begin VB.TextBox txtPassword
Height = 345
IMEMode = 3 'DISABLE
Left = 1455
PasswordChar = "*"
TabIndex = 1
Top = 840
Width = 1845
End
Begin VB.Label lblLabels
Caption = "用戶名稱(&U):"
Height = 270
Index = 0
Left = 360
TabIndex = 4
Top = 390
Width = 1080
End
Begin VB.Label lblLabels
Caption = "密碼(&P):"
Height = 270
Index = 1
Left = 360
TabIndex = 3
Top = 840
Width = 1080
End
End
End
Attribute VB_Name = "F重新登錄"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim SQL As String
Dim msg As String
Private Sub Form_Load()
Dim rst As ADODB.Recordset
Dim strItem As String
'初始化ComboBox
SQL = " select 用戶ID,用戶名稱 from 用戶信息表 order by 用戶ID"
Set rst = SelectSQL(SQL, msg)
If rst.RecordCount > 0 Then
Do While Not rst.EOF
'添加到ComboBox列表
strItem = rst.Fields(0) & " " & rst.Fields(1)
CboName.AddItem (strItem)
rst.MoveNext '指向下一條記錄
Loop
rst.Close
CboName.ListIndex = 0 '默認ComboBox
Else
MsgBox ("請先創建用戶信息!")
CmdOK.Enabled = False
Exit Sub
End If
End Sub
Private Sub CmdOK_Click()
Dim rst As ADODB.Recordset
Dim password As String
'判斷用戶是否存在
UserID = Left(Trim(CboName.Text), 10) '取出用戶的ID
SQL = " select 用戶ID,密碼 from 用戶信息表 where 用戶ID='" & UserID & "'"
Set rst = SelectSQL(SQL, msg)
If rst.RecordCount > 0 Then '如果存在這個用戶
password = Trim(rst.Fields(1)) '取出該用戶的密碼
rst.Close
Else
MsgBox ("數據庫操作錯誤!")
Exit Sub
End If
'判斷密碼是否正確
If password = Trim(txtPassword.Text) Then
LoginSucceeded = True
人事管理系統.Show
Unload Me
Else
MsgBox ("密碼錯誤!")
LoginSucceeded = False
End If
End Sub
Private Sub cmdCancel_Click()
'設置全局變量為 false
'不提示失敗的登錄
LoginSucceeded = False
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
LoginSucceeded = False
Unload Me
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -