📄 frmlogin.frm
字号:
VERSION 5.00
Begin VB.Form FrmLogin
BorderStyle = 1 'Fixed Single
Caption = "登录"
ClientHeight = 4365
ClientLeft = 2835
ClientTop = 3480
ClientWidth = 4530
ControlBox = 0 'False
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2578.987
ScaleMode = 0 'User
ScaleWidth = 4253.424
StartUpPosition = 2 '屏幕中心
Begin VB.ListBox List1
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1530
Left = 540
TabIndex = 5
Top = 1425
Width = 3450
End
Begin ServicingMS.lvButtons_H cmdOK
Height = 420
Left = 1020
TabIndex = 3
Top = 3645
Width = 1380
_ExtentX = 2434
_ExtentY = 741
Caption = "登录"
CapAlign = 2
BackStyle = 2
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
cGradient = 0
Mode = 0
Value = 0 'False
cBack = -2147483633
End
Begin VB.TextBox txtPassword
Height = 345
IMEMode = 3 'DISABLE
Left = 1695
PasswordChar = "*"
TabIndex = 2
Top = 3120
Width = 2325
End
Begin ServicingMS.lvButtons_H cmdCancel
Height = 420
Left = 2670
TabIndex = 4
Top = 3645
Width = 1380
_ExtentX = 2434
_ExtentY = 741
Caption = "取消"
CapAlign = 2
BackStyle = 2
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
cGradient = 0
Mode = 0
Value = 0 'False
cBack = -2147483633
End
Begin VB.Image Image1
Height = 480
Left = 840
Picture = "FrmLogin.frx":0000
Top = 270
Width = 480
End
Begin VB.Image imgBorder
Height = 900
Left = 15
Picture = "FrmLogin.frx":08CA
Top = 15
Width = 4770
End
Begin VB.Label lblLabels
Caption = "用户名称(&U):"
Height = 225
Index = 0
Left = 150
TabIndex = 0
Top = 1170
Width = 1080
End
Begin VB.Label lblLabels
Caption = "登录密码(&P):"
Height = 270
Index = 1
Left = 195
TabIndex = 1
Top = 3210
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
Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click()
'设置全局变量为 false
'不提示失败的登录
LoginSucceeded = False
Unload Me
End
End Sub
Private Sub cmdOK_Click()
Dim ShowAtStartup As Long
Static i As Integer
With rs
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Source = "select * from LoginUserInfo where UserID='" & Left(List1.Text, 4) & "' and UserName='" & Mid(List1.Text, 6, 8) & "'"
.ActiveConnection = Cn
.Open
End With
If rs.RecordCount <> 0 Then
'3.Pass 4.Level
If txtPassword = rs.Fields(3) Then
'ok
Select Case rs.Fields(4)
Case "Admin"
frmMain.XP_StatusBar1.PanelCaption(1) = "当前用户:" & Mid(List1.Text, 6, 8) & " 权限:管理员" & Space(10)
Case "Guest"
frmMain.XP_StatusBar1.PanelCaption(1) = "当前用户:" & Mid(List1.Text, 6, 8) & " 权限:普通用户" & Space(10)
End Select
frmMain.XP_StatusBar1.PanelCaption(4) = "当前日期:" & Format(Date, "yyyy年mm月dd日") & Space(10)
Unload Me
Else
'fail
MsgBox "密码错误,请重新输入!", vbCritical, "提示!"
rs.Close
txtPassword.SelStart = 0
txtPassword.SelLength = Len(txtPassword)
txtPassword.SetFocus
Exit Sub
End If
End If
' If Text1 = "admin" Then
' frmMain.StatusBar1.Panels(5).Text = "操作员:" & "Admin"
' Unload Me
' ShowAtStartup = GetSetting(App.EXEName, "Options", "Show Tips at Startup", 1)
' pbUserPermission = "系统管理员"
' If ShowAtStartup = 1 Then
' frmTip.Show vbModal
' End If
' Else
' Set MdbR = NdMd.OpenRecordset("select * from 口令权限 where 姓名='" & Trim(List1.Text) & "'")
' If MdbR.EOF Then
' MsgBox "该操作员未找到!", vbCritical
' Text1.SelStart = 0
' Text1.SelLength = Len(Text1)
' Text1.SetFocus
' Exit Sub
' Else
' If Crypt(Trim(Text1.Text), "ND2000MXF") <> Trim(MdbR.Fields("密码")) Then
' MsgBox "密码错误,请重新输入!", vbCritical, "提示!"
' i = i + 1
' If i = 3 Then
' Set MdbR = NdMd.OpenRecordset("操作纪录")
' With MdbR
' .AddNew
' .Fields("操作员") = Trim(Left(List1.Text, 5))
' .Fields("进入日期") = Now
' .Fields("退出日期") = Now
' .Fields("操作情况") = "非法进入"
' .Update
' End With
' MsgBox "3次密码输入无效,您的操作记录系统将自动保存," & Chr(13) & "若仍需进入,请联系系统管理员!", vbCritical, "警告!"
' Unload Me
' End
' Else
' Text1.SelStart = 0
' Text1.SelLength = Len(Text1.Text)
' Text1.SetFocus
' End If
' Else
' pbUserPermission = MdbR.Fields!权限
' Set MdbR = NdMd.OpenRecordset("操作纪录")
' Operator = Trim(Left(List1.Text, 5))
' With MdbR
' .AddNew
' .Fields("操作员") = Trim(Left(List1.Text, 5))
' .Fields("进入日期") = Now
' .Fields("操作情况") = "正常进入"
' .Update
' End With
' frmMain.StatusBar1.Panels(5).Text = "操作员:" & Operator
' SaveSetting App.EXEName, "SysStart", "Start", "Two"
' Unload Me
' ShowAtStartup = GetSetting(App.EXEName, "Options", "Show Tips at Startup", 1)
' If ShowAtStartup = 1 Then
' frmTip.Show vbModal
' End If
' End If
' End If
' End If
'
'
' '检查正确的密码
' If txtPassword = "password" Then
' '将代码放在这里传递
' '成功到 calling 函数
' '设置全局变量时最容易的
' LoginSucceeded = True
' Me.Hide
' Else
' MsgBox "无效的密码,请重试!", , "登录"
' txtPassword.SetFocus
' SendKeys "{Home}+{End}"
' End If
End Sub
Private Sub Form_Load()
Dim i As Integer
Cn.Open "dsn=SerManage"
Set rs = New ADODB.Recordset
With rs
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Source = "select * from LoginUserInfo"
.ActiveConnection = Cn
.Open
End With
List1.Clear
For i = 0 To rs.RecordCount - 1
List1.AddItem rs.Fields(1) & vbTab & rs.Fields(2)
rs.MoveNext
Next
List1.ListIndex = Val(GetSetting(App.EXEName, "RegInfo", "UserN", ""))
rs.Close
cmdOK.Enabled = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
rs.Close
Cn.Close
End Sub
Private Sub List1_Click()
On Error Resume Next
SaveSetting App.EXEName, "RegInfo", "UserN", List1.ListIndex 'IIf(List1.ListIndex = -1, 0, List1.ListIndex)
txtPassword.SetFocus
End Sub
Private Sub txtPassword_Change()
If Len(Trim(txtPassword)) <> 0 Then
cmdOK.Enabled = True
Else
cmdOK.Enabled = False
End If
End Sub
Private Sub txtPassword1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Len(txtPassword.Text) <> 0 Then
cmdOK.Enabled = True
cmdOK.SetFocus
'Command1_Click
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -