📄 login.frm
字号:
VERSION 5.00
Begin VB.Form login
Caption = "Form1"
ClientHeight = 3150
ClientLeft = 60
ClientTop = 345
ClientWidth = 4470
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3150
ScaleWidth = 4470
StartUpPosition = 3 '窗口缺省
Begin VB.PictureBox Picture1
BackColor = &H00C0E0FF&
Height = 3135
Left = 0
ScaleHeight = 3075
ScaleWidth = 4395
TabIndex = 0
Top = 0
Width = 4455
Begin VB.ComboBox comb_uid
BackColor = &H00808080&
Height = 300
ItemData = "login.frx":0000
Left = 1920
List = "login.frx":0002
TabIndex = 7
Text = "Combo1"
Top = 1080
Width = 1335
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 375
Left = 2400
TabIndex = 3
Top = 2280
Width = 735
End
Begin VB.TextBox txt_pwd
BackColor = &H00808080&
Height = 270
IMEMode = 3 'DISABLE
Left = 1920
MaxLength = 12
PasswordChar = "*"
TabIndex = 1
Top = 1395
Width = 1335
End
Begin VB.CommandButton Command1
BackColor = &H00C0E0FF&
Caption = "确定"
Height = 375
Left = 960
TabIndex = 2
Top = 2280
Width = 735
End
Begin VB.Label Label3
BackColor = &H00C0E0FF&
Caption = "密 码:"
Height = 195
Left = 840
TabIndex = 6
Top = 1440
Width = 735
End
Begin VB.Label Label2
BackColor = &H00C0E0FF&
Caption = "用户名:"
Height = 195
Left = 840
TabIndex = 5
Top = 1080
Width = 735
End
Begin VB.Label Label1
BackColor = &H00C0E0FF&
Caption = "酒店管理系统"
BeginProperty Font
Name = "楷体_GB2312"
Size = 21.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 720
TabIndex = 4
Top = 120
Width = 3135
End
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()
If txt_pwd.Text = "" Then
MsgBox "密码不能为空!", vbExclamation
txt_pwd.SetFocus
Exit Sub
End If
Dim key As Boolean
key = CheckUser
If key = True Then
Unload Me
main.Show
Else
MsgBox "输入无效,请确认用户名及密码!", vbExclamation
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
'窗口居中
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2 - 550
Dim i_ret As Integer '调用函数的返回值
i_ret = db_Open
If i_ret = 0 Then
Else
MsgBox "数据库文件不存在!", vbExclamation
End If
Call LoadUser
End Sub
Private Function CheckUser() As Boolean
Dim str As String
str = "select * from userinfo where uid='" & comb_uid.Text & "' and pass='" & txt_pwd.Text & "'"
Dim myrs As ADODB.Recordset
Set myrs = New ADODB.Recordset
myrs.CursorLocation = adUseClient
myrs.LockType = adLockOptimistic
myrs.CursorType = adOpenDynamic
myrs.Open str, myCon
If myrs.RecordCount = 0 Then
CheckUser = False
Else
m_user = comb_uid.Text
CheckUser = True
End If
End Function
'加载用户信息
Private Sub LoadUser()
Dim str As String
str = "select * from userinfo order by uid"
Dim myrs As ADODB.Recordset
Set myrs = New ADODB.Recordset
myrs.CursorLocation = adUseClient
myrs.LockType = adLockOptimistic
myrs.CursorType = adOpenDynamic
myrs.Open str, myCon
While Not myrs.EOF
comb_uid.AddItem (myrs("uid"))
myrs.MoveNext
Wend
comb_uid.ListIndex = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -