📄 frmlogin.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 = 2895
ClientLeft = 1245
ClientTop = 1230
ClientWidth = 3915
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 2895
ScaleWidth = 3915
ShowInTaskbar = 0 'False
Begin MSAdodcLib.Adodc Adodc1
Height = 330
Left = 720
Top = 2520
Visible = 0 'False
Width = 1575
_ExtentX = 2778
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 3
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "DSN=personnel"
OLEDBString = ""
OLEDBFile = ""
DataSourceName = "personnel"
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "user"
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 Command2
Caption = "取消"
Height = 375
Left = 2280
TabIndex = 4
Top = 2040
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 375
Left = 480
TabIndex = 3
Top = 2040
Width = 1215
End
Begin VB.TextBox txtPWD
DataSource = "Adodc1"
Height = 375
IMEMode = 3 'DISABLE
Left = 1920
PasswordChar = "*"
TabIndex = 2
Top = 1200
Width = 1695
End
Begin VB.TextBox txtUserName
Height = 375
Left = 1920
TabIndex = 0
Top = 240
Width = 1695
End
Begin VB.Label Label2
Caption = "请输入密码:"
Height = 375
Left = 360
TabIndex = 5
Top = 1320
Width = 1335
End
Begin VB.Label Label1
Caption = "请输入用户名:"
Height = 375
Left = 360
TabIndex = 1
Top = 360
Width = 1455
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'判断用户名是否存在
Private Function nameExist(name As String) As Boolean
Dim i As Integer
i = 0
Adodc1.Recordset.MoveFirst
While (Not Adodc1.Recordset.EOF)
If Adodc1.Recordset("username") = name Then
i = i + 1
End If
Adodc1.Recordset.MoveNext
Wend
If i = 0 Then
nameExist = False
Else
nameExist = True
End If
End Function
'判断密码是否与姓名相符
Private Function rightPWD(name As String, PWD As String) As Boolean
name = "'" & name & "'"
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find "username=" & name
If Adodc1.Recordset("pwd") = PWD Then
rightPWD = True
Else
rightPWD = False
End If
End Function
Private Sub Command1_Click()
If (txtUserName.Text <> "") And (txtPWD.Text <> "") Then
If nameExist(txtUserName.Text) Then
If rightPWD(txtUserName.Text, txtPWD.Text) Then
'标识已有用户登录
userAvailable = True
MsgBox "用户登录成功!", vbOKOnly + vbInformation, "提示信息"
'将当前用户名显示在主窗体标题栏
FrmMain.Caption = "企业人事信息管理系统 用户:" & txtUserName.Text
FrmMain.A11.Enabled = True
FrmMain.A12.Enabled = True
Unload Me
Else
MsgBox "用户名与密码不符,请重新输入!", vbOKOnly + vbExclamation, "提示信息"
End If
Else
MsgBox "用户不存在,请重新输入用户名!", vbOKOnly + vbExclamation, "提示信息"
End If
Else
MsgBox "请输入完整信息!", vbOKOnly + vbExclamation, "提示信息"
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -