📄 frmlogin.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "Mscomctl.ocx"
Begin VB.Form frmLogin
BorderStyle = 3 'Fixed Dialog
Caption = "管理员登录"
ClientHeight = 3555
ClientLeft = 45
ClientTop = 330
ClientWidth = 4170
Icon = "frmLogin.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3555
ScaleWidth = 4170
StartUpPosition = 2 '屏幕中心
Begin VB.Timer Timer1
Interval = 500
Left = 1680
Top = 2400
End
Begin MSComctlLib.ImageList ImageList1
Left = 3360
Top = 2280
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 486
ImageHeight = 63
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 9
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmLogin.frx":0442
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmLogin.frx":0A38
Key = ""
EndProperty
BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmLogin.frx":1758
Key = ""
EndProperty
BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmLogin.frx":2B47
Key = ""
EndProperty
BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmLogin.frx":46CE
Key = ""
EndProperty
BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmLogin.frx":6976
Key = ""
EndProperty
BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmLogin.frx":93CC
Key = ""
EndProperty
BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmLogin.frx":C599
Key = ""
EndProperty
BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmLogin.frx":FE49
Key = ""
EndProperty
EndProperty
End
Begin VB.Frame Frame2
Height = 615
Left = 120
TabIndex = 7
Top = 2820
Width = 3975
Begin VB.Label Label3
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
BackStyle = 0 'Transparent
Caption = "提示:系统的""初始用户""的密码为""000"""
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 210
Left = 150
TabIndex = 8
Top = 240
Width = 3675
End
End
Begin VB.Frame Frame1
Height = 2055
Left = 120
TabIndex = 4
Top = 720
Width = 3975
Begin VB.CommandButton Command2
Caption = "取消"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 555
Left = 2190
Style = 1 'Graphical
TabIndex = 2
Top = 1320
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "用户登录"
Default = -1 'True
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 555
Left = 420
Style = 1 'Graphical
TabIndex = 1
Top = 1320
Width = 1335
End
Begin VB.TextBox txtPwd
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 330
IMEMode = 3 'DISABLE
Left = 1200
PasswordChar = "*"
TabIndex = 0
Text = "000"
Top = 840
Width = 2595
End
Begin VB.ComboBox Combo_User
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 330
ItemData = "frmLogin.frx":13F37
Left = 1200
List = "frmLogin.frx":13F39
Style = 2 'Dropdown List
TabIndex = 3
Top = 360
Width = 2595
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "操作密码"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 240
TabIndex = 6
Top = 900
Width = 840
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "操作人员"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 240
TabIndex = 5
Top = 420
Width = 840
End
End
Begin VB.Image Image1
BorderStyle = 1 'Fixed Single
Height = 585
Left = 120
Picture = "frmLogin.frx":13F3B
Stretch = -1 'True
Top = 120
Width = 3930
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 PictureNum As Integer '记录当前图片编号
Private Sub Command1_Click()
Dim rst As New ADODB.Recordset
Dim strsql As String
On Error GoTo ErrorExit '错误处理
Screen.MousePointer = vbHourglass
strsql = "SELECT UserID,Pwd FROM tbl_Login WHERE UserID='" & Combo_User.Text & "'"
rst.Open strsql, CnnDataBase, adOpenStatic, adLockReadOnly '选取静态数据集
If rst.RecordCount = 0 Then '判断此用户是否存在
MsgBox "无此用户!"
Screen.MousePointer = vbDefault
' CnnDataBase.Close '关闭数据库
Me.Combo_User.ListIndex = -1
' Me.txtPwd.Text = ""
Exit Sub
End If
If rst.RecordCount > 1 Then '记录集中记录数不唯一
MsgBox "数据库错误:用户有重复!"
' CnnDataBase.Close '关闭数据库
Screen.MousePointer = vbDefault
Unload Me '关闭系统
Exit Sub
End If
If IsNull(rst.Fields("Pwd").Value) Then '判断用户密码是否正确
If txtPwd.Text <> "" Then
MsgBox "用户密码不正确!"
Screen.MousePointer = vbDefault
' Me.txtPwd.Text = ""
Me.txtPwd.SetFocus
Exit Sub
End If
Else
If txtPwd.Text <> rst.Fields("Pwd").Value Then
MsgBox "用户密码不正确!"
Screen.MousePointer = vbDefault
' Me.txtPwd.Text = ""
Me.txtPwd.SetFocus
Exit Sub
End If
End If
Set rst = Nothing '关闭临时记录集
' frmMain.Caption = frmMain.Caption & " — [ " & Rst.Fields(0).Value & " ]"
Screen.MousePointer = vbDefault
frmMain.Show '显示主窗口
Unload Me '关闭当前窗口
Exit Sub
ErrorExit:
Screen.MousePointer = vbDefault
MsgBox Err.Description, vbInformation, Me.Caption
CnnDataBase.Close '关闭数据库
Set rst = Nothing '关闭记录集
Unload Me
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
On Error GoTo ErrorExit '错误处理
Dim strsql As String
Dim rst As New ADODB.Recordset
Dim CnnBool As Boolean
CnnBool = ConnectDB '连接数据库
If CnnBool = False Then '数据库连接失败
MsgBox "数据库连接失败!", vbExclamation, Me.Caption
' CnnDataBase.Close '关闭数据库
Unload Me
Exit Sub
End If
strsql = "select * from tbl_login order by userid"
rst.Open strsql, CnnDataBase '打开登录者信息的记录集
With Me.Combo_User
Do While rst.EOF = False '添加所有用户名
.AddItem rst!userid
rst.MoveNext
Loop
End With
PictureNum = 8 '设置动画标题起始点
Exit Sub
ErrorExit:
Screen.MousePointer = vbDefault
MsgBox Err.Description, vbInformation, Me.Caption
Set CnnDataBase = Nothing '关闭数据库
Unload Me
End Sub
Private Sub Timer1_Timer() '动画标题
If PictureNum < 9 Then
PictureNum = PictureNum + 1
Else '设置动画不断循环
PictureNum = 1
End If
Me.Image1.Picture = Me.ImageList1.ListImages(PictureNum).Picture '显示图片动画
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -