-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathuChannelManager.pas
973 lines (846 loc) · 26.1 KB
/
uChannelManager.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
unit uChannelManager;
(*
121207 - checked for ww - OK
*)
interface
uses
Windows
, Messages
, SysUtils
, Variants
, Classes
, Graphics
, Controls
, Forms
, Dialogs
, Menus
, ImgList
, StdCtrls
, Mask
, ExtCtrls
, Grids
, Buttons
, shellapi
, ComCtrls
, ADODB
, db
, DBTables
, DBCtrls
, hdata
, uAppGlobal
, _glob
, ug
, dxCore
, cxGridExportLink
, cxGraphics
, cxControls
, cxLookAndFeels
, cxLookAndFeelPainters
, cxStyles
, cxCustomData
, cxFilter
, cxData
, cxDataStorage
, cxEdit
, cxNavigator
, cxDBData
, cxGridCustomTableView
, cxGridTableView
, cxGridDBTableView
, cxGridLevel
, cxClasses
, cxGridCustomView
, cxGrid
, cxTextEdit
, cxContainer
, cxDBEdit
, cxGridCardView
, cxGridDBCardView
, cxGridCustomLayoutView
, dxLayoutContainer
, cxGridLayoutView
, cxGridDBLayoutView
, cxSpinEdit
, dxPSGlbl
, dxPSUtl
, dxPSEngn
, dxPrnPg
, dxBkgnd
, dxWrap
, dxPrnDev
, dxPSCompsProvider
, dxPSFillPatterns
, dxPSEdgePatterns
, dxPSPDFExportCore
, dxPSPDFExport
, cxDrawTextUtils
, dxPSPrVwStd
, dxPSPrVwAdv
, dxPSPrVwRibbon
, dxPScxPageControlProducer
, dxPScxEditorProducers
, dxPScxExtEditorProducers
, dxPSCore
, dxPScxGridLnk
, dxPScxGridLayoutViewLnk
, dxPScxCommon
// TMSSOFRWARE
, AdvEdit
, AdvEdBtn
, PrjConst
, uUtils
, cmpRoomerDataSet
, cmpRoomerConnection
, sButton
, sPanel
, sMaskEdit
, sCustomComboEdit
, sComboEdit
, sLabel
, dxSkinsCore
, dxSkinsDefaultPainters
, cxButtonEdit
, dxSkinsdxBarPainter
, dxSkinsdxRibbonPainter
, cxPropertiesStore
, dxSkinDarkSide
, dxSkinDevExpressDarkStyle
, dxSkinMcSkin
, dxSkinOffice2013White
, dxSkinscxPCPainter, dxmdaset, dxSkinCaramel, dxSkinCoffee, dxSkinTheAsphaltWorld, sSpeedButton, sEdit, cxMaskEdit, dxPScxPivotGridLnk
;
type
TfrmChannelManager = class(TForm)
sbMain: TStatusBar;
PanTop: TsPanel;
panBtn: TsPanel;
BtnOk: TsButton;
btnCancel: TsButton;
btnClose: TsButton;
tvData: TcxGridDBTableView;
lvData: TcxGridLevel;
grData: TcxGrid;
btnOther: TsButton;
mnuOther: TPopupMenu;
mnuiAllowGridEdit: TMenuItem;
mnuiGridToExcel: TMenuItem;
DS: TDataSource;
mnuiGridToHtml: TMenuItem;
mnuiGridToText: TMenuItem;
mnuiGridToXml: TMenuItem;
N2: TMenuItem;
Export1: TMenuItem;
grPrinter: TdxComponentPrinter;
prLink_grData: TdxGridReportLink;
mnuiPrint: TMenuItem;
m_: TdxMemData;
m_Description: TWideStringField;
m_webserviceUsername: TWideStringField;
m_webservicePassword: TWideStringField;
m_webserviceHotelCode: TWideStringField;
m_weserviceRequestor: TWideStringField;
m_adminUsername: TWideStringField;
m_adminPassword: TWideStringField;
tvDataRecId: TcxGridDBColumn;
tvDataDescription: TcxGridDBColumn;
tvDatawebserviceUsername: TcxGridDBColumn;
tvDatawebservicePassword: TcxGridDBColumn;
tvDatawebserviceHotelCode: TcxGridDBColumn;
tvDataweserviceRequestor: TcxGridDBColumn;
tvDataadminUsername: TcxGridDBColumn;
tvDataadminPassword: TcxGridDBColumn;
m_Id: TIntegerField;
tvDataId: TcxGridDBColumn;
StoreMain: TcxPropertiesStore;
m_code: TWideStringField;
tvDatacode: TcxGridDBColumn;
tvDatachannels: TcxGridDBColumn;
m_webserviceURI: TWideStringField;
tvDatawebserviceURI: TcxGridDBColumn;
m_active: TBooleanField;
m_sendRate: TBooleanField;
m_sendAvailability: TBooleanField;
m_sendStopSell: TBooleanField;
m_sendMinStay: TBooleanField;
tvDataactive: TcxGridDBColumn;
tvDatasendRate: TcxGridDBColumn;
tvDatasendAvailability: TcxGridDBColumn;
tvDatasendStopSell: TcxGridDBColumn;
tvDatasendMinStay: TcxGridDBColumn;
labChannelManager: TsLabel;
m_maintenanceDays: TIntegerField;
tvDatamaintenanceDays: TcxGridDBColumn;
Button1: TsButton;
Button2: TsButton;
Button3: TsButton;
btnInsert: TsButton;
btnEdit: TsButton;
btnDelete: TsButton;
cLabFilter: TsLabel;
edFilter: TsEdit;
btnClear: TsSpeedButton;
m_schannels: TWideStringField;
m_directConnection: TBooleanField;
tvDatadirectConnection: TcxGridDBColumn;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btnCancelClick(Sender: TObject);
procedure btnDeleteClick(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure BtnOkClick(Sender: TObject);
procedure edFilterClickBtn(Sender: TObject);
procedure edFilterChange(Sender: TObject);
procedure tvDataChannelManagerPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
var Error: Boolean);
procedure tvDataCellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
procedure tvDataDataControllerFilterChanged(Sender: TObject);
procedure btnOtherClick(Sender: TObject);
procedure tvDataDataControllerSortingChanged(Sender: TObject);
procedure mnuiAllowGridEditClick(Sender: TObject);
procedure mnuiGridToExcelClick(Sender: TObject);
procedure mnuiGridToHtmlClick(Sender: TObject);
procedure mnuiGridToTextClick(Sender: TObject);
procedure mnuiGridToXmlClick(Sender: TObject);
procedure mnuiPrintClick(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
procedure m_AfterPost(DataSet: TDataSet);
procedure m_BeforePost(DataSet: TDataSet);
procedure m_NewRecord(DataSet: TDataSet);
procedure m_BeforeEdit(DataSet: TDataSet);
procedure btnInsertClick(Sender: TObject);
procedure btnEditClick(Sender: TObject);
procedure tvDatachannelsPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure btnClearClick(Sender: TObject);
private
{ Private declarations }
zFirstTime : boolean;
zAllowGridEdit : boolean;
zPostData : boolean;
zPostState : integer;
zFilterOn : boolean;
zSortStr : string;
Procedure fillGridFromDataset(sGoto : string);
procedure changeAllowgridEdit;
procedure fillHolder;
function getPrevCode : string;
Procedure chkFilter;
procedure applyFilter;
public
{ Public declarations }
zAct : TActTableAction;
zData : recChannelManagerHolder;
end;
function ChannelManager(act : TActTableAction; var theData : recChannelManagerHolder ) : boolean;
function getChannelManager(ed : TsComboEdit; lab : TsLabel) : boolean;
function channelManagerValidate(ed : TsComboEdit; lab : TsLabel) : boolean;
var
frmChannelManager: TfrmChannelManager;
implementation
uses
uD
, uMultiSelection
, uSqlDefinitions
, uActivityLogs
, uDImages
, u2dMatrix
;
{$R *.dfm}
//////////////////////////////////////////////////////////////////////////////////////////////
// unit global functions
//////////////////////////////////////////////////////////////////////////////////////////////
function ChannelManager(act : TActTableAction; var theData : recChannelManagerHolder ) : boolean;
begin
result := false;
frmChannelManager := TfrmChannelManager.Create(frmChannelManager);
try
frmChannelManager.zData := theData;
frmChannelManager.zAct := act;
frmChannelManager.ShowModal;
if frmChannelManager.modalresult = mrOk then
begin
theData := frmChannelManager.zData;
result := true;
end
else
begin
initChannelManagerHolder(theData);
end;
finally
freeandnil(frmChannelManager)
end;
end;
function getChannelManager(ed : TsComboEdit; lab : TsLabel) : boolean;
var
theData : recChannelManagerHolder;
begin
//*NOT TESTED*//
result := false;
initChannelManagerHolder(theData);
theData.Id := strtointdef(trim(ed.text), 1);
result := ChannelManager(actLookup,theData);
if inttostr(theData.Id) = trim(ed.text) then
begin
result := false;
exit;
end;
if result and (inttostr(theData.Id) <> ed.text) then
begin
ed.text := inttostr(theData.Id);
lab.Caption := thedata.Code+' - '+thedata.Description;
end;
end;
function channelManagerValidate(ed : TsComboEdit; lab : TsLabel) : boolean;
var
sValue : string;
pcCode : string;
theData : recChannelManagerHolder;
begin
//*NOT TESTED*//
initChannelManagerHolder(theData);
theData.Id := strtointdef(trim(ed.Text), 1);
result := hdata.GET_ChannelManagerHolderById(theData);
try
if not result then
begin
if ed.CanFocus then
ed.SetFocus;
lab.Color := clRed;
lab.caption := GetTranslatedText('shNotF_star');
end else
begin
lab.Color := clBtnFace;
lab.Caption := thedata.Code+' - '+thedata.Description;
end;
except
end;
end;
//END unit global functions
///////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////
procedure TfrmChannelManager.fillGridFromDataset(sGoto: string);
var
s : string;
rSet : TRoomerDataSet;
begin
zFirstTime := true;
if zSortStr = '' then zSortStr := 'Id ';
rSet := CreateNewDataSet;
try
s := format(select_ChannelManager_fillGridFromDataset, [zSortStr]);
// CopyToClipboard(s);
// DebugMessage('select_ChannelManager_fillGridFromDataset'#10#10+s);
if rSet_bySQL(rSet,s) then
begin
if m_.active then m_.Close;
m_.LoadFromDataSet(rSet);
if sGoto = '' then
begin
m_.First;
end else
begin
try
m_.Locate('Id',sGoto,[]);
except
end;
end;
end;
finally
freeandnil(rSet);
end;
tvDatachannels.Width := 100;
zFirstTime := true;
end;
procedure TfrmChannelManager.fillHolder;
begin
initChannelManagerHolder(zData);
zData.Id := m_.fieldbyname('ID').asInteger;
zData.Code := m_.fieldbyname('code').asstring;
zData.Description := m_.fieldbyname('Description').asstring;
zData.serviceUsername := m_.fieldbyname('webserviceUsername').asstring;
zData.webserviceURI := m_.fieldbyname('webserviceURI').asstring;
zData.servicePassword := m_.fieldbyname('webservicePassword').asstring;
zData.webserviceHotelCode := m_.fieldbyname('webserviceHotelCode').asstring;
zData.serviceRequestorID := m_.fieldbyname('weserviceRequestor').asstring;
zData.active := m_.fieldbyname('active').asBoolean;
zData.sendRate := m_.fieldbyname('sendRate').asBoolean;
zData.sendAvailability := m_.fieldbyname('sendAvailability').asBoolean;
zData.sendStopSell := m_.fieldbyname('sendStopSell').asBoolean;
zData.sendMinStay := m_.fieldbyname('sendMinStay').asBoolean;
zData.maintenanceDays := m_.fieldbyname('maintenanceDays').asInteger;
zData.directConnection := m_.fieldbyname('directConnection').asBoolean;
zData.portalAdminUsername := m_.fieldbyname('adminUsername').asstring;
zData.portalAdminPassword := m_.fieldbyname('adminPassword').asstring;
zData.channels := m_.fieldbyname('schannels').asstring;
end;
procedure TfrmChannelManager.changeAllowgridEdit;
begin
tvDataRecId.Options.Editing := zAllowGridEdit;
tvDataDescription.Options.Editing := zAllowGridEdit;
tvDatawebserviceUsername.Options.Editing := zAllowGridEdit;
tvDatawebservicePassword.Options.Editing := zAllowGridEdit;
tvDatawebserviceURI.Options.Editing := zAllowGridEdit;
tvDatawebserviceHotelCode.Options.Editing := zAllowGridEdit;
tvDataweserviceRequestor.Options.Editing := zAllowGridEdit;
tvDataadminUsername.Options.Editing := zAllowGridEdit;
tvDataadminPassword.Options.Editing := zAllowGridEdit;
tvDatachannels.Options.Editing := zAllowGridEdit;
tvDataactive.Options.Editing := zAllowGridEdit;
tvDatasendRate.Options.Editing := zAllowGridEdit;
tvDatasendAvailability.Options.Editing := zAllowGridEdit;
tvDatasendStopSell.Options.Editing := zAllowGridEdit;
tvDatasendMinStay.Options.Editing := zAllowGridEdit;
tvDatamaintenanceDays.Options.Editing := zAllowGridEdit;
tvDatadirectConnection.Options.Editing := zAllowGridEdit;
end;
function TfrmChannelManager.GetPrevCode : string;
//Copy the cell value from the cell immediately above the focused cell
var
AItem : TcxGridColumn;
APrevRecordIndex, ThisRecordIndex : integer;
ACycleChanged : boolean;
begin
result := '';
if tvData.Controller.FocusedRecord is TcxGridGroupRow then
Exit;
AItem := tvDataRecId;
ThisRecordIndex := tvData.Controller.FocusedRecordIndex;
APrevRecordIndex := tvData.Controller.FindNextRecord(ThisRecordIndex, False, False, ACycleChanged);
if APrevRecordIndex <> -1 then
begin
APrevRecordIndex := tvData.ViewData.Records[APrevRecordIndex].RecordIndex;
Result := tvData.DataController.Values[APrevRecordIndex, AItem.Index];
end;
end;
Procedure TfrmChannelManager.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
end else
begin
end;
end;
/////////////////////////////////////////////////////////////
// Form actions
/////////////////////////////////////////////////////////////
procedure TfrmChannelManager.FormCreate(Sender: TObject);
begin
RoomerLanguage.TranslateThisForm(self);
glb.PerformAuthenticationAssertion(self); PlaceFormOnVisibleMonitor(self);
zFirstTime := true;
zAct := actNone;
zPostData := false;
zPostState := 0;
end;
procedure TfrmChannelManager.FormShow(Sender: TObject);
begin
//**
panBtn.Visible := False;
sbMain.Visible := false;
btnClose.Visible := False;
fillGridFromDataset(inttostr(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;
zAllowGridEdit := mnuiAllowGridEdit.Checked;
changeAllowGridEdit;
chkFilter;
zFirstTime := false;
end;
procedure TfrmChannelManager.FormDestroy(Sender: TObject);
begin
//**
end;
procedure TfrmChannelManager.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
//**
end;
procedure TfrmChannelManager.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 TfrmChannelManager.m_AfterPost(DataSet: TDataSet);
begin
if zFirstTime then exit;
if zPostState = 0 then
begin
fillgridFromDataset(zData.tmp);
exit;
end;
if zPostData then
begin
try
zData.Id := dataset.fieldbyname('ID').asInteger;
zData.Code := dataset.fieldbyname('code').asstring;
zData.Description := dataset.fieldbyname('Description').asstring;
zData.serviceUsername := dataset.fieldbyname('webserviceUsername').asstring;
zData.servicePassword := dataset.fieldbyname('webservicePassword').asstring;
zData.webserviceURI := dataset.fieldbyname('webserviceURI').asstring;
zData.webserviceHotelCode := dataset.fieldbyname('webserviceHotelCode').asstring;
zData.serviceRequestorID := dataset.fieldbyname('weserviceRequestor').asstring;
zData.active := dataset.fieldbyname('active').asBoolean;
zData.sendRate := dataset.fieldbyname('sendRate').asBoolean;
zData.sendAvailability := dataset.fieldbyname('sendAvailability').asBoolean;
zData.sendStopSell := dataset.fieldbyname('sendStopSell').asBoolean;
zData.sendMinStay := dataset.fieldbyname('sendMinStay').asBoolean;
zData.maintenanceDays := dataset.fieldbyname('maintenanceDays').asInteger;
zData.directConnection := dataset.fieldbyname('directConnection').asBoolean;
zData.portalAdminUsername := dataset.fieldbyname('adminUsername').asstring;
zData.portalAdminPassword := dataset.fieldbyname('adminPassword').asstring;
zData.channels := dataset.fieldbyname('schannels').asstring;
if zPostState = 1 then
begin
if hdata.UPD_CHannelManager(zData) then
begin
// label1.Caption := 'Update OK';
glb.ForceTableRefresh;
end else
begin
// label1.Caption := 'Update NOT OK';
end;
end else
if zPostState = 2 then
begin
if hdata.ins_ChannelManager(zData) then
begin
// label1.Caption := 'Insert OK';
glb.ForceTableRefresh;
end else
begin
// label1.Caption := 'insert NOT OK';
end;
end;
finally
zPostData := false;
zPostState := 0;
end;
end;
end;
procedure TfrmChannelManager.m_BeforeEdit(DataSet: TDataSet);
begin
if zFirstTime then exit;
zData.tmp := dataset.FieldByName('Id').AsString;
end;
procedure TfrmChannelManager.m_BeforePost(DataSet: TDataSet);
begin
if zFirstTime then exit;
if tvData.DataController.DataSource.State = dsEdit then
begin
zPostData := true;
zPostState := 1;
glb.LogChanges(DataSet, 'channelmanagers', CHANGE_FIELD, '');
end;
if tvData.DataController.DataSource.State = dsInsert then
begin
if dataset.FieldByName('Description').AsString = '' then
begin
m_.DisableControls;
try
showmessage('Description is requierd - canceling insert - try again');
dataset.cancel;
finally
m_.EnableControls;
end;
zPostData := false;
zPostState := 0;
exit;
end;
if dataset.FieldByName('code').AsString = '' then
begin
m_.DisableControls;
try
showmessage('Code is requierd - canceling insert - try again');
dataset.cancel;
finally
m_.EnableControls;
end;
zPostData := false;
zPostState := 0;
exit;
end;
zPostData := true;
zPostState := 2;
glb.LogChanges(DataSet, 'channelmanagers', ADD_RECORD, 'Channel Managers ID = ' + dataset.FieldByName('Code').AsString + ', name = ' + dataset.FieldByName('Description').AsString);
end;
end;
procedure TfrmChannelManager.m_NewRecord(DataSet: TDataSet);
begin
end;
////////////////////////////////////////////////////////////////////////////////////////
// tvFunctions
////////////////////////////////////////////////////////////////////////////////////////
procedure TfrmChannelManager.tvDataChannelManagerPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
var Error: Boolean);
var
CurrValue : string;
begin
currValue := m_.fieldbyname('Description').asstring;
error := false;
if trim(displayValue) = '' then
begin
error := true;
errortext := 'Description'+' - '+'is required - Use ESC to cancel';
exit;
end;
end;
procedure TfrmChannelManager.tvDatachannelsPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
LookupForDataItem('Channels',
glb.ChannelsSet,
'id',
'name',
m_['schannels'],
True,
True,
'active',
m_,
'schannels');
end;
procedure TfrmChannelManager.tvDataCellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo;
AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
begin
if zAct = actLookup then
begin
btnOk.click;
end else
begin
btnEdit.Click;
end;
end;
procedure TfrmChannelManager.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;
///////////////////////////////////////////////////////////////////////////////
// Filter
///////////////////////////////////////////////////////////////////////////////
procedure TfrmChannelManager.tvDataDataControllerFilterChanged(Sender: TObject);
begin
chkFilter;
end;
procedure TfrmChannelManager.edFilterClickBtn(Sender: TObject);
begin
edFilter.Text := '';
end;
procedure TfrmChannelManager.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 TfrmChannelManager.ApplyFilter;
begin
tvData.DataController.Filter.Options := [fcoCaseInsensitive];
tvData.DataController.Filter.Root.BoolOperatorKind := fboOr;
tvData.DataController.Filter.Root.Clear;
tvData.DataController.Filter.Root.AddItem(tvDataDescription,foLike,'%'+Uppercase(edFilter.Text)+'%','%'+Uppercase(edFilter.Text)+'%');
tvData.DataController.Filter.Root.AddItem(tvDatawebserviceUsername,foLike,'%'+edFilter.Text+'%','%'+edFilter.Text+'%');
tvData.DataController.Filter.Root.AddItem(tvDatawebserviceHotelCode,foLike,'%'+edFilter.Text+'%','%'+edFilter.Text+'%');
tvData.DataController.Filter.Root.AddItem(tvDataadminUsername,foLike,'%'+edFilter.Text+'%','%'+edFilter.Text+'%');
tvData.DataController.Filter.Active := True;
end;
//////////////////////////////////////////////////////////////////////////
// Buttons
//////////////////////////////////////////////////////////////////////////
procedure TfrmChannelManager.btnDeleteClick(Sender: TObject);
var
cNumber : string;
cDescription : string;
s : string;
prevCode : string;
currCode : string;
begin
cNumber := m_.fieldbyname('Id').asstring;
cDescription := m_.fieldbyname('Description').asstring;
s := '';
s := s+GetTranslatedText('shDeleteChannelManager')+' '+cNumber+' '+chr(10);
s := s+GetTranslatedText('shContinue');
if MessageDlg(s,mtConfirmation, [mbYes, mbNo], 0) = mrYes then
begin
screen.Cursor := crHourGlass;
try
currCode := cNumber;
prevCode := GetPrevCode;
if hdata.Del_ChannelManagerByID(m_.fieldbyname('Id').asinteger) then
begin
try
glb.LogChanges(m_, 'channelmanagerss', DELETE_RECORD, 'Channel Manager ID = ' + m_.FieldByName('Code').AsString + ', name = ' + m_.FieldByName('Description').AsString);
fillGridFromDataset(prevCode);
except
end;
end;
finally
screen.Cursor := crDefault;
end;
end;
end;
procedure TfrmChannelManager.btnEditClick(Sender: TObject);
begin
mnuiAllowGridEdit.Checked := true;
zAllowGridEdit := mnuiAllowGridEdit.Checked;
changeAllowGridEdit;
grData.SetFocus;
tvData.GetColumnByFieldName('Description').Focused := True;
showmessage('edit in grid');
end;
procedure TfrmChannelManager.btnInsertClick(Sender: TObject);
begin
mnuiAllowGridEdit.Checked := true;
zAllowGridEdit := mnuiAllowGridEdit.Checked;
changeAllowGridEdit;
if m_.Active = false then m_.Open;
grData.SetFocus;
m_.Insert;
tvData.GetColumnByFieldName('Description').Focused := True;
end;
procedure TfrmChannelManager.BtnOkClick(Sender: TObject);
begin
fillHolder;
end;
procedure TfrmChannelManager.btnCancelClick(Sender: TObject);
begin
initChannelManagerHolder(zData);
end;
procedure TfrmChannelManager.btnClearClick(Sender: TObject);
begin
edFilter.Text := '';
end;
procedure TfrmChannelManager.btnCloseClick(Sender: TObject);
begin
if m_.State IN [dsEdit, dsInsert] then
m_.post;
fillHolder;
end;
procedure TfrmChannelManager.btnOtherClick(Sender: TObject);
begin
//**
end;
procedure TfrmChannelManager.Button1Click(Sender: TObject);
begin
EditPaymentAssuranceForChannels;
end;
procedure TfrmChannelManager.Button2Click(Sender: TObject);
begin
EditChannelsEmailConfirmationMatrix;
end;
procedure TfrmChannelManager.Button3Click(Sender: TObject);
begin
EditChannelsHotelEmailMatrix;
end;
////---------------------------------------------------------------------------
/// Menu in other actions
///-----------------------------------------------------------------------------
procedure TfrmChannelManager.mnuiAllowGridEditClick(Sender: TObject);
begin
mnuiAllowGridEdit.Checked := not mnuiAllowGridEdit.Checked;
zAllowGridEdit := mnuiAllowGridEdit.Checked;
changeAllowGridEdit;
end;
procedure TfrmChannelManager.mnuiGridToExcelClick(Sender: TObject);
var
sFilename : string;
begin
sFilename := g.qProgramPath + caption;
ExportGridToExcel(sFilename, grData, true, true, true);
ShellExecute(Handle, 'OPEN', PChar(sFilename + '.xls'), nil, nil, sw_shownormal);
// To export ot xlsx form then use this
// ExportGridToXLSX(sFilename, grData, true, true, true);
// ShellExecute(Handle, 'OPEN', PChar(sFilename + '.xlsx'), nil, nil, sw_shownormal);
end;
procedure TfrmChannelManager.mnuiGridToHtmlClick(Sender: TObject);
var
sFilename : string;
begin
sFilename := g.qProgramPath + caption;
ExportGridToHtml(sFilename, grData, true, true);
ShellExecute(Handle, 'OPEN', PChar(sFilename + '.html'), nil, nil, sw_shownormal);
end;
procedure TfrmChannelManager.mnuiGridToTextClick(Sender: TObject);
var
sFilename : string;
begin
sFilename := g.qProgramPath + caption;
ExportGridToText(sFilename, grData, true, true,';','','','txt');
ShellExecute(Handle, 'OPEN', PChar(sFilename + '.txt'), nil, nil, sw_shownormal);
end;
procedure TfrmChannelManager.mnuiGridToXmlClick(Sender: TObject);
var
sFilename : string;
begin
sFilename := g.qProgramPath + caption;
ExportGridToXml(sFilename, grData, true, true);
ShellExecute(Handle, 'OPEN', PChar(sFilename + '.xml'), nil, nil, sw_shownormal);
end;
procedure TfrmChannelManager.mnuiPrintClick(Sender: TObject);
begin
grPrinter.PrintTitle := caption;
prLink_grData.ReportTitle.Text := caption;
grPrinter.Preview(true, prLink_grData);
end;
end.