forked from layerfsd/Roomer-PMS-1
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuAssignPayment.pas
739 lines (646 loc) · 22.1 KB
/
uAssignPayment.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
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
unit uAssignPayment;
interface
uses
Winapi.Windows
, Winapi.Messages
, System.SysUtils
, System.Variants
, System.Classes
, Vcl.Graphics
, Vcl.Controls
, Vcl.Forms
, Vcl.Dialogs
, Vcl.Buttons
, Vcl.StdCtrls
, Vcl.ComCtrls
, Vcl.ExtCtrls
, Vcl.Menus
, hdata
,_glob
,ug
, uAppglobal
,ustringUtils
,uSqlDefinitions
,cmpRoomerDataSet
,cmpRoomerConnection
, sSpeedButton
, sEdit
, sLabel
, sComboBox
, sButton
, sPageControl
, sGroupBox
, sPanel
, sStatusBar
, sMemo
, cxGraphics
, cxLookAndFeels
, cxLookAndFeelPainters, cxClasses, cxPropertiesStore, Vcl.Mask, sMaskEdit, sCustomComboEdit, sCurrEdit
;
type
TfrmAssignPayment = class(TForm)
sPanel1: TsPanel;
sGroupBox2: TsGroupBox;
sPageControl1: TsPageControl;
sTabSheet1: TsTabSheet;
btnSetToGroupAccount: TsButton;
sGroupBox1: TsGroupBox;
__cbxRoomSelect: TsComboBox;
sTabSheet2: TsTabSheet;
sGroupBox3: TsGroupBox;
sLabel1: TsLabel;
edSetToGroupReservation: TsEdit;
btnCkeckReservation: TsSpeedButton;
sGroupBox4: TsGroupBox;
sLabel2: TsLabel;
btnCheckRoomReservation: TsSpeedButton;
edSetToRoomReservation: TsEdit;
clabReservation: TsLabel;
clabCustomer: TsLabel;
clabArrivalDeparture: TsLabel;
clabRoom: TsLabel;
clabPaymentType: TsLabel;
clabDate: TsLabel;
clabAmount: TsLabel;
clabdescription: TsLabel;
clabNotes: TsLabel;
edNotes: TsMemo;
edDescription: TsEdit;
labReservation: TsLabel;
labCustomer: TsLabel;
labArrivalDeparture: TsLabel;
labDate: TsLabel;
labRoom: TsLabel;
labCheckReservation: TsLabel;
labCheckRoomReservation: TsLabel;
btnExceuteAssingToroom: TsButton;
btnExecuteRoomReservation: TsButton;
btnExecureReservation: TsButton;
Panel1: TsPanel;
__cbxPaymentType: TsComboBox;
edAmount: TsCalcEdit;
FormStore: TcxPropertiesStore;
sButton1: TsButton;
sButton2: TsButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btnSetToGroupAccountClick(Sender: TObject);
procedure btnCkeckReservationClick(Sender: TObject);
procedure btnCheckRoomReservationClick(Sender: TObject);
procedure btnExceuteAssingToroomClick(Sender: TObject);
procedure btnExecuteRoomReservationClick(Sender: TObject);
procedure btnExecureReservationClick(Sender: TObject);
procedure __cbxRoomSelectCloseUp(Sender: TObject);
procedure btnOKClick(Sender: TObject);
private
{ Private declarations }
zIsGroupInvoice : boolean;
zGroupAvailable : boolean;
rec : recPaymentHolder;
zPaymentID : integer;
public
{ Public declarations }
end;
function OpenAssignPayment(PaymentID : integer) : boolean;
var
frmAssignPayment: TfrmAssignPayment;
implementation
{$R *.dfm}
uses
uD,
uActivityLogs,
uRoomerLanguage
, uUtils
, uSQLUtils
, UITypes, uVCLUtils;
function OpenAssignPayment(paymentID : integer) : boolean;
begin
result := false;
frmAssignPayment := TfrmAssignPayment.Create(frmAssignPayment);
try
frmAssignPayment.zPaymentID := PaymentID;
frmAssignPayment.ShowModal;
if frmAssignPayment.modalresult = mrOk then
begin
result := true;
end else
begin
end;
finally
freeandnil(frmAssignPayment);
end;
end;
procedure TfrmAssignPayment.FormClose(Sender: TObject; var Action: TCloseAction);
begin
//**
end;
procedure TfrmAssignPayment.FormCreate(Sender: TObject);
begin
RoomerLanguage.TranslateThisForm(self);
glb.PerformAuthenticationAssertion(self);
PlaceFormOnVisibleMonitor(self);
end;
procedure TfrmAssignPayment.FormDestroy(Sender: TObject);
begin
//**
end;
procedure TfrmAssignPayment.FormShow(Sender: TObject);
var
rSet : TRoomerDataset;
s : string;
sTmp : string;
i,p : integer;
payType : string;
itemIndex : integer;
begin
rSet := CreateNewDataSet;
try
__cbxPaymentType.clear;
s := '';
s := s+'Select paytype,description,paygroup From paytypes where (active=true) and PayGroup <> '+_db(g.qInvPriceGroup)+' order by paygroup ';
if rSet_bySQL(rSet,s) then
begin
while not rSet.Eof do
begin
__cbxPaymentType.items.add(rSet.fieldbyname('Paytype').AsString+' - '+rSet.fieldbyname('description').AsString);
rSet.Next;
end;
end;
finally
freeandnil(rSet);
end;
initPaymentHolderRec(rec);
d.roomerMainDataSet.SetTimeZoneComparedToUTC('');
rSet := CreateNewDataSet;
try
s := '';
s := s+' SELECT '#10;
s := s+' pm.Reservation '#10;
s := s+' ,pm.RoomReservation '#10;
s := s+' ,pm.Person '#10;
s := s+' ,pm.TypeIndex '#10;
s := s+' ,pm.InvoiceNumber '#10;
s := s+' ,date(pm.PayDate) AS payDate '#10;
s := s+' ,pm.Customer '#10;
s := s+' ,pm.PayType '#10;
s := s+' ,pm.Amount '#10;
s := s+' ,pm.Description '#10;
s := s+' ,pm.CurrencyRate '#10;
s := s+' ,pm.Currency '#10;
s := s+' ,pm.confirmDate '#10;
s := s+' ,pm.Notes '#10;
s := s+' ,pm.dtCreated '#10;
s := s+' ,pm.id '#10;
s := s+' ,rv.name AS ReservationName '#10;
s := s+' ,rv.channel '#10;
s := s+' ,rv.invRefrence AS Refrence '#10;
s := s+' , RR_Arrival(pm.roomreservation, false) as Arrival '#10;
s := s+' , RR_Departure(pm.roomreservation, false) as Departure '#10;
s := s+' ,rr.room '#10;
s := s+' ,chnl.Name AS ChannelName '#10;
s := s+' ,cust.surname AS CustomerName '#10;
s := s+' FROM '#10;
s := s+' payments pm '#10;
s := s+' LEFT OUTER JOIN reservations rv ON pm.reservation = rv.reservation '#10;
s := s+' LEFT OUTER JOIN roomreservations rr ON pm.roomreservation = rr.roomreservation '#10;
s := s+' LEFT OUTER JOIN channels chnl ON rv.channel = chnl.id '#10;
s := s+' LEFT OUTER JOIN customers cust ON pm.customer = cust.Customer '#10;
s := s+'WHERE pm.id='+_db(zPaymentId)+' ';
if rSet_bySQL(rSet,s) then
begin
rSet.First;
if not rSet.eof then
begin
rec.ID := zPaymentId;
rec.Reservation := rSet.FieldByName('reservation').AsInteger;
rec.RoomReservation := rSet.FieldByName('roomreservation').AsInteger;
rec.Person := rSet.FieldByName('Person').AsInteger;
rec.TypeIndex := rSet.FieldByName('TypeIndex').AsInteger;
rec.InvoiceNumber := rSet.FieldByName('InvoiceNumber').AsInteger;
rec.PayDate := rSet.FieldByName('PayDate').AsString;
rec.Customer := rSet.FieldByName('Customer').AsString;
rec.PayType := rSet.FieldByName('PayType').AsString;
rec.NativeAmount := rSet.FieldByName('Amount').AsFloat;
rec.Description := rSet.FieldByName('Description').AsString;
rec.CurrencyRate := rSet.FieldByName('CurrencyRate').AsFloat;
rec.Currency := rSet.FieldByName('Currency').AsString;
rec.confirmDate := rSet.FieldByName('confirmDate').AsDateTime; // '1900-01-01 00:00:00'
rec.Notes := rSet.FieldByName('Notes').AsString;
rec.dtCreated := rSet.FieldByName('dtCreated').AsDateTime;
labRoom.caption := rSet.FieldByName('Room').AsString;
labCustomer.Caption := rSet.FieldByName('customer').asstring+' - '+rSet.FieldByName('customername').asstring;
labReservation.Caption := rSet.FieldByName('reservationName').asstring;
labArrivalDeparture.Caption := dateToStr(rSet.FieldByName('Arrival').asdatetime)+' - '+dateToStr(rSet.FieldByName('Departure').asdatetime);
labRoom.Caption := rSet.FieldByName('Room').asString;
labDate.Caption := datetimeTostr(rSet.FieldByName('dtCreated').asDateTime);
edAmount.Value := rSet.FieldByName('Amount').AsFloat;
itemIndex := -1;
for i := 0 to __cbxPaymentType.items.count-1 do
begin
sTmp := __cbxPaymentType.items[i];
p := pos(' - ',sTmp);
paytype := _trimlower(copy(sTmp,1,p));
if _trimLower(rec.payType) = payType then itemindex := i;
end;
__cbxPaymentType.Itemindex := itemindex;
edDescription.Text := rSet.FieldByName('description').asString;
edNotes.Text := rSet.FieldByName('Notes').Text;
end;
end;
finally
freeandnil(rSet);
end;
zIsGroupInvoice := rec.RoomReservation=0;
zGroupAvailable := false;
rSet := CreateNewDataSet;
try
s := '';
s := s+' SELECT '#10;
s := s+' roomReservation '#10;
s := s+' ,GroupAccount'#10;
s := s+' FROM '#10;
s := s+' roomreservations '#10;
s := s+' WHERE '#10;
s := s+' (reservation = '+_db(rec.reservation)+') and (Groupaccount=1) ';
if rSet_bySQL(rSet,s) then
begin
if not rSet.eof then
begin
zGroupAvailable := true;
end;
__cbxRoomSelect.ItemIndex := 0;
end;
finally
freeandnil(rSet);
end;
btnSetToGroupAccount.enabled := (zIsGroupInvoice=false);
rSet := CreateNewDataSet;
try
s := '';
s := s+' SELECT '#10;
s := s+' rr.roomReservation '#10;
s := s+' , rr.room '#10;
s := s+' ,'+format(Get_mainGuestname,['pe','pe','rr','GuestName'])+#10;
s := s+' FROM '#10;
s := s+' roomreservations rr '#10;
s := s+' WHERE '#10;
s := s+' (rr.reservation= '+_db(rec.Reservation)+') '#10;
if labRoom.caption <> '' then
begin
s := s+' AND (rr.room <> '+_db(labRoom.caption)+') ';
end;
__cbxRoomSelect.Clear;
if rSet_bySQL(rSet,s) then
begin
__cbxRoomSelect.items.add('None');
rSet.First;
while not rSet.eof do
begin
__cbxRoomSelect.Items.Add(rSet.FieldByName('room').asstring+' - '+rSet.FieldByName('Guestname').asstring);
rSet.Next;
end;
__cbxRoomSelect.ItemIndex := 0;
end;
finally
freeandnil(rSet);
end;
sGroupBox1.Visible := __cbxRoomSelect.Items.Count > 1;
sPageControl1.ActivePageIndex := 0;
if (not sGroupBox1.visible) and (not btnSetToGroupAccount.visible) then
begin
sTabSheet1.TabVisible := false;
sPageControl1.ActivePageIndex := 1;
end;
end;
procedure TfrmAssignPayment.btnCkeckReservationClick(Sender: TObject);
var
rSet : TRoomerDataset;
s : string;
SetToGroupReservation : integer;
begin
SetToGroupReservation := strToInt(edSetToGroupReservation.Text);
btnExecureReservation.Enabled := false;
labCheckReservation.caption := '-';
rSet := CreateNewDataSet;
try
s := '';
s := s+' SELECT '#10;
s := s+' rv.Reservation '#10;
s := s+' ,rv.Customer '#10;
s := s+' ,rv.name AS ReservationName '#10;
s := s+' ,rv.channel '#10;
s := s+' ,rv.arrival '#10;
s := s+' ,rv.departure '#10;
s := s+' ,chnl.Name AS ChannelName '#10;
s := s+' ,cust.surname AS CustomerName '#10;
s := s+' FROM '#10;
s := s+' Reservations rv '#10;
s := s+' LEFT OUTER JOIN channels chnl ON rv.channel = chnl.id '#10;
s := s+' LEFT OUTER JOIN customers cust ON rv.customer = cust.Customer '#10;
s := s+'WHERE rv.Reservation='+_db(SetToGroupReservation)+' ';
if rSet_bySQL(rSet,s) then
begin
s := '';
s := s+' Customer : '+rset.FieldByName('Customer').AsString+' '+rset.FieldByName('reservationName').AsString+' '#10;
s := s+' Reservation : '+rset.FieldByName('reservationName').AsString+' '#10;
s := s+' Arrival : '+rset.FieldByName('Arrival').AsString+' Departure : '+rset.FieldByName('Departure').AsString+' '#10;
labCheckReservation.caption := s;
btnExecureReservation.Enabled := true;
end else
begin
labCheckReservation.caption := 'Reservation not found';
end;
finally
freeandnil(rSet);
end;
end;
procedure TfrmAssignPayment.btnExecuteRoomReservationClick(Sender: TObject);
var
rSet : TRoomerDataset;
newReservation : integer;
newRoomreservation : integer;
s : string;
p : integer;
payType : string;
begin
p := pos(' - ',__cbxPaymentType.items[__cbxPaymentType.itemIndex]);
paytype := trim(copy(__cbxPaymentType.items[__cbxPaymentType.itemIndex],1,p));
newRoomReservation := strToInt(edSetToRoomReservation.text);
newReservation := -1;
rSet := CreateNewDataSet;
try
s := '';
s := s+' SELECT '#10;
s := s+' Reservation '#10;
s := s+' FROM '#10;
s := s+' roomreservations '#10;
s := s+'WHERE RoomReservation='+_db(newRoomReservation)+' ';
if rSet_bySQL(rSet,s) then
begin
newReservation := rSet.FieldByName('reservation').asInteger;
end;
finally
freeandnil(rSet);
end;
if MessageDlg('Set payment to '#10#10+labCheckRoomReservation.caption, mtConfirmation, [mbYes, mbNo], 0) = mrYes then
begin
if newRoomReservation <> 0 then
begin
s := '';
s := s+' UPDATE payments '+#10;
s := s+' SET '+#10;
s := s+' roomreservation ='+_db(newroomreservation)+' '+#10;
s := s+' ,reservation ='+_db(newReservation)+' '+#10;
s := s+' ,description ='+_db(edDescription.text)+' '+#10;
s := s+' ,notes ='+_db(edNotes.Text)+' '+#10;
s := s+' ,amount ='+_db(edAmount.value)+' '+#10;
s := s+' ,PayType ='+_db(payType)+' '+#10;
s := s+' WHERE '+#10;
s := s+' (ID = '+_db(rec.id)+') '+#10;
if cmd_bySQL(s) then
begin
AddInvoiceActivityLog(g.quser
,newroomreservation
,newReservation
,1
,CHANGE_PAYMENT
,payType
,edAmount.value
,-1
,edDescription.text);
modalresult := mrOK;
end;
end;
end;
end;
procedure TfrmAssignPayment.btnCheckRoomReservationClick(Sender: TObject);
var
rSet : TRoomerDataset;
s : string;
SetToRoomReservation : integer;
begin
SetToRoomReservation := strToInt(edSetToRoomReservation.Text);
btnExecuteRoomReservation.Enabled := false;
labCheckRoomReservation.caption := '-';
rSet := CreateNewDataSet;
try
s := '';
s := s+' SELECT '#10;
s := s+' rr.roomReservation '#10;
s := s+' ,rr.Reservation '#10;
s := s+' , RR_Arrival(rr.Roomreservation, false) as Arrival '#10;
s := s+' , RR_Departure(rr.Roomreservation, false) as Departure '#10;
s := s+' ,rr.room '#10;
s := s+' ,rr.GroupAccount '#10;
s := s+' ,rv.Customer '#10;
s := s+' ,rv.name AS ReservationName '#10;
s := s+' ,rv.channel '#10;
s := s+' ,rv.invRefrence AS Refrence '#10;
s := s+' ,chnl.Name AS ChannelName '#10;
s := s+' ,cust.surname AS CustomerName '#10;
s := s+' ,'+format(Get_mainGuestname,['pe','pe','rr','GuestName'])+#10;
// s := s+' ,(Select Name from persons pe where (pe.roomreservation = rr.roomreservation) and (mainName=1)) AS GuestName '#10;
s := s+' FROM '#10;
s := s+' RoomReservations rr '#10;
s := s+' LEFT OUTER JOIN reservations rv ON rv.reservation = rr.reservation '#10;
s := s+' LEFT OUTER JOIN channels chnl ON rv.channel = chnl.id '#10;
s := s+' LEFT OUTER JOIN customers cust ON rv.customer = cust.Customer '#10;
s := s+'WHERE rr.roomReservation='+_db(SetToRoomReservation)+' ';
if rSet_bySQL(rSet,s) then
begin
s := '';
s := s+' Customer : '+rset.FieldByName('Customer').AsString+' '+rset.FieldByName('reservationName').AsString+' '#10;
s := s+' Guest : '+rset.FieldByName('GuestName').AsString+' '#10;
s := s+' Reservation : '+rset.FieldByName('reservationName').AsString+' '#10;
s := s+' Room : '+rSet.FieldByName('room').AsString+' - Arrival : '+dateToStr(rset.FieldByName('Arrival').AsDateTime)+' Departure : '+dateToStr(rset.FieldByName('Departure').AsDateTime)+' '#10;
labCheckRoomReservation.caption := s;
btnExecuteRoomReservation.Enabled := true;
end else
begin
labCheckRoomReservation.caption := 'RoomReservation not found';
end;
finally
freeandnil(rSet);
end;
end;
procedure TfrmAssignPayment.btnSetToGroupAccountClick(Sender: TObject);
var
s : string;
p : integer;
payType : string;
begin
p := pos(' - ',__cbxPaymentType.items[__cbxPaymentType.itemIndex]);
paytype := trim(copy(__cbxPaymentType.items[__cbxPaymentType.itemIndex],1,p));
if MessageDlg('Set payment to groupinvoice', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
begin
s := '';
s := s+' UPDATE payments '+#10;
s := s+' SET '+#10;
s := s+' roomreservation = 0 '+#10;
s := s+' ,description ='+_db(edDescription.text)+' '+#10;
s := s+' ,notes ='+_db(edNotes.text)+' '+#10;
s := s+' ,amount ='+_db(edAmount.value)+' '+#10;
s := s+' ,PayType ='+_db(payType)+' '+#10;
s := s+' WHERE '+#10;
s := s+' (ID = '+_db(rec.id)+') '+#10;
if cmd_bySQL(s) then
begin
modalresult := mrOK;
//**log** update payment
AddInvoiceActivityLog(g.quser
,0
,rec.Reservation
,1
,CHANGE_PAYMENT
,payType
,edAmount.value
,-1
,'Set payment to Groupinvoice : ' +edDescription.text);
end;
end;
end;
procedure TfrmAssignPayment.__cbxRoomSelectCloseUp(Sender: TObject);
begin
btnExceuteAssingToRoom.enabled := __cbxRoomSelect.ItemIndex > 0;
end;
procedure TfrmAssignPayment.btnExceuteAssingToroomClick(Sender: TObject);
var
s : string;
rSet : TRoomerDataSet;
roomreservation : integer;
room : string;
sTmp : string;
p : integer;
payType : string;
begin
p := pos(' - ',__cbxPaymentType.items[__cbxPaymentType.itemIndex]);
paytype := trim(copy(__cbxPaymentType.items[__cbxPaymentType.itemIndex],1,p));
sTmp := __cbxRoomselect.Items[__cbxRoomselect.Itemindex];
p := pos(' - ',sTmp);
room := trim(copy(sTmp,1,p));
roomreservation := 0;
rSet := CreateNewDataSet;
try
s := '';
s := s+' SELECT '#10;
s := s+' rr.RoomReservation '#10;
s := s+' FROM '#10;
s := s+' roomreservations rr '#10;
s := s+' WHERE '#10;
s := s+' (rr.room = '+_db(room)+') and (rr.reservation='+_db(rec.reservation)+' ) ';
if rSet_bySQL(rSet,s) then
begin
if not rSet.eof then
begin
roomreservation := rSet.FieldByName('roomreservation').AsInteger;
end;
end;
finally
freeandnil(rSet);
end;
if MessageDlg('Set payment to '+room, mtConfirmation, [mbYes, mbNo], 0) = mrYes then
begin
if roomreservation <> 0 then
begin
s := '';
s := s+' UPDATE payments '+#10;
s := s+' SET '+#10;
s := s+' roomreservation ='+_db(roomreservation)+' '+#10;
s := s+' ,description ='+_db(edDescription.text)+' '+#10;
s := s+' ,notes ='+_db(edNotes.text)+' '+#10;
s := s+' ,amount ='+_db(edAmount.value)+' '+#10;
s := s+' ,PayType ='+_db(payType)+' '+#10;
s := s+' WHERE '+#10;
s := s+' (ID = '+_db(rec.id)+') '+#10;
if cmd_bySQL(s) then
begin
modalresult := mrOK;
AddInvoiceActivityLog(g.quser
,roomreservation
,rec.Reservation
,1
,CHANGE_PAYMENT
,payType
,edAmount.value
,-1
,'Set payment to Room : ' +edDescription.text);
end;
end;
end;
end;
procedure TfrmAssignPayment.btnExecureReservationClick(Sender: TObject);
var
newReservation : integer;
newRoomreservation : integer;
s : string;
p : integer;
payType : string;
begin
p := pos(' - ',__cbxPaymentType.items[__cbxPaymentType.itemIndex]);
paytype := trim(copy(__cbxPaymentType.items[__cbxPaymentType.itemIndex],1,p));
newReservation := strToInt(edSetToGroupReservation.text);
newRoomReservation := 0;
if MessageDlg('Set payment to '#10#10+labCheckReservation.caption, mtConfirmation, [mbYes, mbNo], 0) = mrYes then
begin
if newReservation <> 0 then
begin
s := '';
s := s+' UPDATE payments '+#10;
s := s+' SET '+#10;
s := s+' roomreservation ='+_db(newroomreservation)+' '+#10;
s := s+' ,reservation ='+_db(newReservation)+' '+#10;
s := s+' ,description ='+_db(edDescription.text)+' '+#10;
s := s+' ,notes ='+_db(edNotes.text)+' '+#10;
s := s+' ,amount ='+_db(edAmount.value)+' '+#10;
s := s+' ,PayType ='+_db(payType)+' '+#10;
s := s+' WHERE '+#10;
s := s+' (ID = '+_db(rec.id)+') '+#10;
if cmd_bySQL(s) then
begin
modalresult := mrOK;
AddInvoiceActivityLog(g.quser
,newroomreservation
,newReservation
,1
,CHANGE_PAYMENT
,payType
,edAmount.value
,-1
,edDescription.text);
end;
end;
end;
end;
procedure TfrmAssignPayment.btnOKClick(Sender: TObject);
var
s : string;
p : integer;
payType : string;
begin
p := pos(' - ',__cbxPaymentType.items[__cbxPaymentType.itemIndex]);
paytype := trim(copy(__cbxPaymentType.items[__cbxPaymentType.itemIndex],1,p));
s := '';
s := s+' UPDATE payments '+#10;
s := s+' SET '+#10;
s := s+' description ='+_db(edDescription.text)+' '+#10;
s := s+' ,notes ='+_db(edNotes.text)+' '+#10;
s := s+' ,amount ='+_db(edAmount.value)+' '+#10;
s := s+' ,PayType ='+_db(payType)+' '+#10;
s := s+' WHERE '+#10;
s := s+' (ID = '+_db(rec.id)+') '+#10;
if cmd_bySQL(s) then
begin
AddInvoiceActivityLog(g.quser
,rec.Reservation
,rec.RoomReservation
,1
,CHANGE_PAYMENT
,payType
,edAmount.value
,-1
,edDescription.text);
end;
end;
end.