📄 login.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form login
Caption = "登陆"
ClientHeight = 3465
ClientLeft = 60
ClientTop = 450
ClientWidth = 6240
LinkTopic = "Form1"
LockControls = -1 'True
ScaleHeight = 3465
ScaleWidth = 6240
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command1
Caption = "确认"
Height = 495
Left = 840
TabIndex = 3
Top = 2760
Width = 1935
End
Begin VB.CommandButton Command2
Caption = "取消"
Height = 495
Left = 3480
TabIndex = 2
Top = 2760
Width = 1935
End
Begin VB.TextBox Text1
Height = 375
Left = 2400
TabIndex = 1
Text = "Admin"
Top = 1440
Width = 3255
End
Begin VB.TextBox Text2
Height = 375
IMEMode = 3 'DISABLE
Left = 2400
PasswordChar = "*"
TabIndex = 0
Top = 2160
Width = 3255
End
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 6240
Top = 1800
Visible = 0 'False
Width = 3135
_ExtentX = 5530
_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=hotel.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=hotel.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "Users"
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.Label Label1
Alignment = 2 'Center
AutoSize = -1 'True
Caption = "欢迎使用酒店管理系统 1.0"
BeginProperty Font
Name = "宋体"
Size = 24
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 495
Left = 240
TabIndex = 7
Top = 240
Width = 5775
End
Begin VB.Label Label2
Alignment = 2 'Center
AutoSize = -1 'True
Caption = "用户名:"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 285
Left = 720
TabIndex = 6
Top = 1440
Width = 1215
End
Begin VB.Label Label3
Alignment = 2 'Center
AutoSize = -1 'True
Caption = "密码:"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 285
Left = 1080
TabIndex = 5
Top = 2160
Width = 915
End
Begin VB.Label Label4
Caption = "copyright by limit"
Height = 255
Left = 4200
TabIndex = 4
Top = 960
Width = 1815
End
End
Attribute VB_Name = "login"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim UserName As String
Dim Password As String
Static Times As Integer
If Trim(Text1.Text) = "" Then '如果用户名为空
MsgBox "用户名不能为空!", vbOKOnly + vbCritical, "错误"
Text1.SetFocus
Exit Sub
End If
'打开数据库中的 Users 表
Adodc1.Refresh
'查找用户名
Adodc1.Recordset.Find "Name='" & Text1.Text & "'", , adSearchForward, 1
If Not Adodc1.Recordset.EOF Then '找到记录
UserName = Adodc1.Recordset!Name
Password = Adodc1.Recordset!Password
Else '没找到记录
UserName = ""
Password = ""
End If
If UserName = Text1.Text And Password = Text2.Text Then
Adodc1.Recordset.Close '关闭数据库中的 Users 表
Unload login '关闭窗体
frmMain.Show '显示主窗体
Else
'用户名或密码不对
MsgBox "用户名或密码不对!", vbOKOnly + vbInformation, "提示"
Times = Times + 1
If Times >= 3 Then '超过三次
Adodc1.Recordset.Close '关闭数据库中的 Users 表
End '退出整个程序
End If
Text2.SetFocus '重新输入密码
End If
End Sub
Private Sub Command2_Click()
'结束程序
End
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command1_Click
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -