?? frmyuding.frm
字號:
VERSION 5.00
Begin VB.Form frmYuDing
Caption = "預(yù)定租房"
ClientHeight = 4470
ClientLeft = 60
ClientTop = 345
ClientWidth = 8625
LinkTopic = "Form1"
ScaleHeight = 4470
ScaleWidth = 8625
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame1
Height = 2895
Left = 120
TabIndex = 3
Top = 1320
Width = 8295
Begin VB.TextBox Text1
Height = 375
Index = 8
Left = 5280
TabIndex = 23
Top = 2160
Width = 1695
End
Begin VB.TextBox Text1
Height = 375
Index = 7
Left = 1440
TabIndex = 21
Top = 2160
Width = 1215
End
Begin VB.TextBox Text1
Height = 375
Index = 6
Left = 5280
TabIndex = 19
Top = 1560
Width = 1695
End
Begin VB.TextBox Text1
Height = 375
Index = 5
Left = 1440
TabIndex = 16
Top = 1560
Width = 1215
End
Begin VB.TextBox Text1
Height = 375
Index = 4
Left = 5280
TabIndex = 13
Top = 960
Width = 1215
End
Begin VB.TextBox Text1
Height = 375
Index = 3
Left = 1440
TabIndex = 11
Top = 960
Width = 1215
End
Begin VB.TextBox Text1
Height = 375
Index = 2
Left = 6720
TabIndex = 9
Top = 360
Width = 1215
End
Begin VB.TextBox Text1
Height = 375
Index = 1
Left = 3960
TabIndex = 7
Top = 360
Width = 1215
End
Begin VB.TextBox Text1
Height = 375
Index = 0
Left = 1440
TabIndex = 5
Top = 360
Width = 1215
End
Begin VB.Label Label4
Caption = "月"
Height = 255
Left = 2760
TabIndex = 24
Top = 1680
Width = 375
End
Begin VB.Label Label1
Caption = "預(yù)定日期"
Height = 255
Index = 8
Left = 4200
TabIndex = 22
Top = 2280
Width = 735
End
Begin VB.Label Label1
Caption = "業(yè) 務(wù) 員"
Height = 255
Index = 7
Left = 360
TabIndex = 20
Top = 2280
Width = 735
End
Begin VB.Label Label1
Caption = "計(jì)劃起租日期"
Height = 255
Index = 6
Left = 3840
TabIndex = 18
Width = 1215
End
Begin VB.Label Label3
Caption = "元"
Height = 255
Left = 2760
TabIndex = 17
Top = 1080
Width = 375
End
Begin VB.Label Label1
Caption = "計(jì)劃租期"
Height = 255
Index = 5
Left = 360
TabIndex = 15
Top = 1680
Width = 735
End
Begin VB.Label Label2
Caption = "天"
Height = 255
Left = 6720
TabIndex = 14
Top = 1080
Width = 375
End
Begin VB.Label Label1
Caption = "定金有效期"
Height = 255
Index = 4
Left = 3960
TabIndex = 12
Top = 1080
Width = 975
End
Begin VB.Label Label1
Caption = "定 金"
Height = 255
Index = 3
Left = 360
TabIndex = 10
Top = 1080
Width = 735
End
Begin VB.Label Label1
Caption = "預(yù)定房屋編號"
Height = 255
Index = 2
Left = 5520
TabIndex = 8
Top = 480
Width = 1215
End
Begin VB.Label Label1
Caption = "預(yù)定客戶"
Height = 255
Index = 1
Left = 3000
TabIndex = 6
Top = 480
Width = 735
End
Begin VB.Label Label1
Caption = "預(yù)定單編號"
Height = 255
Index = 0
Left = 360
TabIndex = 4
Top = 480
Width = 975
End
End
Begin VB.Frame Frame3
Caption = "功能鍵"
Height = 975
Left = 600
TabIndex = 0
Top = 120
Width = 7335
Begin VB.CommandButton cmdDingJin
Caption = "收取定金"
Height = 495
Left = 3360
TabIndex = 27
Top = 240
Width = 975
End
Begin VB.CommandButton cmdAddQZClient
Caption = "添加求租客戶"
Height = 495
Left = 1800
TabIndex = 26
Top = 240
Width = 1215
End
Begin VB.CommandButton cmdReset
Caption = "清空重填"
Height = 495
Left = 4680
TabIndex = 25
Top = 240
Width = 975
End
Begin VB.CommandButton cmdYuDing
Caption = "預(yù) 定"
Height = 495
Left = 480
TabIndex = 2
Top = 240
Width = 975
End
Begin VB.CommandButton cmdClose
Caption = "關(guān) 閉"
Height = 495
Left = 6000
TabIndex = 1
Top = 240
Width = 975
End
End
End
Attribute VB_Name = "frmYuDing"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'定義一些變量
Dim sqlyd As String
Dim sqlhc As String
Dim sqlcc As String
Dim sqlydc As String
Dim rs_yd As New ADODB.Recordset '用于打開預(yù)定表
Dim rs_hc As New ADODB.Recordset '用于檢查房屋編號
Dim rs_cc As New ADODB.Recordset '用于檢查預(yù)定客戶
Dim rs_ydc As New ADODB.Recordset '用于檢查預(yù)定表
Private Sub cmdAddQZClient_Click()
frmQZClient.Show
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdDingJin_Click()
fromYuding = True
cmdDingJin.Enabled = False
frmPayDingJin.Show
End Sub
Private Sub cmdReset_Click()
For i = 0 To 8
Text1(i).Text = ""
Next i
'設(shè)定定金有效期為5天
Text1(4).Text = 5
'設(shè)定預(yù)定日期為當(dāng)前日期
Text1(8).Text = Date
cmdYuDing.Enabled = True
End Sub
Private Sub cmdYuDing_Click()
'預(yù)定前先檢查數(shù)據(jù)完整性
If Text1(0).Text = "" Then
MsgBox "預(yù)定單編號不可為空!", vbOKOnly + vbInformation, "注意"
Text1(0).SetFocus
Exit Sub
ElseIf Text1(1).Text = "" Then
MsgBox "預(yù)定客戶不可為空!", vbOKOnly + vbInformation, "注意"
Text1(1).SetFocus
Exit Sub
ElseIf Text1(2).Text = "" Then
MsgBox "預(yù)定房屋編號不可為空!", vbOKOnly + vbInformation, "注意"
Text1(2).SetFocus
Exit Sub
ElseIf Text1(3).Text = "" Or IsNumeric(Text1(3).Text) = False Then
MsgBox "定金應(yīng)為數(shù)字!", vbOKOnly + vbInformation, "注意"
Text1(3).SetFocus
Exit Sub
ElseIf Text1(4).Text = "" Or IsNumeric(Text1(4).Text) = False Then
MsgBox "定金有效期應(yīng)為數(shù)字!", vbOKOnly + vbInformation, "注意"
Text1(4).SetFocus
Exit Sub
ElseIf Text1(5).Text = "" Or IsNumeric(Text1(5).Text) = False Then
MsgBox "計(jì)劃租期應(yīng)為數(shù)字!", vbOKOnly + vbInformation, "注意"
Text1(5).SetFocus
Exit Sub
ElseIf Text1(6).Text = "" Or IsDate(Text1(6).Text) = False Then
MsgBox "計(jì)劃起租日期應(yīng)為這樣的日期格式:2003-7-15!", vbOKOnly + vbInformation, "注意"
Text1(6).SetFocus
Exit Sub
ElseIf Text1(7).Text = "" Then
MsgBox "業(yè)務(wù)員不可為空!", vbOKOnly + vbInformation, "注意"
Text1(7).SetFocus
Exit Sub
ElseIf Text1(8).Text = "" Or IsDate(Text1(8).Text) = False Then
MsgBox "預(yù)定日期應(yīng)為這樣的日期格式:2003-7-15!", vbOKOnly + vbInformation, "注意"
Text1(8).SetFocus
Exit Sub
End If
'判斷該預(yù)定單編號是否存在
sqlydc = "select * from YuDing where 預(yù)定單編號 = '" & Text1(0).Text & "'"
rs_ydc.Open sqlydc, conn, adOpenStatic, adLockOptimistic
If rs_ydc.EOF = False Then
MsgBox "該預(yù)定單編號已經(jīng)存在,請?zhí)钊胍粋€新的編號!", vbOKOnly + vbInformation, "注意"
rs_ydc.Close
Text1(0).SetFocus
Exit Sub
End If
rs_ydc.Close
'還需要判斷該預(yù)定客戶是否在求租客戶表中
sqlcc = "select * from QZClient where 求租客戶姓名 = '" & Text1(1).Text & "'"
rs_cc.Open sqlcc, conn, adOpenStatic, adLockOptimistic
If rs_cc.EOF = True Then
MsgBox "該預(yù)定客戶還未存入求租客戶表中,請先加入求租客戶表!", vbOKOnly + vbInformation, "注意"
rs_cc.Close
cmdAddQZClient.SetFocus
Exit Sub
End If
rs_cc.Close
'需要判斷該房屋狀態(tài),如果為已租,則提醒用戶,如果為預(yù)定,則不可預(yù)定,如果為未租,則可預(yù)定
sqlhc = "select * from House where 房屋編號 = '" & Text1(2).Text & "'"
rs_hc.Open sqlhc, conn, adOpenStatic, adLockOptimistic
If rs_hc.EOF = True Then
MsgBox "該房屋編號不存在,請選擇正確的房屋編號!", vbOKOnly + vbInformation, "注意"
Text1(2).SetFocus
rs_hc.Close
Exit Sub
Else
If rs_hc.Fields(8) = "已租" Then
'房屋為已租時,也可預(yù)定,預(yù)定以后的租期,但要提醒用戶
Dim answer As String
answer = MsgBox("該房屋已經(jīng)出租了,是否仍要預(yù)定?", vbYesNo, "注意")
If answer = vbYes Then
sqlyd = "select * from YuDing "
rs_yd.Open sqlyd, conn, adOpenStatic, adLockOptimistic
rs_yd.AddNew
For i = 0 To 8
rs_yd.Fields(i) = Text1(i).Text
Next i
rs_yd.Update
MsgBox "已成功加入預(yù)定表!", vbOKOnly + vbInformation, "注意"
rs_yd.Close
rs_hc.Close
'最后需要設(shè)置預(yù)定按鈕不可用和收取定金按鈕可用
cmdYuDing.Enabled = False
cmdDingJin.Enabled = True
Exit Sub
Else
rs_hc.Close
Exit Sub
End If
ElseIf rs_hc.Fields(8) = "未租" Then
'房屋為未租時,可以預(yù)定
sqlyd = "select * from YuDing "
rs_yd.Open sqlyd, conn, adOpenStatic, adLockOptimistic
rs_yd.AddNew
For i = 0 To 8
rs_yd.Fields(i) = Text1(i).Text
Next i
rs_yd.Update
'修改房屋狀態(tài)
rs_hc(8) = "預(yù)定"
rs_hc.Update
MsgBox "已成功加入預(yù)定表!", vbOKOnly + vbInformation, "注意"
rs_yd.Close
rs_hc.Close
'最后需要設(shè)置預(yù)定按鈕不可用和收取定金按鈕可用
cmdYuDing.Enabled = False
cmdDingJin.Enabled = True
Exit Sub
ElseIf rs_hc.Fields(8) = "預(yù)定" Then
'房屋為預(yù)定時,不可以再次預(yù)定
MsgBox "該房屋已被預(yù)定,請選擇另外的房屋!", vbOKOnly + vbInformation, "注意"
rs_hc.Close
Exit Sub
End If
End If
End Sub
Private Sub Form_Load()
Dim X0 As Long
Dim Y0 As Long
'讓窗體居中
X0 = Screen.Width
Y0 = Screen.Height
X0 = (X0 - Me.Width) / 2
Y0 = (Y0 - Me.Height) / 2
Me.Move X0, Y0
'開始時,收取定金按鈕應(yīng)不可用,必須單擊預(yù)定按鈕成功后,才設(shè)為可用
cmdDingJin.Enabled = fale
'判斷是菜單直接調(diào)用還是求租客戶資料窗體調(diào)用本窗體
If fromqzc = False Then
For i = 0 To 8
Text1(i).Text = ""
Next i
ElseIf fromqzc = True Then
Text1(1).Text = frmQZClient.Text1(1).Text
Text1(2).Text = frmQZClient.Text1(8).Text
End If
'設(shè)定定金有效期為5天
Text1(4).Text = 5
'設(shè)定預(yù)定日期為當(dāng)前日期
Text1(8).Text = Date
End Sub
Private Sub Form_Unload(Cancel As Integer)
'設(shè)置fromqzc=false
fromqzc = False
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -