📄 frmcheckin.frm
字号:
If .RecordCount > 0 Then
txtRate.Text = toMoney(!RoomRate)
hsAdults.Min = !NoofPerson
txtAdults.Tag = !ExtraAdultRate
txtChildrens.Tag = !ExtraChildRate
End If
End With
DisplayForEditing
cmdCheckInOut.Caption = "Check Out"
CmdChangeRoom.Enabled = True
cmdUpdateDelete.Enabled = True
CmdPrint.Visible = True
Call txtDays_Change
Call ComputeRate
Else 'adStatePopupMode
RS.Open "SELECT * FROM Transactions WHERE FolioNumber = '" & PopupPK & "'", CN, adOpenStatic, adLockOptimistic
rsRoomRates.Open "SELECT * FROM [Room Rates] WHERE RoomNumber = " & PK & " AND RateTypeID = " & dcRateType.BoundText, CN, adOpenStatic, adLockOptimistic
With rsRoomRates
If .RecordCount > 0 Then
txtRate.Text = toMoney(!RoomRate)
hsAdults.Min = !NoofPerson
txtAdults.Tag = !ExtraAdultRate
txtChildrens.Tag = !ExtraChildRate
End If
End With
DisplayForEditing
cmdCheckInOut.Caption = "Check Out"
Me.CmdChangeRoom.Enabled = True
Me.cmdUpdateDelete.Enabled = True
Call ComputeRate
CmdPrint.Visible = True
CmdPrint.Left = 634
CmdPrint.Top = 442
CmdChangeRoom.Visible = False
cmdCheckInOut.Visible = False
cmdUpdateDelete.Visible = False
End If
rsRoomRates.Close
CN.Execute "DELETE FolioNumber " & _
"From [Rate Per Period Temp] " & _
"WHERE FolioNumber='" & txtFolioNumber.Text & "'"
CN.Execute "INSERT INTO [Rate Per Period Temp] " & _
"SELECT [Rate Per Period].* " & _
"From [Rate Per Period] " & _
"WHERE FolioNumber='" & txtFolioNumber.Text & "'"
CN.CommitTrans
Exit Sub
err:
CN.RollbackTrans
prompt_err err, Name, "Form_Load"
Screen.MousePointer = vbDefault
End Sub
'Procedure used to generate PK
Private Sub GeneratePK()
PK = getIndex("Transactions")
txtFolioNumber.Text = GenerateID(PK, Format$(Date, "yy") & "-", "00000")
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lblAmountPaid.FontUnderline = False
lblRatePerPeriod.FontUnderline = False
lblOtherCharges.FontUnderline = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
If HaveAction = True Then
frmRoomsWindow.RefreshRecords
End If
Unload frmRatePerPeriod
Unload frmOtherCharges
Unload frmPayment
Set frmRatePerPeriod = Nothing
Set frmOtherCharges = Nothing
Set frmPayment = Nothing
Set frmCheckIn = Nothing
End Sub
Private Sub ResetEntry()
' txtBranch.Text = ""
' txtAcctNo.Text = ""
' txtAcctName.Text = ""
End Sub
Private Sub hsAdults_Change()
txtAdults.Text = hsAdults.Value
Call ComputeAdultsRate
Call ComputeRate
End Sub
Private Sub hsChildrens_Change()
txtChildrens.Text = hsChildrens.Value
Call ComputeChildrensRate
Call ComputeRate
End Sub
Private Sub hsDays_Change()
dtpDateOut.Value = dtpDateIn.Value + hsDays.Value
txtDays.Text = hsDays.Value
Call ComputeRate
End Sub
Private Sub ComputeRate()
txtTotalCharges.Text = toMoney(ComputeRatePerPeriod)
txtSubTotal.Text = toMoney(toNumber(txtTotalCharges.Text) + toNumber(txtOtherCharges.Text))
txtTotal.Text = toMoney(toNumber(txtSubTotal.Text) - (toNumber(txtSubTotal.Text) * toNumber(txtDiscount.Text) / 100))
txtBalance.Text = toMoney(toNumber(txtTotal.Text) - toNumber(txtAmountPaid.Text))
End Sub
Private Sub lblAmountPaid_Click()
With frmPayment
.FolioNumber = txtFolioNumber.Text
.GuestName = txtFirstName.Text & " " & txtLastName.Text
.Balance = txtBalance.Text
.RefreshBalance
Set .RefForm = Me
.Show vbModal
txtAmountPaid.Text = toMoney(AmountPaid)
End With
End Sub
Private Sub lblAmountPaid_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
SetHandCur True
lblAmountPaid.FontUnderline = True
End Sub
Private Sub lblOtherCharges_Click()
With frmOtherCharges
.FolioNumber = txtFolioNumber.Text
.GuestName = txtFirstName.Text & " " & txtLastName.Text
Set .RefForm = Me
.Show vbModal
txtOtherCharges.Text = toMoney(OtherCharges)
End With
Call ComputeRate
End Sub
Private Sub lblOtherCharges_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
SetHandCur True
lblOtherCharges.FontUnderline = True
End Sub
Private Sub lblRatePerPeriod_Click()
With frmRatePerPeriod
.FolioNumber = txtFolioNumber.Text
.Show vbModal
Call ComputeRate
End With
End Sub
Private Sub lblRatePerPeriod_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
SetHandCur True
lblRatePerPeriod.FontUnderline = True
End Sub
Private Sub ComputeAdultsRate()
On Error GoTo err
Dim rsRatePerPeriod As New ADODB.Recordset
If txtAdults.Tag = "" Then Exit Sub
CN.BeginTrans
Dim intAdults As Integer
If txtAdults.Text = hsAdults.Min Then
intAdults = 0
Else
intAdults = CInt(txtAdults.Text) - hsAdults.Min
End If
With rsRatePerPeriod
.Open "SELECT * FROM [Rate Per Period] WHERE FolioNumber = '" & txtFolioNumber.Text & "' AND [Date] = #" & dtpDateOut.Value - 1 & "#", CN, adOpenStatic, adLockOptimistic
If .RecordCount = 1 Then
.Fields("Adults") = txtAdults.Tag * intAdults
.Update
End If
End With
CN.CommitTrans
rsRatePerPeriod.Close
Exit Sub
err:
CN.RollbackTrans
prompt_err err, Name, "ComputeAdultsRate"
Screen.MousePointer = vbDefault
End Sub
Private Sub ComputeChildrensRate()
On Error GoTo err
Dim rsRatePerPeriod As New ADODB.Recordset
If txtChildrens.Tag = "" Then Exit Sub
CN.BeginTrans
With rsRatePerPeriod
.Open "SELECT * FROM [Rate Per Period] WHERE FolioNumber = '" & txtFolioNumber.Text & "' AND [Date] = #" & dtpDateOut.Value - 1 & "#", CN, adOpenStatic, adLockOptimistic
If .RecordCount = 1 Then
.Fields("Childrens") = txtChildrens.Tag * txtChildrens.Text
.Update
End If
End With
CN.CommitTrans
rsRatePerPeriod.Close
Exit Sub
err:
CN.RollbackTrans
prompt_err err, Name, "ComputeChildrensRate"
Screen.MousePointer = vbDefault
End Sub
Private Sub txtAmountPaid_Change()
txtBalance.Text = toMoney(toNumber(txtTotal.Text) - toNumber(txtAmountPaid.Text))
End Sub
Private Sub txtDays_Change()
On Error GoTo err
Dim rsRatePerPeriod As New ADODB.Recordset
Dim tmpDate As Date
tmpDate = dtpDateIn.Value
If txtAdults.Tag = "" Then Exit Sub
CN.BeginTrans
CN.Execute "DELETE [Date] " & _
"FROM [Rate Per Period] " & _
"WHERE [Date]>#" & dtpDateOut - 1 & "#"
Dim intAdults As Integer
If txtAdults.Text = hsAdults.Min Then
intAdults = 0
Else
intAdults = CInt(txtAdults.Text) - hsAdults.Min
End If
With rsRatePerPeriod
.Open "SELECT * FROM [Rate Per Period] WHERE FolioNumber = '" & txtFolioNumber.Text & "' ORDER BY [Date]", CN, adOpenStatic, adLockOptimistic
Do Until tmpDate > dtpDateOut.Value - 1
.Filter = "[Date] = #" & tmpDate & "#"
If .RecordCount = 0 Then
.AddNew
.Fields("FolioNumber") = txtFolioNumber.Text
.Fields("Date") = tmpDate
.Fields("RoomNumber") = txtRoomNumber.Text
.Fields("RateTypeID") = dcRateType.BoundText
.Fields("Rate") = txtRate.Text
.Fields("Adults") = txtAdults.Tag * intAdults
.Fields("Childrens") = toMoney(txtChildrens.Tag) * toNumber(txtChildrens.Text)
.Update
End If
tmpDate = tmpDate + 1
Loop
End With
CN.CommitTrans
rsRatePerPeriod.Close
Exit Sub
err:
CN.RollbackTrans
prompt_err err, Name, "txtDays_Change"
Screen.MousePointer = vbDefault
End Sub
Private Sub txtDiscount_Change()
Call ComputeRate
End Sub
Private Function ComputeRatePerPeriod() As Currency
On Error GoTo err
Dim rsRoomRates As New ADODB.Recordset
With rsRoomRates
.Open "SELECT * FROM [Rate Per Period] WHERE FolioNumber = '" & txtFolioNumber.Text & "'", CN, adOpenStatic, adLockOptimistic
Do Until .EOF
ComputeRatePerPeriod = ComputeRatePerPeriod + toMoney(!Rate) + toMoney(!Adults) + toMoney(!Childrens)
.MoveNext
Loop
End With
rsRoomRates.Close
Exit Function
err:
CN.RollbackTrans
prompt_err err, Name, "ComputeRatePerPeriod"
Screen.MousePointer = vbDefault
End Function
Private Sub txtDiscount_GotFocus()
HLText txtDiscount
End Sub
Private Sub txtDiscount_KeyPress(KeyAscii As Integer)
KeyAscii = isNumber(KeyAscii)
End Sub
Private Sub txtDiscount_Validate(Cancel As Boolean)
txtDiscount.Text = toMoney(txtDiscount.Text)
End Sub
Private Sub txtRate_GotFocus()
HLText txtRate
End Sub
Private Sub txtRate_KeyPress(KeyAscii As Integer)
KeyAscii = isNumber(KeyAscii)
End Sub
Private Sub txtRate_Validate(Cancel As Boolean)
txtRate.Text = toMoney(txtRate.Text)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -