forked from layerfsd/Roomer-PMS-1
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuFrmRoomReservationCancellationDialog.pas
138 lines (124 loc) · 3.89 KB
/
uFrmRoomReservationCancellationDialog.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
unit uFrmRoomReservationCancellationDialog;
interface
uses
Winapi.Windows,
Winapi.Messages,
System.SysUtils,
System.Variants,
System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,
sLabel,
sCheckBox,
sMemo,
sButton,
Vcl.ExtCtrls,
sPanel,
cxClasses,
cxPropertiesStore
, uRoomerDialogForm, sGroupBox, cxGridTableView, cxStyles, dxPScxCommon, dxPScxGridLnk, Vcl.ComCtrls, sStatusBar
;
type
TFrmRoomReservationCancellationDialog = class(TfrmBaseRoomerDialogForm)
sLabel2: TsLabel;
sGroupBox1: TsGroupBox;
sPanel1: TsPanel;
sLabel1: TsLabel;
lblResName: TsLabel;
sLabel3: TsLabel;
lblContact: TsLabel;
sLabel5: TsLabel;
lblArrival: TsLabel;
sLabel7: TsLabel;
lblDeparture: TsLabel;
sLabel9: TsLabel;
lblRooms: TsLabel;
sLabel11: TsLabel;
lblGuests: TsLabel;
sLabel4: TsLabel;
lblGuest: TsLabel;
sLabel8: TsLabel;
lblRoom: TsLabel;
mmoReason: TsMemo;
lbReservationNr: TsLabel;
lblReservationNr: TsLabel;
protected
procedure DoLoadData; override;
{ Private declarations }
public
{ Public declarations }
RoomReservation: Integer;
class function CancelRoomBookingDialog(aRoomReservation: Integer): Boolean; // function must be of type TStateChangeHandlerFunc
end;
implementation
{$R *.dfm}
uses
cmpRoomerDataSet,
uRoomerLanguage,
uAppGlobal,
uD,
hData,
uUtils
;
class function TFrmRoomReservationCancellationDialog.CancelRoomBookingDialog(aRoomReservation: Integer): Boolean;
var
_FrmRoomReservationCancellationDialog: TFrmRoomReservationCancellationDialog;
begin
result := False;
_FrmRoomReservationCancellationDialog := TFrmRoomReservationCancellationDialog.Create(nil);
try
_FrmRoomReservationCancellationDialog.RoomReservation := aRoomReservation;
if _FrmRoomReservationCancellationDialog.ShowModal = mrOK then
begin
d.roomerMainDataSet.SystemCancelRoomReservation(aRoomReservation,
Format('User %s changed state of room to cancelled on %s',
[d.roomerMainDataSet.userName, DateTimeToStr(now)]) + #13 +
ReplaceString(_FrmRoomReservationCancellationDialog.mmoReason.Text, '''', '\'''));
result := True;
end;
finally
FreeAndNil(_FrmRoomReservationCancellationDialog);
end;
end;
procedure TFrmRoomReservationCancellationDialog.DoLoadData;
var
rSet: TRoomerDataset;
sql: String;
begin
inherited;
rSet := CreateNewDataset;
sql := Format(
'SELECT r.Reservation, r.Name, r.ContactName, p.Name AS GuestName, ' +
'DATE(rr.Arrival) AS Arrival, ' +
'DATE(rr.Departure) AS Departure, ' +
'(SELECT COUNT(id) FROM roomreservations r1 WHERE r1.Reservation=r.Reservation) AS NumRooms, ' +
'(SELECT COUNT(id) FROM persons pe WHERE pe.Reservation=r.Reservation) AS NumGuests, ' +
'(SELECT COUNT(id) FROM persons pe WHERE pe.RoomReservation=rr.RoomReservation) AS NumGuestsInRoom, ' +
'(SELECT Room FROM roomsdate rd WHERE rd.RoomReservation=rr.RoomReservation AND (NOT ResFlag IN (''X'',''C'')) LIMIT 1) AS Room '
+
'FROM reservations r ' +
'INNER JOIN roomreservations rr ON rr.Reservation=r.Reservation ' +
'INNER JOIN persons p ON p.MainName=1 AND p.RoomReservation=rr.RoomReservation ' +
'WHERE rr.RoomReservation = %d ',
[RoomReservation]
);
{$ifdef DEBUG}
CopyToClipboard(sql);
{$endif}
if hData.rSet_bySQL(rSet, sql) then
begin
lblRoom.Caption := rSet['Room'];
lblGuest.Caption := rSet['GuestName'];
lblResName.Caption := rSet['Name'];
lblContact.Caption := rSet['ContactName'];
lblArrival.Caption := DateToStr(rSet['Arrival']);
lblDeparture.Caption := DateToStr(rSet['Departure']);
lblRooms.Caption := inttostr(rSet['NumRooms']);
lblGuests.Caption := inttostr(rSet['NumGuests']);
lblReservationNr.Caption := Format('%d - %d', [rSet.fieldByName('Reservation').AsInteger, RoomReservation]);
end;
end;
end.