📄 frmlogin.frm
字号:
VERSION 5.00
Begin VB.Form frmLogin
BorderStyle = 1 'Fixed Single
Caption = "停车收费记录系统"
ClientHeight = 3570
ClientLeft = 45
ClientTop = 330
ClientWidth = 5265
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3570
ScaleWidth = 5265
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame1
Height = 3690
Left = 0
TabIndex = 4
Top = -120
Width = 5265
Begin VB.TextBox TextUser
Height = 300
Left = 1545
MaxLength = 50
TabIndex = 0
Text = "Admin"
Top = 1755
Width = 2175
End
Begin VB.TextBox TextPwd
Height = 300
IMEMode = 3 'DISABLE
Left = 1545
MaxLength = 50
PasswordChar = "*"
TabIndex = 1
Text = "Admin"
Top = 2220
Width = 2175
End
Begin VB.CommandButton cmdOK
Caption = "登录(&O)"
Default = -1 'True
Height = 360
Left = 1200
TabIndex = 2
Top = 2850
Width = 1050
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "退出(&E)"
Height = 360
Left = 2445
TabIndex = 3
Top = 2850
Width = 1050
End
Begin VB.PictureBox picBG
Appearance = 0 'Flat
BackColor = &H80000001&
BorderStyle = 0 'None
ForeColor = &H80000008&
Height = 1275
Left = 30
ScaleHeight = 1275
ScaleWidth = 5205
TabIndex = 5
TabStop = 0 'False
Top = 120
Width = 5205
Begin VB.Label lblLogin
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "欢迎使用"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Index = 1
Left = 180
TabIndex = 9
Top = 165
Width = 900
End
Begin VB.Label lblLogin
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "版权所有 (C) 2007-2008 特瑞飞软件"
Height = 180
Index = 2
Left = 2085
TabIndex = 8
Top = 1035
Width = 2970
End
Begin VB.Label lblLogin
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "特瑞飞车辆收费管理系统 演示版"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 285
Index = 3
Left = 600
TabIndex = 6
Top = 510
Width = 4365
End
Begin VB.Label lblLogin
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "特瑞飞车辆收费管理系统 演示版"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 285
Index = 0
Left = 645
TabIndex = 7
Top = 555
Width = 4365
End
End
Begin VB.Label lblLogin
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "用户名"
Height = 180
Index = 4
Left = 900
TabIndex = 12
Top = 1830
Width = 540
End
Begin VB.Label lblLogin
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "登录密码"
Height = 180
Index = 5
Left = 720
TabIndex = 11
Top = 2280
Width = 720
End
Begin VB.Image Image1
Height = 1305
Left = 3855
Picture = "frmLogin.frx":0000
Stretch = -1 'True
Top = 1665
Width = 1050
End
Begin VB.Label lblLogin
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "注:默认登录用户:密码 是 Admin:Admin"
ForeColor = &H00C00000&
Height = 180
Index = 6
Left = 960
TabIndex = 10
Top = 3435
Width = 3240
End
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub CmdCancel_Click() '取消
Unload Me
End Sub
Private Sub CmdOK_Click() '登录
Dim check As New adodb.Recordset '定义Recordset对象
Dim DBstr As String
Dim UsrID As String
Dim UsrPwd As String
'检验用户名和密码
'1.读出数据库中的记录
'2.找到输入的用户名
'3.比较输入的密码是否与数据库中的记录相符
If Len(Trim(Me.TextUser.Text)) <= 0 Then '没有输入用户名
MsgBox "请输入用户名!", , "登陆信息"
Exit Sub
End If
If Len(Trim(Me.TextUser.Text)) > 16 Then '用户名过长
MsgBox "您输入用户名过长!", , "登陆信息"
Exit Sub
End If
UsrID = Replace(Trim(Me.TextUser.Text), "'", "''")
If Len(Trim(Me.TextPwd.Text)) <= 0 Then '没有输入密码
MsgBox "请输入密码!", , "登陆信息"
Exit Sub
End If
If Len(Trim(Me.TextPwd.Text)) > 16 Then '密码过长
MsgBox "您输入密码过长!", , "登陆信息"
Exit Sub
End If
UsrPwd = Trim(Me.TextPwd.Text)
DBstr = "select * from UserInfo where UserID='" & UsrID & "'"
'打开数据集
check.Open DBstr, DBCnn, adOpenStatic, adLockReadOnly, -1
If check.RecordCount <= 0 Then '找不到该用户名
MsgBox "用户名不存在!" & vbCrLf & "请重新输入!", , "登陆信息"
check.Close
Exit Sub
Else
'数据集指针指向第一个记录,这里查找到的记录唯一
check.MoveFirst
'检验密码
If TextPwd = check.Fields("UserPwd").Value Then
UserNow.ID = Trim(Me.TextUser.Text)
UserNow.Type = check.Fields("UserType").Value
Else
MsgBox "密码错误!", , "登陆信息"
check.Close
Exit Sub
End If
'关闭数据集
check.Close
End If
'用户名,密码都正确,进入主窗口
Unload Me
frmMain.Show
End Sub
'文本框获得焦点时选中所有文字
Private Sub TextPwd_GotFocus()
TextPwd.SelStart = 0 '选中文字的起始位置
TextPwd.SelLength = Len(TextPwd) '选中文字的长度
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -