📄 login.frm
字号:
VERSION 5.00
Begin VB.Form login
Caption = "Form1"
ClientHeight = 2820
ClientLeft = 4935
ClientTop = 3990
ClientWidth = 3885
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2820
ScaleWidth = 3885
Begin VB.TextBox Text2
Height = 495
IMEMode = 3 'DISABLE
Left = 1800
PasswordChar = "*"
TabIndex = 2
Top = 1320
Width = 1575
End
Begin VB.TextBox Text1
Height = 495
Left = 1800
TabIndex = 1
Top = 480
Width = 1575
End
Begin VB.CommandButton Command1
Caption = "登陆"
Height = 495
Left = 360
TabIndex = 3
Top = 2040
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 495
Left = 2280
TabIndex = 4
Top = 2040
Width = 1095
End
Begin VB.Label Label2
Caption = "密码:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 480
TabIndex = 5
Top = 1320
Width = 735
End
Begin VB.Label Label1
Caption = "编号:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 480
TabIndex = 0
Top = 600
Width = 1095
End
End
Attribute VB_Name = "login"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.Open "SELECT id,access FROM employeeinfo where id='" & Text1.Text & "' and password='" & Text2 & "'", cnn, adOpenForwardOnly, adLockReadOnly
If Not rst.EOF Then
CurrentStatus = 1 '设置登录状态
CurrentUser = Text1 '设置当前用户
If rst.Fields(1).Value = 1 Then
UserRank = "1" '设置当前权限
Else
UserRank = "0"
End If
rst.Close
Set rst = Nothing
main.Show
Unload Me
Else '数据库中不存在匹配记录
rst.Close
Set rst = Nothing
MsgBox "用户名或密码错误", vbOKOnly, "警告"
Text1 = ""
Text2 = ""
End If
End Sub
Private Sub Command2_Click()
CloseDb
End
End Sub
Private Sub Form_Load()
OpenDb Str
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then Command1_Click
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -