-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathuChannels.pas
1065 lines (966 loc) · 28.9 KB
/
uChannels.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
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit uChannels;
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.Menus
, Vcl.ExtCtrls
, Generics.Collections
, Data.DB
, shellapi
, _glob
, uAppGlobal
, Hdata
, ug
, uManageFilesOnServer
, uActivityLogs
, kbmMemTable
, sSkinProvider
, sSpeedButton
, sEdit
, sPageControl
, sStatusBar
, sLabel
, sButton
, sPanel
, dxCore
, cxGridExportLink
, cxGraphics
, cxControls
, cxLookAndFeels
, cxLookAndFeelPainters
, cxStyles
, cxCustomData
, cxFilter
, cxData
, cxDataStorage
, cxEdit
, cxNavigator
, cxDBData
, cxGridCustomTableView
, cxGridTableView
, cxGridDBTableView
, cxGridLevel
, cxClasses
, cxGridCustomView
, cxGrid
, cxTextEdit
, dxPSGlbl
, dxPSUtl
, dxPSEngn
, dxPrnPg
, dxBkgnd
, dxWrap
, dxPrnDev
, dxPSCompsProvider
, dxPSFillPatterns
, dxPSEdgePatterns
, dxPSPDFExportCore
, dxPSPDFExport
, cxDrawTextUtils
, dxPSPrVwStd
, dxPSPrVwAdv
, dxPSPrVwRibbon
, dxPScxPageControlProducer
, dxPScxGridLnk
, dxPScxGridLayoutViewLnk
, dxPScxEditorProducers
, dxPScxExtEditorProducers
, dxPSCore
, dxPScxCommon
, cmpRoomerDataSet
, cmpRoomerConnection
, dxmdaset
, cxButtonEdit
, cxCalc
, Vcl.Mask
, cxContainer
, cxMaskEdit
, cxDropDownEdit
, cxLookupEdit
, cxDBLookupEdit
, cxDBExtLookupComboBox
, cxDBLookupComboBox
, cxSpinEdit
, dxSkinsCore
, dxSkinsdxBarPainter
, dxSkinsdxRibbonPainter
, cxPropertiesStore
, cxColorComboBox
, cxCheckGroup
, cxRadioGroup
, dxPScxPivotGridLnk
, dxSkinDarkSide
, dxSkinDevExpressDarkStyle
, dxSkinMcSkin
, dxSkinOffice2013White
, dxSkinsDefaultPainters
, dxSkinscxPCPainter, dxSkinCaramel, dxSkinCoffee, dxSkinTheAsphaltWorld
;
type
TfrmChannels = class(TForm)
sPanel1: TsPanel;
btnOther: TsButton;
btnClose: TsButton;
labFilterWarning: TsLabel;
mnuOther: TPopupMenu;
mnuiPrint: TMenuItem;
mnuiAllowGridEdit: TMenuItem;
N2: TMenuItem;
Export1: TMenuItem;
mnuiGridToExcel: TMenuItem;
mnuiGridToHtml: TMenuItem;
mnuiGridToText: TMenuItem;
mnuiGridToXml: TMenuItem;
sbMain: TsStatusBar;
edFilter: TsEdit;
cLabFilter: TsLabel;
btnClear: TsSpeedButton;
panBtn: TsPanel;
btnCancel: TsButton;
BtnOk: TsButton;
DS: TDataSource;
grPrinter: TdxComponentPrinter;
prLink_grData: TdxGridReportLink;
m_: TdxMemData;
grData: TcxGrid;
tvData: TcxGridDBTableView;
lvData: TcxGridLevel;
m_ID: TIntegerField;
m_Active: TBooleanField;
tvDataRecId: TcxGridDBColumn;
tvDataID: TcxGridDBColumn;
tvDataActive: TcxGridDBColumn;
m_name: TWideStringField;
m_channelManagerId: TWideStringField;
m_minAlotment: TIntegerField;
m_defaultAvailability: TIntegerField;
m_defaultPricePP: TFloatField;
m_marketSegment: TWideStringField;
m_currencyId: TIntegerField;
m_managedByChannelManager: TBooleanField;
m_default: TBooleanField;
tvDataname: TcxGridDBColumn;
tvDatachannelManagerId: TcxGridDBColumn;
tvDataminAlotment: TcxGridDBColumn;
tvDatadefaultAvailability: TcxGridDBColumn;
tvDatadefaultPricePP: TcxGridDBColumn;
tvDatamarketSegment: TcxGridDBColumn;
tvDatacurrencyId: TcxGridDBColumn;
tvDataCurrency: TcxGridDBColumn;
tvDatamanagedByChannelManager: TcxGridDBColumn;
m_Currency: TWideStringField;
StoreMain: TcxPropertiesStore;
m_push: TBooleanField;
tvDatapush: TcxGridDBColumn;
m_customerId: TIntegerField;
tvDatacustomerId: TcxGridDBColumn;
m_color: TWideStringField;
tvDatacolor: TcxGridDBColumn;
m_rateRoundingType: TIntegerField;
tvDatarateRoundingType: TcxGridDBColumn;
tvDataroomClasses: TcxGridDBColumn;
tvDatadefaultChannel: TcxGridDBColumn;
m_compensationPercentage: TFloatField;
m_hotelsBookingEngine: TBooleanField;
tvDatacompensationPercentage: TcxGridDBColumn;
tvDatahotelsBookingEngine: TcxGridDBColumn;
m_RateRoundingText: TStringField;
Button1: TsButton;
Button2: TsButton;
Button3: TsButton;
m_CHANNEL_ARRANGES_PAYMENT: TBooleanField;
tvDataCHANNEL_ARRANGES_PAYMENT: TcxGridDBColumn;
btnInsert: TsButton;
btnEdit: TsButton;
btnDelete: TsButton;
m_directConnection: TBooleanField;
tvDatadirectConnection: TcxGridDBColumn;
m_activePlanCode: TIntegerField;
tvDataactivePlanCode: TcxGridDBColumn;
m_ratesExcludingTaxes: TBooleanField;
tvDataratesExcludingTaxes: TcxGridDBColumn;
tvDatarateRoundingType1: TcxGridDBColumn;
m_roomClasses: TWideStringField;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure m_BeforeDelete(DataSet: TDataSet);
procedure m_BeforeInsert(DataSet: TDataSet);
procedure m_BeforePost(DataSet: TDataSet);
procedure m_NewRecord(DataSet: TDataSet);
procedure tvDataDblClick(Sender: TObject);
procedure BtnOkClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
procedure tvDataFocusedRecordChanged(Sender: TcxCustomGridTableView;
APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord;
ANewItemRecordFocusingChanged: Boolean);
procedure tvDataDataControllerFilterChanged(Sender: TObject);
procedure tvDataDataControllerSortingChanged(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
procedure btnOtherClick(Sender: TObject);
procedure btnDeleteClick(Sender: TObject);
procedure mnuiPrintClick(Sender: TObject);
procedure mnuiAllowGridEditClick(Sender: TObject);
procedure mnuiGridToExcelClick(Sender: TObject);
procedure mnuiGridToHtmlClick(Sender: TObject);
procedure mnuiGridToTextClick(Sender: TObject);
procedure mnuiGridToXmlClick(Sender: TObject);
procedure btnEditClick(Sender: TObject);
procedure btnClearClick(Sender: TObject);
procedure edFilterChange(Sender: TObject);
procedure tvDataCurrencyPropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure tvDatamarketSegmentPropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure tvDatacustomerIdPropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure tvDataroomClassesPropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure btnInsertClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure tvDataactivePlanCodePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
private
{ Private declarations }
zFirstTime: Boolean;
zAllowGridEdit: Boolean;
zFilterOn: Boolean;
zSortStr: string;
zIsAddRow: Boolean;
Procedure fillGridFromDataset(iGoto: Integer);
procedure fillHolder;
procedure changeAllowgridEdit;
Procedure chkFilter;
procedure applyFilter;
procedure RemoveRedundantRatesAndAvailabilities;
public
{ Public declarations }
zAct: TActTableAction;
zData: recChannelHolder;
end;
function openChannels(act: TActTableAction;
var theData: recChannelHolder): Boolean;
var
frmChannels: TfrmChannels;
implementation
{$R *.dfm}
uses
uD
, prjConst
, uSqlDefinitions
, uCurrencies
, uCustomerTypes2
, uCustomers2
, uMultiSelection
, uDImages
, uUtils
, u2DMatrix
, UITypes
;
/// ///////////////////////////////////////////////////////////////////////////////////////////
// unit global functions
/// ///////////////////////////////////////////////////////////////////////////////////////////
function roundint2text(aInt : integer) : string;
begin
case aint of
1 : result := 'Round to nearest whole number';
2 : result := 'Round up to whole number';
3 : result := 'Round down to whole number';
4 : result := 'Round to 1 decimal';
5 : result := 'Round to 2 decimals';
6 : result := 'Round to 3 decimals';
else
result := 'No rounding';
end;
end;
function roundText2int(aText : string) : integer;
begin
if atext = 'Round to nearest whole number' then result := 1
else if atext = 'Round up to whole number' then result := 2
else if atext = 'Round down to whole number' then result := 3
else if atext = 'Round to 1 decimal' then result := 4
else if atext = 'Round to 2 decimals' then result := 5
else if atext = 'Round to 3 decimals' then result := 6
else {if atext = 'No rounding' then} result := 0;
end;
function openChannels(act: TActTableAction;
var theData: recChannelHolder): Boolean;
begin
result := false;
frmChannels := TfrmChannels.Create(frmChannels);
try
frmChannels.zData := theData;
frmChannels.zAct := act;
frmChannels.ShowModal;
if frmChannels.modalresult = mrOk then
begin
theData := frmChannels.zData;
result := true;
end
else
begin
initChannelHolder(theData);
end;
finally
freeandnil(frmChannels);
end;
end;
/// ////////////////////////////////////////////////////////////////////
{ Private declarations }
/// ////////////////////////////////////////////////////////////////////
Procedure TfrmChannels.fillGridFromDataset(iGoto: Integer);
var
s: string;
rSet: TRoomerDataSet;
rSetRoomClasses: TRoomerDataSet;
begin
zFirstTime := true;
if zSortStr = '' then
zSortStr := 'ID';
rSet := CreateNewDataSet;
try
s := format(select_Channels, [zSortStr]);
CopyToClipboard(s);
if rSet_bySQL(rSet, s) then
begin
if m_.active then
m_.Close;
m_.LoadFromDataSet(rSet);
m_.First;
rSet.First;
while not m_.Eof do
begin
m_.Edit;
m_.FieldByName('rateRoundingText').AsString := roundint2text(m_.FieldByName('rateRoundingType').AsInteger);
rSetRoomClasses := CreateNewDataSet;
try
rSet_bySQL(rSetRoomClasses,
format('SELECT Code FROM roomtypegroups WHERE id IN (SELECT roomClassId FROM channelclassrelations WHERE channelId=%d)', [m_.FieldByName('id').AsInteger]));
s := '';
rSetRoomClasses.First;
while NOT rSetRoomClasses.Eof do
begin
if s = '' then
s := rSetRoomClasses['Code']
else
s := s + ',' + rSetRoomClasses['Code'];
rSetRoomClasses.Next;
end;
m_.FieldByName('roomClasses').AsString := s;
finally
FreeAndNil(rSetRoomClasses);
end;
m_.Post;
rSet.Next;
m_.Next;
end;
if iGoto = 0 then
begin
m_.First;
end
else
begin
try
m_.Locate('ID', iGoto, []);
except
end;
end;
end;
finally
freeandnil(rSet);
end;
end;
procedure TfrmChannels.fillHolder;
begin
initChannelHolder(zData);
zData.ID := m_.FieldByName('ID').AsInteger;
zData.active := m_['Active'];
zData.name := m_['name'];
zData.channelManagerId := m_['channelManagerId'];
zData.minAlotment := m_['minAlotment'];
zData.defaultAvailability := m_['defaultAvailability'];
zData.defaultPricePP := m_['defaultPricePP'];
zData.marketSegment := m_['marketSegment'];
zData.currencyId := m_['currencyId'];
zData.managedByChannelManager := m_['managedByChannelManager'];
zData.CHANNEL_ARRANGES_PAYMENT := m_['CHANNEL_ARRANGES_PAYMENT'];
zData.defaultChannel := m_['defaultChannel'];
zData.push := m_['push'];
zData.customerId := m_['customerId'];
zData.color := m_['color'];
zData.currency := m_['currency'];
zData.roomClasses := m_['roomClasses'];
zData.hotelsBookingEngine := m_['hotelsBookingEngine'];
zData.compensationPercentage := m_['compensationPercentage'];
zData.directConnection := m_['directConnection'];
zData.Rounding := m_['rateRoundingType'];
zData.activePlanCode := m_['activePlanCode'];
zData.ratesExcludingTaxes := m_['ratesExcludingTaxes'];
end;
procedure TfrmChannels.changeAllowgridEdit;
begin
tvDataID.Options.Editing := false;
tvDataActive.Options.Editing := zAllowGridEdit;
tvDataname.Options.Editing := zAllowGridEdit;
tvDatachannelManagerId.Options.Editing := zAllowGridEdit;
tvDataminAlotment.Options.Editing := zAllowGridEdit;
tvDatadefaultAvailability.Options.Editing := zAllowGridEdit;
tvDatadefaultPricePP.Options.Editing := zAllowGridEdit;
tvDatamarketSegment.Options.Editing := zAllowGridEdit;
tvDatacurrencyId.Options.Editing := zAllowGridEdit;
tvDatamanagedByChannelManager.Options.Editing := zAllowGridEdit;
tvDataCHANNEL_ARRANGES_PAYMENT.Options.Editing := zAllowGridEdit;
tvDataCurrency.Options.Editing := zAllowGridEdit;
tvDatadefaultChannel.Options.Editing := zAllowGridEdit;
tvDatarateRoundingType.Options.Editing := zAllowGridEdit;
tvDataroomClasses.Options.Editing := zAllowGridEdit;
tvDatahotelsBookingEngine.Options.Editing := zAllowGridEdit;
tvDatacompensationPercentage.Options.Editing := zAllowGridEdit;
tvDatadirectConnection.Options.Editing := zAllowGridEdit;
tvDataactivePlanCode.Options.Editing := zAllowGridEdit;
tvDataratesExcludingTaxes.Options.Editing := zAllowGridEdit;
end;
procedure TfrmChannels.chkFilter;
var
sFilter: string;
rC1, rc2: Integer;
begin
sFilter := edFilter.text;
rC1 := tvData.DataController.RecordCount;
rc2 := tvData.DataController.FilteredRecordCount;
zFilterOn := rC1 <> rc2;
if zFilterOn then
begin
labFilterWarning.Visible := true;
labFilterWarning.color := clMoneyGreen;
labFilterWarning.Font.Style := [fsBold]; // -C
// labFilterWarning.caption := shFilterOn+' - '+inttostr(rc2)+' '+shRecordsOf+' '+inttostr(rc1)+' '+shAreVisible+' ';;
labFilterWarning.caption := format(GetTranslatedText('shFilterOnRecordsOf'),
[rc2, rC1]);
end
else
begin
labFilterWarning.Visible := false;
end;
end;
procedure TfrmChannels.edFilterChange(Sender: TObject);
begin
if edFilter.text = '' then
begin
tvData.DataController.Filter.Root.Clear;
tvData.DataController.Filter.active := false;
end
else
begin
applyFilter;
end;
end;
procedure TfrmChannels.applyFilter;
begin
tvData.DataController.Filter.Options := [fcoCaseInsensitive];
tvData.DataController.Filter.Root.BoolOperatorKind := fboOr;
tvData.DataController.Filter.Root.Clear;
tvData.DataController.Filter.Root.AddItem(tvDataname, foLike,
'%' + edFilter.text + '%', '%' + edFilter.text + '%');
tvData.DataController.Filter.Root.AddItem(tvDatachannelManagerId, foLike,
'%' + edFilter.text + '%', '%' + edFilter.text + '%');
tvData.DataController.Filter.Root.AddItem(tvDataCurrency, foLike,
'%' + edFilter.text + '%', '%' + edFilter.text + '%');
tvData.DataController.Filter.active := true;
end;
/// //////////////////////////////////////////////////////////
// Form actions
/// //////////////////////////////////////////////////////////
procedure TfrmChannels.FormCreate(Sender: TObject);
begin
RoomerLanguage.TranslateThisForm(self);
glb.PerformAuthenticationAssertion(self); PlaceFormOnVisibleMonitor(self);
// **
zFirstTime := true;
zAct := actNone;
zIsAddRow := false;
end;
procedure TfrmChannels.FormDestroy(Sender: TObject);
begin
glb.EnableOrDisableTableRefresh('channels', True);
end;
procedure TfrmChannels.FormShow(Sender: TObject);
begin
glb.EnableOrDisableTableRefresh('channels', False);
// **
panBtn.Visible := false;
sbMain.Visible := false;
btnClose.Visible := false;
fillGridFromDataset(zData.ID);
zFirstTime := true;
sbMain.SimpleText := zSortStr;
if zAct = actLookup then
begin
mnuiAllowGridEdit.Checked := false;
panBtn.Visible := true;
end
else
begin
mnuiAllowGridEdit.Checked := true;
btnClose.Visible := true;
sbMain.Visible := true;
end;
// -C
zAllowGridEdit := mnuiAllowGridEdit.Checked;
changeAllowgridEdit;
chkFilter;
zFirstTime := false;
end;
procedure TfrmChannels.FormClose(Sender: TObject; var Action: TCloseAction);
begin
glb.EnableOrDisableTableRefresh('channels', True);
if tvData.DataController.DataSet.State = dsInsert then
begin
tvData.DataController.Post;
end;
if tvData.DataController.DataSet.State = dsEdit then
begin
tvData.DataController.Post;
end;
try RemoveRedundantRatesAndAvailabilities; except end;
end;
Procedure TfrmChannels.RemoveRedundantRatesAndAvailabilities;
var
s: string;
begin
s := 'DELETE FROM channelrates WHERE NOT roomClassId IN (SELECT roomclassId FROM channelclassrelations WHERE channelId=channelrates.channelId)';
cmd_bySQL(s);
s := 'DELETE FROM channelratesavailabilities WHERE NOT roomClassId IN (SELECT id FROM roomtypegroups WHERE Active)';
cmd_bySQL(s);
end;
procedure TfrmChannels.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key = VK_ESCAPE then
Close;
end;
procedure TfrmChannels.FormKeyPress(Sender: TObject; var Key: Char);
begin
if zAct = actLookup then
begin
if Key = chr(13) then
begin
if activecontrol = edFilter then
begin
end
else
begin
BtnOk.click;
end;
end;
if Key = chr(27) then
begin
if activecontrol = edFilter then
begin
end
else
begin
btnCancel.click;
end;
end;
end;
end;
/// /////////////////////////////////////////////////////////////////////////////////////
// memory table
procedure TfrmChannels.m_BeforeDelete(DataSet: TDataSet);
var
s: string;
begin
fillHolder;
(*
if hdata.payTypeExistsInOther(zData.PayType) then
begin
Showmessage('payType'+' ' + zData.Description + ' '+GetTranslatedText('shExistsInRelatedData')+' ' + chr(10) + GetTranslatedText('shCanNotDelete')+' ');
Abort;
exit;
end;
*)
s := '';
s := s + GetTranslatedText('shDeleteChannel') + ' ' + zData.name + ' '
+ chr(10);
s := s + GetTranslatedText('shContinue');
if MessageDlg(s, mtConfirmation, [mbYes, mbNo], 0) = mrYes then
begin
if not Del_Channel(zData) then
begin
abort;
end else
glb.LogChanges(DataSet, 'channels', DELETE_RECORD, 'Channel ID = ' + zData.channelManagerId + ', name = ' + zData.Name);
end
else
begin
abort
end;
end;
procedure TfrmChannels.m_BeforeInsert(DataSet: TDataSet);
begin
if zFirstTime then
exit;
tvData.GetColumnByFieldName('channelManagerId').Focused := true;
end;
procedure TfrmChannels.m_BeforePost(DataSet: TDataSet);
var
nID: Integer;
begin
if zFirstTime then
exit;
initChannelHolder(zData);
zData.ID := DataSet.FieldByName('ID').AsInteger;
zData.active := DataSet['Active'];
zData.name := DataSet['name'];
zData.channelManagerId := DataSet['channelManagerId'];
zData.minAlotment := DataSet['minAlotment'];
zData.defaultAvailability := DataSet['defaultAvailability'];
zData.defaultPricePP := DataSet['defaultPricePP'];
zData.marketSegment := DataSet['marketSegment'];
zData.currencyId := DataSet['currencyId'];
zData.managedByChannelManager := DataSet['managedByChannelManager'];
zData.CHANNEL_ARRANGES_PAYMENT := DataSet['CHANNEL_ARRANGES_PAYMENT'];
zData.defaultChannel := DataSet['defaultChannel'];
zData.push := DataSet['push'];
zData.customerId := DataSet['customerId'];
zData.color := DataSet['color'];
zData.currency := DataSet['currency'];
zData.Rounding := roundtext2Int(DataSet['rateRoundingtext']);
zData.roomClasses := DataSet['roomClasses'];
zData.hotelsBookingEngine := DataSet['hotelsBookingEngine'];
zData.compensationPercentage := DataSet['compensationPercentage'];
zData.directConnection := DataSet['directConnection'];
zData.activePlanCode := DataSet['activePlanCode'];
zData.ratesExcludingTaxes := DataSet['ratesExcludingTaxes'];
if tvData.DataController.DataSource.State = dsEdit then
begin
glb.LogChanges(DataSet, 'channels', CHANGE_FIELD, '');
if UPD_Channel(zData) then
begin
glb.ForceTableRefresh;
end
else
begin
abort;
exit;
end;
end;
if tvData.DataController.DataSource.State = dsInsert then
begin
if DataSet.FieldByName('channelManagerId').AsString = '' then
begin
showmessage('Channel is requierd - set value or use [ESC] to cancel ');
tvData.GetColumnByFieldName('channelManagerId').Focused := true;
abort;
exit;
end;
if ins_Channel(zData, nID) then
begin
glb.LogChanges(DataSet, 'channels', ADD_RECORD, 'Channel ID = ' + zData.channelManagerId + ', name = ' + zData.Name);
glb.ForceTableRefresh;
end
else
begin
abort;
exit;
end;
end;
end;
procedure TfrmChannels.m_NewRecord(DataSet: TDataSet);
begin
DataSet['Active'] := false;
DataSet['name'] := '';
DataSet['channelManagerId'] := '';
DataSet['minAlotment'] := 0;
DataSet['defaultAvailability'] := 0;
DataSet['defaultPricePP'] := 0;
DataSet['marketSegment'] := '';
DataSet['currencyId'] := getNativeCurrencyID();
DataSet['currency'] := ctrlGetString('NativeCurrency');;
DataSet['defaultChannel'] := false;
DataSet['push'] := true;
DataSet['customerId'] := GetCustomerId(ctrlGetString('rackCustomer'));
DataSet['color'] := '15793151';
DataSet['rateRoundingType'] := 1;
DataSet['rateRoundingText'] := roundint2text(DataSet['rateRoundingType']);
DataSet['roomClasses'] := '';
DataSet['hotelsBookingEngine'] := false;
DataSet['compensationPercentage'] := 0;
DataSet['directConnection'] := False;
DataSet['ratesExcludingTaxes'] := False;
if glb.LocateSpecificRecord('channelplancodes', 'Code', 'PLAN') then
DataSet['activePlanCode'] := glb.ChannelPlanCodes['ID'];
end;
/// /////////////////////////////////////////////////////////////////////////////////////
// table View Functions
/// /////////////////////////////////////////////////////////////////////////////////////
procedure TfrmChannels.tvDataFocusedRecordChanged
(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord
: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
begin
if AFocusedRecord = nil then
begin
zIsAddRow := true;
end
else
begin
zIsAddRow := false;
end;
end;
procedure TfrmChannels.tvDatamarketSegmentPropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
var
theData: recCustomerTypeHolder;
begin
fillHolder;
theData.customerType := zData.marketSegment;
// theData.ID := zData.CurrencyID;
openCustomerTypes(actLookup, theData);
if theData.customerType <> '' then
begin
if tvData.DataController.DataSource.State <> dsInsert then
m_.Edit;
m_['marketSegment'] := theData.customerType;
// m_['currencyID'] := theData.ID;
end;
end;
procedure TfrmChannels.tvDataroomClassesPropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
var
newValue: String;
begin
newValue := LookupForDataItem('Room Classes', glb.RoomTypeGroups, 'Code',
'Description', m_['roomClasses'], true, false, 'Active', nil, '');
// CopyToClipboard(m_['roomClasses']);
// DebugMessage(m_['roomClasses']);
if newValue <> m_['roomclasses'] then
begin
m_.Edit;
m_['roomClasses'] := newValue;
d.roomerMainDataSet.SystemCorrectRoomClasses(m_['id'], newValue);
end;
end;
procedure TfrmChannels.tvDataDblClick(Sender: TObject);
begin
if zAct = actLookup then
begin
BtnOk.click
end;
end;
/// /////////////////////////////////////////////////////////////////////////
// Filter
/// //////////////////////////////////////////////////////////////////////////
// procedure TfrmChannels2.tvDataCurrencyPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
// var
// theData : recCurrencyHolder;
// begin
/// / fillholder;
/// / theData.Currency := zData.Currency;
/// / theData.ID := zData.CurrencyID;
/// /
/// /
/// / currencies(actlookup,theData);
/// /
/// / if theData.Currency <> '' then
/// / begin
/// / m_.Edit;
/// / m_['currency'] := theData.Currency;
/// / m_['currencyID'] := theData.ID;
/// / m_.Post;
/// / end;
//
// end;
procedure TfrmChannels.tvDataactivePlanCodePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
LookupForDataItem('Channel Plan Code',
glb.ChannelPlanCodes,
'Id',
'Description',
m_['activePlanCode'],
False,
True,
'active',
m_,
'activePlanCode');
end;
procedure TfrmChannels.tvDataCurrencyPropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
var
theData: recCurrencyHolder;
begin
fillHolder;
theData.currency := zData.currency;
theData.ID := zData.currencyId;
currencies(actLookup, theData);
if theData.currency <> '' then
begin
if tvData.DataController.DataSource.State <> dsInsert then
m_.Edit;
m_['currency'] := theData.currency;
m_['currencyID'] := theData.ID;
end;
end;
procedure TfrmChannels.tvDatacustomerIdPropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
var
theData: recCustomerHolder;
sCustomer : String;
begin
fillHolder;
sCustomer := '';
theData.ID := zData.customerId;
glb.LocateSpecificRecordAndGetValue('customers', 'id', zData.customerId, 'Customer', sCustomer);
theData.Customer := sCustomer;
openCustomers(actLookup, true, theData);
if theData.ID <> 0 then
begin
if tvData.DataController.DataSource.State <> dsInsert then
m_.Edit;
m_['customerId'] := theData.ID;
end;
end;
procedure TfrmChannels.tvDataDataControllerFilterChanged(Sender: TObject);
begin
chkFilter;
end;
procedure TfrmChannels.tvDataDataControllerSortingChanged(Sender: TObject);
var
i: Integer;
s: string;
serval: Boolean;
begin
s := '';
serval := false;
for i := 0 to tvData.SortedItemCount - 1 do
begin
if serval then
s := s + ', ';
s := s + TcxGridDBColumn(tvData.SortedItems[i]).DataBinding.FieldName;
serval := true;
if tvData.SortedItems[i].SortOrder = soDescending then
s := s + ' DESC';
end;
zSortStr := s;
sbMain.SimpleText := s;
end;
/// ///////////////////////////////////////////////////////////////////////
// Buttons
/// ///////////////////////////////////////////////////////////////////////
procedure TfrmChannels.BtnOkClick(Sender: TObject);
begin
fillHolder;
end;
procedure TfrmChannels.btnOtherClick(Sender: TObject);
begin
// **
end;
procedure TfrmChannels.Button1Click(Sender: TObject);
begin
EditPaymentAssuranceForChannels;
end;
procedure TfrmChannels.Button2Click(Sender: TObject);
begin
EditChannelsEmailConfirmationMatrix;
end;
procedure TfrmChannels.Button3Click(Sender: TObject);
begin
EditChannelsHotelEmailMatrix;
end;
procedure TfrmChannels.btnCancelClick(Sender: TObject);
begin
initChannelHolder(zData);
end;
procedure TfrmChannels.btnClearClick(Sender: TObject);
begin
edFilter.text := '';
end;
procedure TfrmChannels.btnCloseClick(Sender: TObject);
begin
if m_.State IN [dsEdit, dsInsert] then
m_.Post;
fillHolder;
end;
procedure TfrmChannels.btnDeleteClick(Sender: TObject);
begin
m_.Delete;
end;
procedure TfrmChannels.btnEditClick(Sender: TObject);
begin
//**
end;
procedure TfrmChannels.btnInsertClick(Sender: TObject);
begin
//**
end;