📄 g登录.frm
字号:
VERSION 5.00
Begin VB.Form G登录
Caption = "登录"
ClientHeight = 2295
ClientLeft = 60
ClientTop = 345
ClientWidth = 3870
LinkTopic = "Form1"
ScaleHeight = 2295
ScaleWidth = 3870
StartUpPosition = 3 'Windows Default
Begin VB.Frame Frame1
Caption = "登录信息"
Height = 2175
Left = 0
TabIndex = 0
Top = 120
Width = 3855
Begin VB.TextBox txtPassword
Height = 345
IMEMode = 3 'DISABLE
Left = 1455
PasswordChar = "*"
TabIndex = 4
Top = 840
Width = 1725
End
Begin VB.CommandButton CmdCancel
Cancel = -1 'True
Caption = "退出"
Height = 390
Left = 2295
TabIndex = 3
Top = 1440
Width = 780
End
Begin VB.CommandButton CmdOk
Caption = "确定"
Default = -1 'True
Height = 390
Left = 1215
TabIndex = 2
Top = 1440
Width = 780
End
Begin VB.ComboBox CboName
Height = 315
Left = 1455
TabIndex = 1
Text = "administrator"
Top = 360
Width = 1815
End
Begin VB.Label lblLabels
Caption = "密码(&P):"
Height = 270
Index = 1
Left = 360
TabIndex = 6
Top = 840
Width = 1080
End
Begin VB.Label lblLabels
Caption = "用户名称(&U):"
Height = 270
Index = 0
Left = 360
TabIndex = 5
Top = 390
Width = 1080
End
End
End
Attribute VB_Name = "G登录"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim msg As String
Private Sub cmdCancel_Click()
'设置全局变量为 false
'不提示失败的登录
LoginSucceeded = False
Unload Me
End Sub
Private Sub CmdOk_Click()
Dim rst As ADODB.Recordset
Dim password As String
'判断密码是否正确
UserID = Left(Trim(CboName.Text), 6)
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 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
strItem = rst.Fields(0) & " " & rst.Fields(1)
CboName.AddItem (strItem)
rst.MoveNext
Loop
rst.Close
CboName.ListIndex = 0
Else
MsgBox ("请先创建用户信息!")
CmdOk.Enabled = False
Exit Sub
End If
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 + -