📄 frmlogin.frm
字号:
VERSION 5.00
Begin VB.Form frmLogin
BorderStyle = 3 'Fixed Dialog
Caption = "登录"
ClientHeight = 2160
ClientLeft = 2835
ClientTop = 3480
ClientWidth = 3855
LinkTopic = "Form1"
MinButton = 0 'False
Picture = "frmLogin.frx":0000
ScaleHeight = 1276.198
ScaleMode = 0 'User
ScaleWidth = 3619.636
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox txtUser
Height = 345
Left = 1290
TabIndex = 1
Top = 135
Width = 2325
End
Begin VB.TextBox txtPassword
Height = 345
IMEMode = 3 'DISABLE
Left = 1290
PasswordChar = "*"
TabIndex = 3
Top = 525
Width = 2325
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "确定"
ForeColor = &H80000018&
Height = 255
Left = 840
TabIndex = 4
Top = 1680
Width = 495
End
Begin VB.Image ImageCancel
Height = 855
Left = 2280
Picture = "frmLogin.frx":15603
Top = 1200
Width = 810
End
Begin VB.Image ImageOK
Height = 345
Left = 600
Picture = "frmLogin.frx":17AC9
Top = 1200
Width = 945
End
Begin VB.Label lblLabels
BackColor = &H80000005&
BackStyle = 0 'Transparent
Caption = "管理员ID(&U):"
ForeColor = &H8000000E&
Height = 270
Index = 0
Left = 120
TabIndex = 0
Top = 120
Width = 1080
End
Begin VB.Label lblLabels
BackStyle = 0 'Transparent
Caption = "密码(&P):"
ForeColor = &H8000000E&
Height = 270
Index = 1
Left = 120
TabIndex = 2
Top = 540
Width = 1080
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim cnt As Integer
Public LoginSucceeded As Boolean
Private Sub Form_Load()
Dim connectionstring As String
connectionstring = "provider=Microsoft.Jet.oledb.4.0;" & _
"data source=图书馆查询管理系统.mdb"
conn.Open connectionstring
cnt = 0
End Sub
Private Sub ImageCancel_Click()
'设置全局变量为 false
'不提示失败的登录
LoginSucceeded = False
Me.Hide
If MsgBox("确定退出本系统吗?", vbQuestion + vbYesNo, "退出系统") = vbYes Then
Me.Hide
Else
Me.Show
End If
End Sub
Private Sub ImageOK_Click()
Dim sql As String
Dim rs_login As New ADODB.Recordset
If Trim(txtUser.Text) = "" Then '判断输入的用户名是否为空
MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
txtUser.SetFocus
Else
sql = "select * from pass where 名称='" & txtUser.Text & "'"
rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_login.EOF = True Then
MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
txtUser.SetFocus
Else '检验密码是否正确
If Trim(rs_login.Fields("密码")) = Trim(txtPassword.Text) Then
userID = txtUser.Text
userpow = rs_login.Fields("权限")
strstatus = rs_login.Fields("权限")
rs_login.Close
Unload Me
Form1.Show
Else
MsgBox "密码不正确", vbOKOnly + vbExclamation, ""
txtPassword.SetFocus
End If
End If
End If
cnt = cnt + 1
If cnt = 3 Then
Unload Me
End If
Exit Sub
Me.Hide
Form1.Show
End Sub
Private Sub txtuser_Change()
txtPassword = ""
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -