📄 frmlogin.frm
字号:
VERSION 5.00
Object = "{E95A2510-F3D1-416D-823B-4F840FE98091}#3.0#0"; "Command.ocx"
Begin VB.Form frmLogin
BorderStyle = 3 'Fixed Dialog
Caption = "身份验证"
ClientHeight = 2430
ClientLeft = 45
ClientTop = 330
ClientWidth = 4905
ControlBox = 0 'False
Icon = "frmLogin.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2430
ScaleWidth = 4905
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin CSCommand.Command cmdCancel
Cancel = -1 'True
Height = 300
Left = 3360
TabIndex = 5
Top = 1995
Width = 855
_ExtentX = 1508
_ExtentY = 529
IconAlign = 0
Icon = "frmLogin.frx":0E42
Caption = "退出(&Q)"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin CSCommand.Command cmdLogin
Default = -1 'True
Height = 300
Left = 2160
TabIndex = 4
Top = 1995
Width = 855
_ExtentX = 1508
_ExtentY = 529
IconAlign = 0
Icon = "frmLogin.frx":0E5E
Caption = "确定(&O)"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.Frame Frame1
Caption = "用户验证"
Height = 1575
Left = 1800
TabIndex = 0
Top = 250
Width = 2775
Begin VB.ComboBox cmbType
Height = 300
ItemData = "frmLogin.frx":0E7A
Left = 960
List = "frmLogin.frx":0E87
TabIndex = 2
Top = 720
Width = 1575
End
Begin VB.ComboBox cmbUser
Height = 300
ItemData = "frmLogin.frx":0E9F
Left = 960
List = "frmLogin.frx":0EA1
TabIndex = 1
Text = "选择用户"
Top = 360
Width = 1575
End
Begin VB.TextBox txtPassword
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00008000&
Height = 270
IMEMode = 3 'DISABLE
Left = 960
PasswordChar = "*"
TabIndex = 3
Top = 1080
Width = 1575
End
Begin VB.Label Label2
Caption = "用户等级"
Height = 255
Index = 1
Left = 120
TabIndex = 8
Top = 720
Width = 855
End
Begin VB.Label Label2
Caption = "密 码"
Height = 255
Index = 0
Left = 120
TabIndex = 7
Top = 1080
Width = 615
End
Begin VB.Label Label1
Caption = "用户名"
Height = 255
Left = 120
TabIndex = 6
Top = 360
Width = 615
End
End
Begin VB.Label Label3
Caption = "身份验证"
BeginProperty Font
Name = "宋体"
Size = 26.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2175
Left = 600
TabIndex = 9
Top = 120
Width = 495
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim sql As String
Dim a As Integer
Private Sub cmbUser_Click()
cmbType.SetFocus
End Sub
Private Sub cmdCancel_Click()
If MsgBox("要退出系统吗?", vbQuestion + vbOKCancel, "系统退出") = vbOK Then
End
End If
End Sub
Private Sub cmdLogin_Click()
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
If a = 4 Then
MsgBox "非法用户 系统退出", vbCritical + vbOKOnly, "系统验证"
End
End If
If txtPassword.Text = "" Then
MsgBox "请输入密码!", vbInformation + vbOKOnly, "系统验证"
Exit Sub
End If
sql = "select * from administrator where admin='" & cmbUser.Text & "' and ad_pwd='" & txtPassword.Text & "'and ad_type='" & cmbType.Text & "' "
If mdlCon.connectToserver(con, rs, sql) Then
mdlCon.userName = cmbUser.Text
mdlCon.userPassowrd = txtPassword.Text
mdlCon.userType = cmbType.Text
mdfrmMain.Show
rs.Close
con.Close
Unload Me
Else
MsgBox "用户名、密码或用户等级错误!", vbOKOnly, "系统验证"
a = a + 1
txtPassword.Text = ""
txtPassword.SetFocus
rs.Close
con.Close
End If
End Sub
Private Sub Form_Load()
Dim con As New ADODB.Connection
Dim rs As New Recordset
Dim UserStr As String
Dim i As Integer
cmbType.ListIndex = 0
UserStr = "select * from administrator"
If mdlCon.connectTotable(con, rs, UserStr) Then
While Not rs.EOF
cmbUser.AddItem rs!admin
rs.MoveNext
Wend
rs.Close
con.Close
Else
MsgBox "欢迎初次使用本《酒店管理系统》默认用户名和密码:admin", vbInformation + vbOKOnly, "欢迎登录"
rs.Close
rs.Open "insert into administrator values('admin','经理','admin')"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -