📄 frmlogin.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmLogin
BorderStyle = 1 'Fixed Single
Caption = "登录"
ClientHeight = 1344
ClientLeft = 36
ClientTop = 336
ClientWidth = 3744
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1344
ScaleWidth = 3744
StartUpPosition = 3 '窗口缺省
Begin VB.ComboBox Combo1
Height = 300
Left = 840
TabIndex = 5
Top = 120
Width = 2415
End
Begin MSAdodcLib.Adodc Adodc1
Height = 312
Left = 0
Top = 960
Visible = 0 'False
Width = 1212
_ExtentX = 2138
_ExtentY = 550
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
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.TextBox txtPassword
Height = 300
IMEMode = 3 'DISABLE
Left = 840
PasswordChar = "*"
TabIndex = 2
Top = 516
Width = 2445
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消"
Height = 330
Left = 2520
TabIndex = 1
Top = 960
Width = 1140
End
Begin VB.CommandButton cmdOK
Caption = "确定"
CausesValidation= 0 'False
Height = 330
Left = 1260
TabIndex = 0
Top = 960
Width = 1140
End
Begin VB.Label lblLabels
AutoSize = -1 'True
Caption = "密码"
Height = 180
Index = 1
Left = 360
TabIndex = 4
Top = 480
Width = 360
End
Begin VB.Label lblLabels
AutoSize = -1 'True
Caption = "用户"
Height = 180
Index = 0
Left = 360
TabIndex = 3
Top = 120
Width = 360
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
On Error Resume Next '错误处理代码
'设定窗体显示位置
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 3
'设定ADO数据控件的数据属性
Adodc1.ConnectionString = constr '设定连接字符串
Adodc1.CommandType = adCmdTable '设定命令类型,表示从选定表中返回所有行
Adodc1.RecordSource = "用户表" '设定数据源
Adodc1.Refresh '刷新控件
'设定组合框内容
Combo1.Clear '清空组合框
Adodc1.Recordset.MoveFirst '转移至最前记录,注意用户表中必须有记录,否则会出错
While Not Adodc1.Recordset.EOF '循环至最后记录
Combo1.AddItem Adodc1.Recordset(1) '向组合框列表中添加条目
Adodc1.Recordset.MoveNext '转向下一条记录
Wend
End Sub
Private Sub cmdOK_Click()
Dim Uname As String '声明局部变量,传递用户名
Dim Upassword As String '声明局部变量,传递密码
'检查用户名输入
If Combo1.Text = "" Then '未选择用户名
MsgBox "请输入用户名。", vbInformation + vbOKOnly, "错误" '给出错误信息
Combo1.SetFocus '焦点返回组合框
Exit Sub '退出过程
End If
'传递变量
Uname = Combo1.Text
Upassword = txtPassword.Text
'核对用户名
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find "用户名称 = '" & Uname & "'" '查找用户名
If Adodc1.Recordset.EOF Then '没有这个用户名
MsgBox "没有这个用户!请确认用户名。", vbInformation + vbOKOnly, "错误" '给出错误信息
'返回焦点并选中所有内容
Combo1.SetFocus
Combo1.SelStart = 0
Combo1.SelLength = Len(Uname)
Exit Sub
End If
'核对密码
If Upassword <> Adodc1.Recordset(2) Then '密码不正确
MsgBox "密码输入不正确!请确认密码。", vbInformation + vbOKOnly, "错误" '给出错误信息
'返回焦点并选中所有内容
txtPassword.SetFocus
txtPassword.SelStart = 0
txtPassword.SelLength = Len(Upassword)
Exit Sub
End If
'用户名和密码全部正确,正确登录
UserID = Adodc1.Recordset(0) '传递变量
UserName = Uname '传递变量
password = Upassword '传递变量
JDGL = CBool(Adodc1.Recordset(3)) '将数据转换为Boolean类型,传递用户权限
DDGL = CBool(Adodc1.Recordset(4)) '将数据转换为Boolean类型,传递用户权限
YWGL = CBool(Adodc1.Recordset(5)) '将数据转换为Boolean类型,传递用户权限
YHGL = CBool(Adodc1.Recordset(6)) '将数据转换为Boolean类型,传递用户权限
frmMain.mnuJDGL.Enabled = JDGL '如果用户没有权限则无法使用对应的菜单
frmMain.mnuDDGL.Enabled = DDGL '如果用户没有权限则无法使用对应的菜单
frmMain.mnuYWGL.Enabled = YWGL '如果用户没有权限则无法使用对应的菜单
frmMain.mnuYHGL.Enabled = YHGL '如果用户没有权限则无法使用对应的菜单
frmMain.Caption = "旅行社酒店预订系统--当前用户:" & UserName '设定主窗体标题
Unload Me '卸载登录窗体
frmMain.Show '显示主窗体
End Sub
Private Sub cmdCancel_Click()
If MsgBox("确定退出本系统吗?", vbQuestion + vbYesNo, "退出系统") = vbYes Then
For Each Form In Forms '遍历窗体集
Unload Form '卸载窗体
Next Form
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -