?? main_tfdj.frm
字號:
Name = "宋體"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FFFF&
Height = 390
Left = 3300
TabIndex = 17
Top = 90
Width = 2280
End
Begin VB.Label Lab7
BackStyle = 0 'Transparent
Caption = "操作員:"
Height = 240
Left = 60
TabIndex = 7
Top = 3660
Width = 735
End
Begin VB.Label Lab1
BackStyle = 0 'Transparent
Caption = "NO."
Height = 225
Left = 6225
TabIndex = 5
Top = 585
Width = 675
End
End
Attribute VB_Name = "main_tfdj"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim DBcnn As New ADODB.Connection
Dim DBrs1 As New ADODB.Recordset
Dim DBrs2 As New ADODB.Recordset
Dim DBrs3 As New ADODB.Recordset
Dim DBrs4 As New ADODB.Recordset
Dim sqlstr As String
Private Sub Form_Load()
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
If DBrs4.State = 1 Then
DBrs4.Close
End If
'設置并執行SQL語句并返回相應的數據集DBrs4,
'使其包含djb表中標志字段值為1的所有記錄
sqlstr = "select * from djb where 標志='1'"
DBrs4.Open sqlstr, DBcnn, adOpenStatic, adLockBatchOptimistic
'使用數據對象DBrs4來設置“源房間號”對應的組合框的填充字段來源和綁定字段
Set Dcomyfjh.RowSource = DBrs4
Dcomyfjh.ListField = DBrs4.Fields("房間號").Name
Dcomyfjh.BoundColumn = DBrs4.Fields("房間號").Name
If DBrs2.State = 1 Then
DBrs2.Close
End If
'設置并執行SQL語句并返回相應的數據集DBrs2,
'使其包含kf表中的所有記錄
sqlstr = "select * from kf"
DBrs2.Open sqlstr, DBcnn, adOpenStatic, adLockBatchOptimistic
'使用數據對象DBrs4來設置“源房間號”對應的
'組合框的填充字段來源和綁定字段
Set Dcommbfjh.RowSource = DBrs2
Dcommbfjh.ListField = DBrs2.Fields("房間號").Name
Dcommbfjh.BoundColumn = DBrs2.Fields("房間號").Name
If DBrs1.State = 1 Then
DBrs1.Close
End If
sqlstr = "select * from djb"
DBrs1.Open sqlstr, DBcnn, adOpenDynamic, adLockBatchOptimistic
If DBrs3.State = 1 Then
DBrs3.Close
End If
sqlstr = "select * from djys"
DBrs3.Open sqlstr, DBcnn, adOpenDynamic, adLockBatchOptimistic
End Sub
Private Sub Form_Activate()
czy.Text = main.StatusBar1.Panels(4).Text '賦值給czy.text
'查詢住宿登記信息
DBrs4.Filter = " 標志='1'"
End Sub
Private Sub Form_Unload(Cancel As Integer)
main.Enabled = True '設置主窗體有效
End Sub
Private Sub Dcommbfjh_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Texbz.SetFocus 'texbz獲得焦點
End Sub
Private Sub Dcomyfjh_Change()
'判斷輸入或選擇的房間號是否為空
If Dcomyfjh.Text <> "" Then
'輸入或選擇的房間號不為空,設置數據集對象DBrs1的Filter屬性,
'以在住宿登記表(djb)找到房間號等于用戶輸入或選擇的源房間號
'并且標志等于1的記錄
sqlstr = "房間號='" & Dcomyfjh.Text & "'and 標志='1'"
DBrs1.Filter = sqlstr
'判斷是否存在符合條件的房間號
If DBrs1.EOF Then
'不存在符合條件的房間號,給出錯誤提示
MsgBox ("請核準住宿房間和住宿人!")
Else
'存在符合上述條件的房間號,接著判斷該房間的客房類型是否為空
If DBrs1.Fields("客房類型") <> "" Then
'該房間的客房類型不為空,在該窗體中與“憑證號碼”、
'“姓名”和“證件號碼”對應的控件中顯示該房間相應的信息
With DBrs1
If .Fields("憑證號碼") <> "" Then bh.Text = .Fields("憑證號碼")
If .Fields("姓名") <> "" Then Texxmb.Text = .Fields("姓名")
If .Fields("證件名稱") <> "" Then Combo1.Text = .Fields("證件名稱")
If .Fields("證件號碼") <> "" Then Texsfz.Text = .Fields("證件號碼")
If .Fields("客房價格") <> "" Then Texjg.Text = .Fields("客房價格")
'根據源房間號來查詢與該房間類型相同并且是空房的目標房間號
sqlstr = "房間類型='" & .Fields("客房類型") & "' and 房態='空房'"
DBrs2.Filter = sqlstr
End With
End If
End If
'設置與“目標房間號”對應的組合框的使能狀態
Dcommbfjh.Enabled = True
Texbz.Enabled = True
End If
End Sub
Private Sub Dcomyfjh_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Dcommbfjh.SetFocus '按回車鍵Dcommbfjh獲得焦點
End Sub
Private Sub texbz_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Comok.SetFocus '按回車鍵comok獲得焦點
End Sub
Private Sub comdj_Click() '登記
Frame2.Enabled = True: Frame3.Enabled = True: Dcomyfjh.Enabled = True
Dcommbfjh.Enabled = True: Texjg.Enabled = True: Comok.Enabled = True
Comcancel.Enabled = True: Comok.Enabled = True: Comdj.Enabled = False
Dcomyfjh.SetFocus 'Dcomyfjh獲得焦點
End Sub
Private Sub comok_Click()
'定義一個字符串類型的變量
Dim bh As String
'設置并執行SQL語句并返回相應的數據集,使該數據集包含房間號等于
'用戶輸入或選擇的源房間號并且房態為空房的記錄
'查詢空閑房間信息
sqlstr = "房間號='" & Dcommbfjh.Text & "'and 房態='空房'"
DBrs2.Filter = sqlstr
'判斷酒店客房(kf)表是否存在符合上述條件的記錄
If DBrs2.RecordCount > 0 Then
'酒店客房(kf)表存在符合上述條件的記錄,接著設置數據集對象DBrs1的Filter屬性,
'以在住宿登記表(djb)找到房間號等于用戶輸入或選擇的源房間號
'并且標志等于1的記錄
sqlstr = "房間號 ='" & Dcomyfjh.Text & "'and 標志='1'"
DBrs1.Filter = sqlstr
bh = DBrs1.Fields("憑證號碼")
'在住宿登記(djb)表中修改該房間號的住宿登記信息
If Dcommbfjh.Text <> "" Then DBrs1.Fields("房間號") = Val(Dcommbfjh.Text)
If Texbz.Text <> "" Then DBrs1.Fields("備注") = Texbz.Text
DBrs1.Fields("標志") = "1"
DBrs1.Fields("摘要") = "由源房" & Dcomyfjh.Text & "調到目標房" & Dcommbfjh.Text
'保存此次修改操作
DBrs1.UpdateBatch
'設置數據集對象DBrs3的Filter屬性,以在住宿登記表(djb)找到房間號等于用戶
'輸入或選擇的源房間號并且標志等于1的記錄
sqlstr = "憑證號碼='" & DBrs1.Fields("憑證號碼") & "'"
DBrs3.Filter = sqlstr
If DBrs3.EOF = False Then DBrs3.MoveLast
If DBrs3.BOF = False Then DBrs3.MoveFirst
'判斷住宿預收(djys)表是否存在符合上述條件的記錄
If DBrs3.RecordCount > 0 Then
'在住宿預收(djys)表存在符合上述條件的記錄,修改所有符合條件的住宿登記預收信息
DBrs3.MoveFirst
For i = 1 To DBrs3.RecordCount
If Dcommbfjh.Text <> "" Then DBrs3.Fields("房間號") = Val(Dcommbfjh.Text)
If Texbz.Text <> "" Then DBrs3.Fields("備注") = Texbz.Text
DBrs3.Fields("標志") = "1"
DBrs3.Fields("摘要") = "由源房" & Dcomyfjh.Text & "調到目標房" & Dcommbfjh.Text
'保存所作的修改
DBrs3.UpdateBatch
If DBrs3.EOF = False Then DBrs3.MoveNext
Next i
End If
'修改目標房間號的客房狀態為“入住”
DBrs2.Fields("房態") = "入住"
DBrs2.UpdateBatch
sqlstr = "房間號 ='" & Dcomyfjh.Text & "'"
DBrs2.Filter = sqlstr
'修改源房間號的客房狀態為“空房”
DBrs2.Fields("房態") = "空房"
DBrs2.UpdateBatch
'查詢空閑房間信息
sqlstr = "房態 like '空房'"
DBrs3.Filter = sqlstr
'設置窗體中的控件的使能狀態
Texxmb.Enabled = False
Texsfz.Enabled = False
Dcommbfjh.Enabled = False
Dcomyfjh.Enabled = False
Texbz.Enabled = False
Comok.Enabled = False
Comcancel.Enabled = False
Comdj.Enabled = True
'清空窗體中的所有控件的顯示值
Dcommbfjh.Text = ""
Dcomyfjh.Text = ""
Texxmb.Text = ""
Texsfz.Text = ""
Texbz.Text = ""
Texjg.Text = ""
Comdj.SetFocus
Else
'不存在符合上述條件的記錄,給出錯誤的提示
MsgBox ("所選房間已有人入住,請選擇空房,再保存!!!")
End If
End Sub
Private Sub comcancel_Click() '取消操作
Dcomyfjh.Enabled = True: Dcommbfjh.Enabled = True: Comdj.Enabled = True
Comok.Enabled = False: Texbz.Enabled = True
Dcommbfjh.Text = "": Dcomyfjh.Text = "": Texxmb.Text = ""
Texsfz.Text = "": Texbz.Text = "": Texjg.Text = ""
End Sub
Private Sub comend_Click()
Unload Me
main.Enabled = True '設置主窗體有效
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -