forked from layerfsd/Roomer-PMS-1
-
Notifications
You must be signed in to change notification settings - Fork 1
/
objRoomList2.pas
461 lines (381 loc) · 11.9 KB
/
objRoomList2.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
unit objRoomList2;
interface
uses
Windows,
Forms,
Messages,
SysUtils,
Variants,
Classes,
Contnrs,
Dialogs,
NativeXML,
ADODB,
hData
, System.Generics.Collections
, uUtils
, cmpRoomerDataSet
, cmpRoomerConnection, RoomerExceptionHandling
;
TYPE
ERoomListException = class(ERoomerException);
TRoomItem = class
FRoom : string ;
FRoomDescription : string ;
FRoomType : string ;
FRoomEquipments : string ;
FBookable : boolean ;
FUseInResStatistics : boolean ;
FStatus : string ;
FOrderIndex : integer ;
Fhidden : boolean ;
FLocation : string ;
FFloor : integer ;
FuseInNationalReport : boolean ;
FCleaningNotes : string ;
FMaintenanceNotes : string ;
FLostAndFound : string ;
FReportUser : string ;
FReportUserName : string ;
FStatusDescripton : String ;
function getRoom : string ;
function getRoomDescription : string ;
function getRoomType : string ;
function getRoomEquipments : string ;
function getBookable : boolean ;
function getUseInResStatistics : boolean ;
function getStatus : string ;
function getOrderIndex : integer ;
function gethidden : boolean ;
function getLocation : string ;
function getFloor : integer ;
function getuseInNationalReport : boolean ;
procedure SetRoom(Value : string);
procedure SetRoomDescription(Value : string);
procedure SetRoomType(Value : string);
procedure SetRoomEquipments(Value : string);
procedure SetBookable(Value : boolean);
procedure SetUseInResStatistics(Value : boolean);
procedure SetStatus(Value : string);
procedure SetOrderIndex(Value : integer);
procedure Sethidden(Value : boolean);
procedure SetLocation(Value : string);
procedure SetFloor(Value : integer);
procedure SetuseInNationalReport(Value : boolean);
private
function getCleaningNotes: string;
function getLostAndFound: string;
function getMaintenanceNotes: string;
function getReportUser: string;
function getReportUserName: string;
procedure setCleaningNotes(const Value: string);
procedure setLostAndFound(const Value: string);
procedure setMaintenanceNotes(const Value: string);
procedure setReportUser(const Value: string);
procedure setReportUserName(const Value: string);
function getStatusDescripton: string;
procedure setStatusDescripton(const Value: string);
// **
public
constructor Create;
function IsNotClean: boolean;
property Room : string read getRoom write setRoom ;
property RoomDescription : string read getRoomDescription write setRoomDescription ;
property RoomType : string read getRoomType write setRoomType ;
property RoomEquipments : string read getRoomEquipments write setRoomEquipments ;
property Bookable : boolean read getBookable write setBookable ;
property UseInResStatistics : boolean read getUseInResStatistics write setUseInResStatistics ;
property Status : string read getStatus write setStatus ;
property OrderIndex : integer read getOrderIndex write setOrderIndex ;
property hidden : boolean read gethidden write sethidden ;
property Location : string read getLocation write setLocation ;
property Floor : integer read getFloor write setFloor ;
property useInNationalReport: boolean read getuseInNationalReport write setUseInNationalReport;
property CleaningNotes : string read getCleaningNotes write setCleaningNotes;
property MaintenanceNotes : string read getMaintenanceNotes write setMaintenanceNotes;
property LostAndFound : string read getLostAndFound write setLostAndFound ;
property ReportUser : string read getReportUser write setReportUser ;
property ReportUserName : string read getReportUserName write setReportUserName ;
property StatusDescripton : string read getStatusDescripton write setStatusDescripton ;
end;
TRooms = class (TObjectDictionary<String, TRoomItem>)
private
FHotelcode: string;
procedure FillList;
public
constructor Create(const aHotelCode : string); overload;
destructor Destroy; override;
function FindRoomStatus(const RoomNumber: string): string;
end;
implementation
uses //uDSp
ug
, _glob
, uD
, uAppGlobal
, uSqlDefinitions
, UITypes
;
constructor TRoomItem.Create;
begin
FCleaningNotes := '';
FMaintenanceNotes := '';
FLostAndFound := '';
FReportUser := '';
FReportUserName := '';
FStatusDescripton := '';
end;
function TRoomItem.getBookable: boolean;
begin
result := FBookable
end;
function TRoomItem.getCleaningNotes: string;
begin
result := FCleaningNotes;
end;
function TRoomItem.getFloor: integer;
begin
result := FFloor
end;
function TRoomItem.getHidden: boolean;
begin
result := FHidden
end;
function TRoomItem.getLocation: string;
begin
result := FLocation
end;
function TRoomItem.getLostAndFound: string;
begin
result := FLostAndFound;
end;
function TRoomItem.getMaintenanceNotes: string;
begin
result := FMaintenanceNotes;
end;
function TRoomItem.getOrderIndex: integer;
begin
result := FOrderIndex
end;
function TRoomItem.getReportUser: string;
begin
result := FReportUser;
end;
function TRoomItem.getReportUserName: string;
begin
result := FReportUserName;
end;
function TRoomItem.getRoom: string;
begin
result := FRoom
end;
function TRoomItem.getRoomDescription: string;
begin
result := FRoomDescription
end;
function TRoomItem.getRoomEquipments: string;
begin
result := FRoomEquipments
end;
function TRoomItem.getRoomType: string;
begin
result := FRoomType
end;
function TRoomItem.getStatus: string;
begin
result := FStatus
end;
function TRoomItem.getStatusDescripton: string;
begin
result := FStatusDescripton;
end;
function TRoomItem.getUseInNationalReport: boolean;
begin
result := FUseInNationalReport
end;
function TRoomItem.getUseInResStatistics: boolean;
begin
result := FUseInResStatistics
end;
function TRoomItem.IsNotClean: boolean;
begin
Result := not CharInSet(Status[1], ['C', 'R']);
end;
procedure TRoomItem.SetBookable(Value: boolean);
begin
FBookable := value;
end;
procedure TRoomItem.setCleaningNotes(const Value: string);
begin
FCleaningNotes := Value;
end;
procedure TRoomItem.SetFloor(Value: integer);
begin
FFloor := value
end;
procedure TRoomItem.SetHidden(Value: boolean);
begin
FHidden := value
end;
procedure TRoomItem.SetLocation(Value: string);
begin
FLocation := value
end;
procedure TRoomItem.setLostAndFound(const Value: string);
begin
FLostAndFound := Value;
end;
procedure TRoomItem.setMaintenanceNotes(const Value: string);
begin
FMaintenanceNotes := Value;
end;
procedure TRoomItem.SetOrderIndex(Value: integer);
begin
FOrderIndex := value
end;
procedure TRoomItem.setReportUser(const Value: string);
begin
FReportUser := Value;
end;
procedure TRoomItem.setReportUserName(const Value: string);
begin
FReportUserName := Value;
end;
procedure TRoomItem.SetRoom(Value: string);
begin
FRoom := value
end;
procedure TRoomItem.SetRoomDescription(Value: string);
begin
FRoomDescription := value
end;
procedure TRoomItem.SetRoomEquipments(Value: string);
begin
FRoomEquipments := value
end;
procedure TRoomItem.SetRoomType(Value: string);
begin
FRoomType := value
end;
procedure TRoomItem.SetStatus(Value: string);
begin
FStatus := value
end;
procedure TRoomItem.setStatusDescripton(const Value: string);
begin
FStatusDescripton := Value;
end;
procedure TRoomItem.SetUseInNationalReport(Value: boolean);
begin
FUseInNationalReport := value
end;
procedure TRoomItem.SetUseInResStatistics(Value: boolean);
begin
FUseInResStatistics := value
end;
constructor TRooms.Create(const aHotelCode : string);
begin
inherited Create([doOwnsValues]);
FHotelCode := aHotelCode;
try
FillList;
except
Clear;
raise;
end;
end;
destructor TRooms.Destroy;
begin
Clear;
inherited;
end;
procedure TRooms.FillList();
var
RoomItem : TRoomItem;
rSet : TRoomerDataSet;
Room : string ;
RoomDescription : string ;
RoomType : string ;
RoomEquipments : string ;
Bookable : boolean ;
useInResStatistics : boolean ;
Status : string ;
OrderIndex : integer ;
hidden : boolean ;
Location : string ;
Floor : integer ;
useInNationalReport : boolean ;
maintNotes : TRoomerDataSet;
maintCodes : TRoomerDataSet;
maintStaff : TRoomerDataSet;
begin
Clear;
if NOT d.roomerMainDataSet.LoggedIn then exit;
glb.RefreshTablesWhenNeeded;
maintNotes := glb.Maintenanceroomnotes;
maintCodes := glb.MaintenanceCodes;
maintStaff := glb.Staffmembers;
rSet := glb.RoomsSet;
Rset.First;
While not rSet.Eof do
begin
hidden := Rset['hidden'];
if not hidden then
begin
RoomItem := TRoomItem.Create;
try
Room := Rset.fieldbyname('Room').asString;
RoomDescription := Rset.fieldbyname('Description').asString;
RoomType := Rset.fieldbyname('RoomType').asString;
RoomEquipments := Rset.fieldbyname('Equipments').asString;
Location := Rset.fieldbyname('Location').asString;
Floor := Rset.fieldbyname('Floor').asInteger;
Bookable := Rset['Bookable'];
useinResStatistics := Rset['Statistics'];
useInNationalReport := Rset['useInNationalReport'];
Status := Rset.fieldbyname('Status').asString;
OrderIndex := Rset.fieldbyname('OrderIndex').asInteger;
RoomItem.SetRoom(Room);
RoomItem.SetRoomDescription(RoomDescription);
RoomItem.SetRoomType(RoomType);
RoomItem.SetRoomEquipments(RoomEquipments);
RoomItem.SetBookable(Bookable);
RoomItem.SetUseInResStatistics(UseInResStatistics);
RoomItem.SetStatus(Status);
RoomItem.SetOrderIndex(OrderIndex);
RoomItem.Sethidden(hidden);
RoomItem.SetLocation(Location);
RoomItem.SetFloor(Floor);
RoomItem.SetUseInNationalReport(UseInNationalReport);
if glb.LocateSpecificRecord('maintenanceroomnotes', 'Room', Room) then
begin
RoomItem.CleaningNotes := maintNotes['CleaningNotes'];
RoomItem.MaintenanceNotes := maintNotes['MaintenanceNotes'];
RoomItem.LostAndFound := maintNotes['LostAndFound'];
if glb.LocateSpecificRecord('staffmembers', 'id', maintNotes.FieldByName('StaffIdReported').AsInteger) then
begin
RoomItem.ReportUser := maintStaff['Initials'];
RoomItem.ReportUserName := maintStaff['Name'];
end;
if glb.LocateSpecificRecord('maintenancecodes', 'Code', Status) then
RoomItem.StatusDescripton := maintCodes['name'];
end;
Add(Lowercase(Room), RoomItem);
except
on E: Exception do
ERoomListException.Create('Exception during update of roomslist: ' + e.message);
end;
end;
rSet.Next;
end;
end;
function TRooms.FindRoomStatus(const RoomNumber: string): string;
var
RoomItem : TRoomItem;
begin
if Application.Terminated then exit;
result := '';
if TryGetValue(RoomNumber, RoomItem) then
result := RoomItem.FStatus;
end;
end.