📄 frmlogin.frm
字号:
VERSION 5.00
Begin VB.Form FrmLogin
BackColor = &H0000FF00&
Caption = "登录"
ClientHeight = 2925
ClientLeft = 60
ClientTop = 345
ClientWidth = 6285
ControlBox = 0 'False
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2925
ScaleWidth = 6285
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox TxtPwd
BeginProperty Font
Name = "黑体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 360
IMEMode = 3 'DISABLE
Left = 3750
MaxLength = 10
PasswordChar = "*"
TabIndex = 2
Text = "1111111123"
Top = 1140
Width = 1470
End
Begin VB.PictureBox Picture1
BackColor = &H0080FFFF&
BorderStyle = 0 'None
Height = 915
Left = 0
ScaleHeight = 915
ScaleWidth = 6495
TabIndex = 1
Top = 0
Width = 6495
Begin VB.Label Label3
BackColor = &H0080FFFF&
Caption = "太阳能路灯监控系统"
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 960
TabIndex = 6
Top = 240
Width = 4335
End
End
Begin VB.TextBox TxtUsr
BeginProperty Font
Name = "黑体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 360
Left = 1545
MaxLength = 7
TabIndex = 0
Text = "0000000"
Top = 1110
Width = 1140
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "工号:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Index = 0
Left = 690
TabIndex = 5
Top = 1140
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "口令:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Index = 1
Left = 2910
TabIndex = 4
Top = 1140
Width = 720
End
Begin VB.Label Label2
BackColor = &H00C0FFC0&
BorderStyle = 1 'Fixed Single
Caption = $"FrmLogin.frx":0000
ForeColor = &H00000000&
Height = 1035
Left = 960
TabIndex = 3
Top = 1620
Width = 4875
End
Begin VB.Image Image2
Height = 660
Index = 0
Left = 60
Picture = "FrmLogin.frx":00F5
Stretch = -1 'True
Top = 1800
Width = 750
End
Begin VB.Image Image2
Height = 960
Index = 1
Left = 60
Picture = "FrmLogin.frx":0537
Stretch = -1 'True
Top = 720
Visible = 0 'False
Width = 960
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 rst As ADODB.Recordset
Dim passwordcounter As String
Dim ii As Integer
Private Sub form_KeyDown(KeyCode As Integer, Shift As Integer)
On Error Resume Next
If KeyCode = 27 Then
'ESC
' ii = MsgBox("确定退出吗?", vbOKCancel)
' If ii = 1 Then
' End
' Else
' Exit Sub
' End If
If MsgBox(Chr(13) & " 是否退出系统? " & Chr(13), 36 + 256, "欢迎您再次使用!") = vbYes Then
End
End If
End If
End Sub
Private Sub Form_Load()
SetWindowRgn Frmlogin.hwnd, CreateRoundRectRgn(0, 0, Frmlogin.Width / Screen.TwipsPerPixelX, Frmlogin.Height / Screen.TwipsPerPixelY, 60, 60), True
On Error Resume Next
' Left = (Screen.Width - Me.Width) / 2
' Top = (Screen.Height - Me.Height) / 2
passwordcounter = 0
TxtUsr = ""
TxtPwd = ""
End Sub
Private Sub TxtPwd_GotFocus() '密码框获得输入焦点
On Error Resume Next
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseClient
rst.Open "select * from userduty where 编号='" & Trim(TxtUsr.Text) & "'", adocnstring, adOpenDynamic, adLockOptimistic, adCmdText
If rst.EOF Then
MsgBox "该用户名无效,请输入正确的用户名.", , "用户名"
TxtUsr.SetFocus '用户名获得输入焦点
TxtUsr = ""
End If
rst.Close
Set rst = Nothing
End Sub
Private Sub TxtUsr_KeyDown(KeyCode As Integer, Shift As Integer)
On Error Resume Next
If KeyCode = vbKeyReturn Then
TxtPwd.SetFocus
ElseIf KeyCode = 27 Then
'ESC
' ii = MsgBox("确定退出吗?", vbOKCancel)
' If ii = 1 Then
' End
' Else
' Exit Sub
' End If
If MsgBox(Chr(13) & " 是否退出系统? " & Chr(13), 36 + 256, "欢迎您再次使用!") = vbYes Then
End
End If
End If
End Sub
Private Sub TxtPwd_KeyDown(KeyCode As Integer, Shift As Integer)
On Error Resume Next
If KeyCode = vbKeyReturn Then
CmdOK_Click
ElseIf KeyCode = 27 Then
'ESC
' ii = MsgBox("确定退出吗?", vbOKCancel)
' If ii = 1 Then
' End
' Else
' Exit Sub
' End If
If MsgBox(Chr(13) & " 是否退出系统? " & Chr(13), 36 + 256, "欢迎您再次使用!") = vbYes Then
End
End If
End If
End Sub
Private Sub CmdOK_Click()
On Error Resume Next
passwordcounter = passwordcounter + 1
Me.Caption = "正在检查用户..."
If Len(TxtUsr.Text) = 0 Then
MsgBox "请输入您的用户名.", , "错误"
TxtUsr.SetFocus
Else
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseClient
rst.Open "select * from userduty where 编号='" & Trim(TxtUsr.Text) & "'", adocnstring, adOpenDynamic, adLockOptimistic, adCmdText
If rst.EOF Then
MsgBox "该用户名无效,请输入正确的用户名.", , "用户名"
rst.Close
TxtUsr.SetFocus
Else
rst.Close
rst.Open "select * from userduty where 编号='" & Trim(TxtUsr.Text) & "' and 密码 = '" & TxtPwd.Text & "'", adocnstring, adOpenDynamic, adLockOptimistic, adCmdText
If rst.EOF Then
If passwordcounter > 3 Then
MsgBox "登录失败!", , "^_^"
Unload Me
End
End If
MsgBox "该密码无效,请输入正确的密码.", , "密码"
TxtPwd.SetFocus
TxtPwd.Text = ""
rst.Close
Else
''' Global gUserCode As String
''' Global gUserName As String
''' Global gUserpass As String
''' Global gUserQX As String
gUserName = Trim(rst![姓名])
gUserCode = Trim(rst![编号])
gUserpass = Trim(rst![密码])
gUserQX = Trim(rst![权限])
rst.Update
rst.Close
Unload Me
FrmWait.Show
FrmMain.Show
End If
End If
End If
End Sub
Private Sub CmdClose_Click()
On Error Resume Next
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -