-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathuChannelPlanCodes.pas
818 lines (723 loc) · 20.7 KB
/
uChannelPlanCodes.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
unit uChannelPlanCodes;
interface
uses
Windows
, Messages
, SysUtils
, Variants
, Classes
, Graphics
, Controls
, Forms
, Dialogs
, Menus
, ImgList
, StdCtrls
, Mask
, ExtCtrls
, Grids
, Buttons
, shellapi
, ADODB
, db
, DBTables
, DBCtrls
, ComCtrls
, 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
, dxmdaset
, cxGridBandedTableView
, cxGridDBBandedTableView
, cxCalc
, cxVariants
, cxDataUtils
, AdvEdit
, AdvEdBtn
, PrjConst, cxButtonEdit, cxCheckBox
, cmpRoomerDataSet
, cmpRoomerConnection
, sLabel
, sSpeedButton
, sEdit
, sButton
, sPanel
, sStatusBar, dxSkinsCore, dxSkinDarkSide, dxSkinDevExpressDarkStyle, dxSkinMcSkin, dxSkinOffice2013White, dxSkinsDefaultPainters,
dxSkinscxPCPainter, dxSkinsdxBarPainter, dxSkinsdxRibbonPainter, cxPropertiesStore, sCheckBox, dxPScxPivotGridLnk, dxSkinCaramel, dxSkinCoffee, dxSkinTheAsphaltWorld
;
type
TfrmChannelPlanCodes = class(TForm)
sbMain: TsStatusBar;
PanTop: TsPanel;
btnDelete: TsButton;
btnOther: TsButton;
btnClose: TsButton;
labFilterWarning: TStaticText;
panBtn: TsPanel;
btnCancel: TsButton;
BtnOk: TsButton;
tvData: TcxGridDBTableView;
lvData: TcxGridLevel;
grData: TcxGrid;
m_: TdxMemData;
mnuOther: TPopupMenu;
mnuiPrint: TMenuItem;
mnuiAllowGridEdit: TMenuItem;
N2: TMenuItem;
Export1: TMenuItem;
mnuiGridToExcel: TMenuItem;
mnuiGridToHtml: TMenuItem;
mnuiGridToText: TMenuItem;
mnuiGridToXml: TMenuItem;
DS: TDataSource;
grPrinter: TdxComponentPrinter;
prLink_grData: TdxGridReportLink;
Label1: TsLabel;
edFilter: TsEdit;
btnClear: TsSpeedButton;
cLabFilter: TsLabel;
btnInsert: TsButton;
btnEdit: TsButton;
m_Code: TWideStringField;
m_Active: TBooleanField;
tvDataRecId: TcxGridDBColumn;
tvDataCode: TcxGridDBColumn;
tvDataActive: TcxGridDBColumn;
m_Description: TWideStringField;
tvDataDescription: TcxGridDBColumn;
chkActive: TsCheckBox;
FormStore: TcxPropertiesStore;
m_defaultPlan: TBooleanField;
tvDatadefaultPlan: TcxGridDBColumn;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
procedure btnDeleteClick(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure BtnOkClick(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
procedure mnuExitClick(Sender: TObject);
procedure btnOtherClick(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 m_BeforePost(DataSet: TDataSet);
procedure edFilterChange(Sender: TObject);
procedure tvDataDataControllerFilterChanged(Sender: TObject);
procedure m_NewRecord(DataSet: TDataSet);
procedure tvDataDblClick(Sender: TObject);
procedure tvDataDataControllerSortingChanged(Sender: TObject);
procedure btnInsertClick(Sender: TObject);
procedure tvDataFocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord;
ANewItemRecordFocusingChanged: Boolean);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure m_BeforeDelete(DataSet: TDataSet);
procedure m_BeforeInsert(DataSet: TDataSet);
procedure btnClearClick(Sender: TObject);
procedure btnEditClick(Sender: TObject);
procedure tvDataCodePropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
procedure chkActiveClick(Sender: TObject);
private
{ Private declarations }
zFirstTime : boolean;
zAllowGridEdit : boolean;
zFilterOn : boolean;
zSortStr : string;
zIsAddRow : boolean;
Procedure fillGridFromDataset(sGoto : string);
procedure fillHolder;
procedure changeAllowgridEdit;
Procedure chkFilter;
procedure applyFilter;
public
{ Public declarations }
zAct : TActTableAction;
zData : recChannelPlanCodeHolder;
end;
function ChannelPlanCodes(act : TActTableAction; var theData : recChannelPlanCodeHolder) : boolean;
function getChannelPlanCode(ed : TAdvEdit; lab : TLabel) : boolean;
function ChannelCodeValidate(ed : TAdvEdit; lab: TLabel) : boolean;
var
frmChannelPlanCodes: TfrmChannelPlanCodes;
implementation
uses
uD, uDImages, uUtils;
{$R *.dfm}
//////////////////////////////////////////////////////////////////////////////////////////////
// unit global functions
//////////////////////////////////////////////////////////////////////////////////////////////
function ChannelPlanCodes(act : TActTableAction; var theData : recChannelPlanCodeHolder) : boolean;
begin
result := false;
frmChannelPlanCodes := TfrmChannelPlanCodes.Create(frmChannelPlanCodes);
try
frmChannelPlanCodes.zData := theData;
frmChannelPlanCodes.zAct := act;
frmChannelPlanCodes.ShowModal;
if frmChannelPlanCodes.modalresult = mrOk then
begin
theData := frmChannelPlanCodes.zData;
result := true;
end
else
begin
initChannelPlanCodeHolder(theData);
end;
finally
freeandnil(frmChannelPlanCodes);
end;
end;
function getChannelPlanCode(ed : TAdvEdit; lab : TLabel) : boolean;
var
theData : recChannelPlanCodeHolder;
begin
result := false;
initChannelPlanCodeHolder(theData);
theData.Code := trim(ed.text);
result := ChannelPlanCodes(actLookup,theData);
if trim(theData.Code) = trim(ed.text) then
begin
result := false;
exit;
end;
if result and (theData.Code <> ed.text) then
begin
ed.text := theData.Code;
lab.Caption := theData.Description;
end;
end;
function ChannelCodeValidate(ed : TAdvEdit; lab : TLabel) : boolean;
var
sValue : string;
pcCode : string;
theData : recChannelPlanCodeHolder;
begin
initChannelPlanCodeHolder(theData);
theData.Code := trim(ed.Text);
result := hdata.GET_ChannelPlanCodeHolder(theData);
if not result then
begin
ed.SetFocus;
lab.Color := clRed;
lab.caption := GetTranslatedText('shNotF_star');
end else
begin
lab.Color := clBtnFace;
lab.caption := theData.Description;
end;
end;
//END unit global functions
///////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////
Procedure TfrmChannelPlanCodes.fillGridFromDataset(sGoto : string);
var
s : string;
rSet : TRoomerDataSet;
active : boolean;
begin
active := chkActive.Checked;
zFirstTime := true;
if zSortStr = '' then zSortStr := 'Code ';
s := '';
s := s+ ' SELECT *'+#10;
s := s+ ' FROM '+#10;
s := s+ ' channelplancodes '+#10;
s := s+ ' WHERE '+#10;
s := s+ ' Active = %d '+#10;
s := s+ ' ORDER BY '+#10;
s := s+ ' '+zSortStr+' ';
s := format(s, [ord(active)]);
rSet := CreateNewDataSet;
try
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('Code',sGoto,[]);
except
end;
end;
end;
finally
freeandnil(rSet);
end;
end;
procedure TfrmChannelPlanCodes.fillHolder;
begin
initChannelPlanCodeHolder(zData);
zData.Code := m_.fieldbyname('Code').asstring;
zData.Description := m_.fieldbyname('Description').asstring;
zData.active := m_['active'];
zData.defaultPlan := m_.fieldbyname('defaultPlan').AsBoolean;
end;
procedure TfrmChannelPlanCodes.changeAllowgridEdit;
begin
if zAllowGridEdit then
begin
tvDataCode.Options.Editing := true;
tvDataDescription.Options.Editing := true;
tvDataActive.Options.Editing := true;
tvDatadefaultPlan.Options.Editing := true;
end else
begin
tvDataCode.Options.Editing := false;
tvDataDescription.Options.Editing := false;
tvDataActive.Options.Editing := false;
tvDatadefaultPlan.Options.Editing := False;
end;
end;
procedure TfrmChannelPlanCodes.chkActiveClick(Sender: TObject);
begin
zFirstTime := false;
if tvdata.DataController.DataSet.State = dsEdit then
begin
tvdata.DataController.Post;
end;
fillGridFromDataset(zData.code);
zFirstTime := false;
end;
Procedure TfrmChannelPlanCodes.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 := format(GetTranslatedText('shFilterOnRecordsOf'), [rc2, rc1]);
end else
begin
labFilterWarning.Visible := false;
end;
end;
/////////////////////////////////////////////////////////////
// Form actions
/////////////////////////////////////////////////////////////
procedure TfrmChannelPlanCodes.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if tvdata.DataController.DataSet.State = dsInsert then
begin
tvdata.DataController.Post;
end;
if tvdata.DataController.DataSet.State = dsEdit then
begin
tvdata.DataController.Post;
end;
end;
procedure TfrmChannelPlanCodes.FormCreate(Sender: TObject);
begin
RoomerLanguage.TranslateThisForm(self);
glb.PerformAuthenticationAssertion(self);
PlaceFormOnVisibleMonitor(self);
zFirstTime := true;
zAct := actNone;
zisAddrow := false;
end;
procedure TfrmChannelPlanCodes.FormShow(Sender: TObject);
begin
panBtn.Visible := False;
sbMain.Visible := false;
btnClose.Visible := False;
fillGridFromDataset(zData.Code);
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 TfrmChannelPlanCodes.FormDestroy(Sender: TObject);
begin
//
end;
procedure TfrmChannelPlanCodes.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 TfrmChannelPlanCodes.m_BeforeDelete(DataSet: TDataSet);
var
s : string;
begin
fillHolder;
if hdata.ChannelPlanCodeExistsInOther(zData.Code) then
begin
Showmessage(format(GetTranslatedText('shExistsInRelatedDataCannotDelete'), ['Code', zData.Description]));
Abort;
exit;
end;
s := '';
s := s+GetTranslatedText('shDeleteChannelPlanCode')+' '+zData.Description+' '+chr(10);
s := s+GetTranslatedText('shContinue');
if MessageDlg(s,mtConfirmation, [mbYes, mbNo], 0) = mrYes then
begin
if not Del_ChannelPlanCode(zData) then
begin
abort;
end
end else
begin
abort
end;
end;
procedure TfrmChannelPlanCodes.m_BeforeInsert(DataSet: TDataSet);
begin
if zFirstTime then exit;
tvData.GetColumnByFieldName('Code').Focused := True;
end;
procedure TfrmChannelPlanCodes.m_BeforePost(DataSet: TDataSet);
begin
if zFirstTime then exit;
initChannelPlanCodeHolder(zData);
zData.Code := dataset.fieldbyname('Code').asstring;
zData.Description := dataset.fieldbyname('Description').asstring;
zData.Active := dataset.fieldbyname('active').asBoolean;
zData.DefaultPlan := dataset.fieldbyname('defaultPlan').asBoolean;
if tvData.DataController.DataSource.State = dsEdit then
begin
if UPD_ChannelPlanCode(zData) then
begin
glb.ForceTableRefresh;
end else
begin
label1.Caption := GetTranslatedText('shTx_ChannelPlanCodes_UpdateNotOK');
abort;
exit;
end;
end;
if tvData.DataController.DataSource.State = dsInsert then
begin
if dataset.FieldByName('Code').AsString = '' then
begin
showmessage(GetTranslatedText('shTx_ChannelPlanCodes_CodeRequired'));
tvData.GetColumnByFieldName('Code').Focused := True;
abort;
exit;
end;
if ins_ChannelPlanCode(zData) then
begin
glb.ForceTableRefresh;
end else
begin
label1.Caption := GetTranslatedText('shTx_ChannelPlanCodes_InsertNotOK');
abort;
exit;
end;
end;
end;
procedure TfrmChannelPlanCodes.m_NewRecord(DataSet: TDataSet);
begin
dataset.fieldbyname('active').asBoolean := true;
dataset.fieldbyname('defaultPlan').asBoolean := true;
end;
////////////////////////////////////////////////////////////////////////////////////////
// tvFunctions
////////////////////////////////////////////////////////////////////////////////////////
procedure TfrmChannelPlanCodes.tvDataDblClick(Sender: TObject);
begin
if ZAct = actLookup then
begin
btnOK.Click
end;
end;
procedure TfrmChannelPlanCodes.tvDataFocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord,
AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
begin
if AFocusedRecord = nil then
begin
zIsAddrow := true;
end else
begin
zIsAddrow := false;
end;
end;
////////////////////////////////////////////////////////////////////////////
// Filter
/////////////////////////////////////////////////////////////////////////////
procedure TfrmChannelPlanCodes.tvDataCodePropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
var Error: Boolean);
var
CurrValue : string;
begin
currValue := m_.fieldbyname('Code').asstring;
error := false;
if trim(displayValue) = '' then
begin
error := true;
// errortext := 'VatCode code '+' - '+'is required - Use ESC to cancel';
errortext := GetTranslatedText('shTx_ChannelPlanCodes_CodeIsRequired');
exit;
end;
if hdata.ChannelPlanCodeExist(displayValue) then
begin
error := true;
errortext := displayvalue+' '+GetTranslatedText('shNewValueExistInAnotherRecor');
exit
end;
if tvData.DataController.DataSource.State = dsEdit then
begin
if hdata.channelPlanCodeExistsInOther(currValue) then
begin
error := true;
errortext := displayvalue+' - '+GetTranslatedText('shOldValueUsedInRelatedDataC');
exit;
end;
end;
end;
procedure TfrmChannelPlanCodes.tvDataDataControllerFilterChanged(Sender: TObject);
begin
chkFilter;
end;
procedure TfrmChannelPlanCodes.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;
procedure TfrmChannelPlanCodes.ApplyFilter;
begin
tvData.DataController.Filter.Options := [fcoCaseInsensitive];
tvData.DataController.Filter.Root.BoolOperatorKind := fboOr;
tvData.DataController.Filter.Root.Clear;
tvData.DataController.Filter.Root.AddItem(tvDataCode ,foLike,'%'+Uppercase(edFilter.Text)+'%','%'+Uppercase(edFilter.Text)+'%');
tvData.DataController.Filter.Root.AddItem(tvDataDescription,foLike,'%'+edFilter.Text+'%','%'+edFilter.Text+'%');
tvData.DataController.Filter.Active := True;
end;
procedure TfrmChannelPlanCodes.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;
//////////////////////////////////////////////////////////////////////////
// Buttons
//////////////////////////////////////////////////////////////////////////
procedure TfrmChannelPlanCodes.BtnOkClick(Sender: TObject);
begin
fillHolder;
end;
procedure TfrmChannelPlanCodes.btnCancelClick(Sender: TObject);
begin
initChannelPlanCodeHolder(zData);
end;
procedure TfrmChannelPlanCodes.btnClearClick(Sender: TObject);
begin
edFilter.Text := '';
end;
procedure TfrmChannelPlanCodes.btnCloseClick(Sender: TObject);
begin
fillHolder;
end;
procedure TfrmChannelPlanCodes.mnuExitClick(Sender: TObject);
begin
Close;
end;
procedure TfrmChannelPlanCodes.btnOtherClick(Sender: TObject);
begin
//
end;
procedure TfrmChannelPlanCodes.btnDeleteClick(Sender: TObject);
begin
m_.Delete;
end;
procedure TfrmChannelPlanCodes.btnEditClick(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;
mnuiAllowGridEdit.Checked := true;
zAllowGridEdit := mnuiAllowGridEdit.Checked;
changeAllowGridEdit;
grData.SetFocus;
tvData.GetColumnByFieldName('Description').Focused := True;
showmessage(GetTranslatedText('shTx_Items2_EditInGrid'));
end;
procedure TfrmChannelPlanCodes.btnInsertClick(Sender: TObject);
begin
mnuiAllowGridEdit.Checked := true;
zAllowGridEdit := mnuiAllowGridEdit.Checked;
changeAllowGridEdit;
if m_.Active = false then m_.Open;
grData.SetFocus;
m_.Insert;
tvData.GetColumnByFieldName('Code').Focused := True;
end;
////---------------------------------------------------------------------------
/// Menu in other actions
///-----------------------------------------------------------------------------
procedure TfrmChannelPlanCodes.mnuiAllowGridEditClick(Sender: TObject);
begin
if zFirstTime then exit;
mnuiAllowGridEdit.Checked := not mnuiAllowGridEdit.Checked;
zAllowGridEdit := mnuiAllowGridEdit.Checked;
changeAllowGridEdit;
end;
procedure TfrmChannelPlanCodes.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 TfrmChannelPlanCodes.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 TfrmChannelPlanCodes.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 TfrmChannelPlanCodes.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 TfrmChannelPlanCodes.mnuiPrintClick(Sender: TObject);
begin
grPrinter.PrintTitle := caption;
prLink_grData.ReportTitle.Text := caption;
grPrinter.Preview(true, prLink_grData);
end;
end.