?? main_mima.frm
字號:
VERSION 5.00
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form main_mima
BackColor = &H00C0C0C0&
BorderStyle = 1 'Fixed Single
Caption = "酒店客房管理系統(tǒng)"
ClientHeight = 2700
ClientLeft = 45
ClientTop = 330
ClientWidth = 5490
Icon = "main_mima.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2700
ScaleWidth = 5490
StartUpPosition = 1 '所有者中心
Begin VB.Frame Frame1
Height = 1215
Left = 2160
TabIndex = 2
Top = 705
Width = 3105
Begin MSDataListLib.DataCombo Dcomczy
Height = 330
Left = 960
TabIndex = 6
Top = 240
Width = 2055
_ExtentX = 3625
_ExtentY = 582
_Version = 393216
Text = ""
End
Begin VB.TextBox txtpwd
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
IMEMode = 3 'DISABLE
Left = 1005
MaxLength = 6
PasswordChar = "*"
TabIndex = 3
Top = 705
Width = 1920
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "操作員: "
BeginProperty Font
Name = "黑體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 120
TabIndex = 5
Top = 255
Width = 1095
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 = 300
Left = 120
TabIndex = 4
Top = 735
Width = 975
End
End
Begin VB.CommandButton cmdquit
BackColor = &H00FF8080&
Caption = "退出"
Height = 400
Left = 3720
TabIndex = 1
Top = 2145
Width = 1365
End
Begin VB.CommandButton cmdok
BackColor = &H00FF8080&
Caption = "確定"
Height = 400
Left = 2355
TabIndex = 0
Top = 2145
UseMaskColor = -1 'True
Width = 1365
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "酒店客房管理系統(tǒng)"
BeginProperty Font
Name = "宋體"
Size = 24
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFC0&
Height = 495
Left = 720
TabIndex = 7
Top = 120
Width = 4335
End
Begin VB.Shape Shape1
Height = 1830
Left = 150
Top = 705
Width = 1830
End
Begin VB.Image Image1
Height = 1800
Left = 150
Picture = "main_mima.frx":000C
Stretch = -1 'True
Top = 720
Width = 1830
End
End
Attribute VB_Name = "main_mima"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'強(qiáng)制變量說明
Option Explicit
'定義數(shù)據(jù)庫連接對象
Dim DBcnn As New ADODB.Connection
'定義數(shù)據(jù)庫中對應(yīng)于系統(tǒng)用戶(qxsz)表的數(shù)據(jù)集對象
Dim DBrs1 As New ADODB.Recordset
Dim DBrs2 As New ADODB.Recordset
'定義存儲(chǔ)sql語句的字符串變量
Dim sqlstr As String
'定義一個(gè)整型變量
Dim TIM As Integer
'定義一個(gè)字符串變量
Dim myval As String
Private Sub Form_Load()
'判斷當(dāng)前數(shù)據(jù)庫連接對象的狀態(tài),如果未連接到數(shù)據(jù)庫KFGL,則連接到數(shù)據(jù)庫KFGL
If DBcnn.State = 0 Then
Dim connectstr As String
connectstr = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=" & _
App.Path & "\KFGL.mdb;Persist Security Info=False"
DBcnn.CursorLocation = adUseClient
DBcnn.Open connectstr
End If
'判斷數(shù)據(jù)集對象DBrs1和DBrs2的狀態(tài),如果是打開狀態(tài),則先關(guān)閉,
'以防止出現(xiàn)重復(fù)打開數(shù)據(jù)集對象的錯(cuò)誤
If DBrs1.State = 1 Then
DBrs1.Close
End If
If DBrs2.State = 1 Then
DBrs2.Close
End If
'設(shè)置并執(zhí)行SQL語句并返回相應(yīng)的數(shù)據(jù)集
sqlstr = "select * from qxsz"
DBrs1.Open sqlstr, DBcnn, adOpenStatic, adLockBatchOptimistic
DBrs2.Open sqlstr, DBcnn, adOpenDynamic, adLockBatchOptimistic
'設(shè)置與操作員信息對應(yīng)的DataCombo組合框的數(shù)據(jù)填充字段來源
Set Dcomczy.RowSource = DBrs1
Dcomczy.ListField = DBrs1.Fields("操作員").Name
End Sub
Private Sub Form_Activate()
'當(dāng)記錄為零時(shí),進(jìn)入系統(tǒng)具有所有權(quán)限
If DBrs1.RecordCount = 0 Then
MsgBox ("請先設(shè)置操作員密碼和權(quán)限!")
Load main
main.Show
Unload Me
Else
Dcomczy.SetFocus
End If
End Sub
Private Sub Dcomczy_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Dcomczy.SetFocus '按回車鍵,txtczy獲得焦點(diǎn)
End Sub
Private Sub txtczy_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then cmdok.SetFocus '按回車鍵cmdok獲得焦點(diǎn)
If KeyCode = vbKeyUp Then Dcomczy.SetFocus
If KeyCode = vbKeyDown Then cmdok.SetFocus
End Sub
Private Sub cmdok_Click()
'main.StatusBar1.Panels(4).Text = Dcomczy.Text '賦值給main.StatusBar1.Panels(4).Text
'判斷當(dāng)前數(shù)據(jù)集對象DBrs2的記錄位置是否在尾部,如果在則移到記錄集首部
If DBrs2.BOF = False Then
DBrs2.MoveFirst
End If
'設(shè)置數(shù)據(jù)集對象DBrs2的Filter屬性,以找到用戶輸入或選擇的系統(tǒng)用戶名
sqlstr = "操作員 like '" & Dcomczy.BoundText & "'"
DBrs2.Filter = sqlstr
'判斷是否存在用戶輸入或選擇的系統(tǒng)用戶名
If DBrs2.EOF Then
'不存在用戶輸入或選擇的系統(tǒng)用戶名,給出錯(cuò)誤提示
MsgBox ("操作員輸入錯(cuò)誤!")
Else
'存在用戶輸入或選擇的系統(tǒng)用戶名,判斷用戶輸入的密碼是否正確
sqlstr = "操作員='" & Dcomczy.BoundText & "'"
DBrs1.Filter = sqlstr
If Dcomczy.BoundText <> "" And Dcomczy.Text <> "" _
And txtpwd.Text = DBrs1.Fields("密碼") Then
main.loginname = Dcomczy.Text
Load main
main.Show
Unload Me
Else
'判斷用戶輸入錯(cuò)誤密碼的次數(shù)是否超過3次
If TIM = 3 Then
'密碼輸錯(cuò)3次,退出該系統(tǒng)
myval = MsgBox("密碼輸入錯(cuò)誤,請向系統(tǒng)管理員查詢!", 0, "")
If myval = vbOK Then
End
End If
End If
If Dcomczy.BoundText = "" Then
MsgBox ("請輸入操作員!")
Dcomczy.SetFocus
Else
If Dcomczy.BoundText <> DBrs1.Fields("操作員") Then
MsgBox ("查無此操作員,請重新輸入操作員!")
Dcomczy.SetFocus
Else
'判斷用戶是否輸入密碼
If txtpwd.Text = "" Then
'用戶沒有輸入密碼,給出錯(cuò)誤提示
MsgBox ("請輸入操作員密碼!")
txtpwd.SetFocus
Else
'判斷用戶是否輸入正確的密碼
If txtpwd.Text <> DBrs1.Fields("密碼") Then
'用戶輸入錯(cuò)誤的密碼,給出錯(cuò)誤提示
MsgBox ("密碼錯(cuò)誤,請重新輸入密碼!")
TIM = TIM + 1
txtpwd.SetFocus
End If
End If
End If
End If
End If
End If
End Sub
Private Sub cmdquit_Click()
End
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -