📄 登录.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmLogin
BorderStyle = 3 'Fixed Dialog
Caption = " "
ClientHeight = 2535
ClientLeft = 2835
ClientTop = 3480
ClientWidth = 4500
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1497.762
ScaleMode = 0 'User
ScaleWidth = 4225.256
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 0
Top = 1680
Width = 2520
_ExtentX = 4445
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.CommandButton Command3
Caption = "用户注册"
Height = 390
Left = 3120
TabIndex = 8
Top = 1920
Width = 1140
End
Begin VB.ComboBox Combo1
Height = 300
Left = 1440
TabIndex = 6
Text = "Combo1"
Top = 1320
Width = 2295
End
Begin VB.TextBox txtUserName
Height = 345
Left = 1440
TabIndex = 1
Top = 135
Width = 2325
End
Begin VB.CommandButton command1
Caption = "登录系统"
Default = -1 'True
Height = 390
Left = 495
TabIndex = 4
Top = 1920
Width = 1140
End
Begin VB.CommandButton command2
Cancel = -1 'True
Caption = "退出系统"
Height = 390
Left = 1800
TabIndex = 5
Top = 1920
Width = 1140
End
Begin VB.TextBox txtPassword
Height = 345
IMEMode = 3 'DISABLE
Left = 1440
PasswordChar = "*"
TabIndex = 3
Top = 720
Width = 2325
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "权限:"
Height = 180
Left = 720
TabIndex = 7
Top = 1440
Width = 450
End
Begin VB.Label lblLabels
AutoSize = -1 'True
Caption = "用户名称:"
Height = 180
Index = 0
Left = 360
TabIndex = 0
Top = 240
Width = 810
End
Begin VB.Label lblLabels
AutoSize = -1 'True
Caption = "密码:"
Height = 180
Index = 1
Left = 720
TabIndex = 2
Top = 840
Width = 450
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 Command1_Click()
Dim sqlstr As String
'检查正确的密码
' If txtPassword = "password" Then
' '将代码放在这里传递
' '成功到 calling 函数
' '设置全局变量时最容易的
' LoginSucceeded = True
' Me.Hide
' Else
' MsgBox "无效的密码,请重试!", , "登录"
' txtPassword.SetFocus
' SendKeys "{Home}+{End}"
' End If
If txtUserName = "" Then
MsgBox "请输入用户名", vbOKOnly, "错误"
End If
If txtPassword = "" Then
MsgBox "请输入密码", vbOKOnly, "错误"
End If
If Combo1.Text = "请选择权限" Then
MsgBox "请选择权限", vbOKOnly, "错误"
End If
sqlstr = "select * from 员工信息表 where 用户名ID = '" & txtUserName.Text & "'"
Adodc1.RecordSource = sqlstr
Adodc1.Refresh
If Adodc1.Recordset("密码") = txtPassword.Text And Adodc1.Recordset("权限") = Combo1.Text Then
LoginSucceeded = True
Me.Hide
MsgBox "成功登录!"
If Combo1.Text = "员工" Then
Form2.Show
Else
MDIForm1.Show
End If
Else
MsgBox "请确认您的信息后再登录!"
End If
End Sub
Private Sub Command2_Click()
'设置全局变量为 false
'不提示失败的登录
LoginSucceeded = False
End
End Sub
Private Sub Command3_Click()
Unload Me
MsgBox "您好,欢迎注册本系统!", , "提示信息"
Form1.Show
End Sub
Private Sub Form_Load()
txtUserName.Text = ""
txtPassword.Text = ""
Combo1.Text = "请选择权限"
Combo1.AddItem "员工"
Combo1.AddItem "管理员"
Adodc1.Visible = False
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\工资管理系统.mdb;Persist Security Info=False"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "员工信息表"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -