📄 frmlogin.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmLogin
Caption = "系统登录"
ClientHeight = 2670
ClientLeft = 60
ClientTop = 345
ClientWidth = 4755
LinkTopic = "Form1"
ScaleHeight = 2670
ScaleWidth = 4755
StartUpPosition = 2 '屏幕中心
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 480
Top = 2400
Visible = 0 'False
Width = 3375
_ExtentX = 5953
_ExtentY = 661
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= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database\企业工资管理系统.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database\企业工资管理系统.mdb;Persist Security Info=False"
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 cmdCancel
Caption = "取消"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2400
TabIndex = 5
Top = 1800
Width = 1215
End
Begin VB.CommandButton cmdOK
Caption = "确定"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 720
TabIndex = 4
Top = 1800
Width = 1095
End
Begin VB.TextBox PassWord
DataSource = "Adodc1"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
IMEMode = 3 'DISABLE
Left = 2040
PasswordChar = "*"
TabIndex = 3
Text = "Text2"
Top = 1080
Width = 1815
End
Begin VB.TextBox UserName
DataSource = "Adodc1"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2040
TabIndex = 1
Text = "Text1"
Top = 360
Width = 1815
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "用户密码:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 720
TabIndex = 2
Top = 1080
Width = 1215
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "用户名称:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 720
TabIndex = 0
Top = 360
Width = 1215
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdCancel_Click()
Unload Me
Exit Sub
End Sub
Private Sub cmdOK_Click()
On Error GoTo errorhandle
Dim finduser As Boolean
finduser = False
Adodc1.Recordset.MoveFirst '将记录指针移动到首记录
If Trim(UserName.Text = "") Then
MsgBox "请输入用户名称!", vbOKOnly + vbExclamation, "警告"
UserName.SetFocus
Exit Sub
Else
Do While Not Adodc1.Recordset.EOF '判断数据表是否已经读完,即遍历整张表
If Adodc1.Recordset.Fields("用户名称") = Trim(UserName.Text) Then 'field就是某个字段
finduser = True
If Adodc1.Recordset.Fields("用户密码") = Trim(Password.Text) Then
Me.Hide
strUserName = Trim(UserName.Text) '保存用户名称
frmMain.Show
Unload Me
Else
MsgBox "密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
Password.SetFocus
Password.Text = ""
End If
End If
Adodc1.Recordset.MoveNext '记录往下移动一条
Loop
If finduser = False Then
MsgBox "没有这个用户,请重新输入!", vbOKOnly + vbExclamation, "警告"
UserName.SetFocus
UserName.Text = ""
End If
End If
Exit Sub
errorhandle:
MsgBox "您的操作有误!", vbOKOnly + vbExclamation, "错误"
End Sub
Private Sub Form_Load()
UserName.Text = ""
Password.Text = ""
End Sub
Private Sub PassWord_KeyPress(KeyAscii As Integer)
Dim finduser As Boolean
finduser = False
Adodc1.Recordset.MoveFirst '将记录指针移动到首记录
If KeyAscii = 13 Then
If Trim(UserName.Text = "") Then
MsgBox "请输入用户名称!", vbOKOnly + vbExclamation, "警告"
UserName.SetFocus
Exit Sub
Else
Do While Not Adodc1.Recordset.EOF '判断数据表是否已经读完,即遍历整张表
If Adodc1.Recordset.Fields("用户名称") = Trim(UserName.Text) Then 'field就是某个字段
finduser = True
If Adodc1.Recordset.Fields("用户密码") = Trim(Password.Text) Then
Me.Hide
strUserName = Trim(UserName.Text) '保存用户名称
frmMain.Show
Unload Me
Else
MsgBox "密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
Password.SetFocus
Password.Text = ""
End If
End If
Adodc1.Recordset.MoveNext '记录往下移动一条
Loop
If finduser = False Then
MsgBox "没有这个用户,请重新输入!", vbOKOnly + vbExclamation, "警告"
UserName.SetFocus
UserName.Text = ""
End If
End If
Exit Sub
errorhandle:
MsgBox "您的操作有误!", vbOKOnly + vbExclamation, "错误"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -