-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathuCleaningNotes.pas
739 lines (648 loc) · 21.4 KB
/
uCleaningNotes.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
unit uCleaningNotes;
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
, Hdata
, ug
, uD
, uFrmKeyPairSelector
, RoomerCloudEntities
, uManageFilesOnServer
, 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, dxSkinsCore, dxSkinDarkSide, dxSkinDevExpressDarkStyle, dxSkinMcSkin, dxSkinOffice2013White,
dxSkinsDefaultPainters, dxSkinscxPCPainter, cxCalc, cxButtonEdit, dxSkinsdxBarPainter, dxSkinsdxRibbonPainter, cxPropertiesStore, dxmdaset,
dxPScxPivotGridLnk, dxSkinCaramel, dxSkinCoffee, dxSkinTheAsphaltWorld, sCheckBox, dxSkinBlack, dxSkinBlue, dxSkinBlueprint,
dxSkinDarkRoom, dxSkinDevExpressStyle, dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky,
dxSkinLondonLiquidSky, dxSkinMoneyTwins, dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink,
dxSkinOffice2007Silver, dxSkinOffice2010Black, dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinPumpkin, dxSkinSeven,
dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus, dxSkinSilver, dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008, dxSkinValentine,
dxSkinVS2010, dxSkinWhiteprint, dxSkinXmas2008Blue, cxDropDownEdit, cxCheckBox, cxCalendar, cxCurrencyEdit,
uCurrencyHandler
, uRoomerForm, dxSkinsdxStatusBarPainter, dxStatusBar
;
type
{$SCOPEDENUMS ON}
TfrmCleaningNotes = class(TfrmBaseRoomerForm)
sPanel1: TsPanel;
btnDelete: TsButton;
btnOther: TsButton;
mnuOther: TPopupMenu;
mnuiPrint: TMenuItem;
N2: TMenuItem;
Export1: TMenuItem;
mnuiGridToExcel: TMenuItem;
mnuiGridToHtml: TMenuItem;
mnuiGridToText: TMenuItem;
mnuiGridToXml: TMenuItem;
edFilter: TsEdit;
cLabFilter: TsLabel;
btnClear: TsSpeedButton;
panBtn: TsPanel;
btnCancel: TsButton;
BtnOk: TsButton;
dsCleaningNotes: TDataSource;
grPrinter: TdxComponentPrinter;
prLink_grData: TdxGridReportLink;
m_CleaningNotes: TdxMemData;
grData: TcxGrid;
tvData: TcxGridDBTableView;
lvData: TcxGridLevel;
m_CleaningNotesID: TIntegerField;
m_CleaningNotesActive: TBooleanField;
btnInsert: TsButton;
btnEdit: TsButton;
chkActive: TsCheckBox;
timFilter: TTimer;
m_CleaningNotesinterval: TIntegerField;
m_CleaningNotesminimumDays: TIntegerField;
m_CleaningNotesserviceType: TWideStringField;
m_CleaningNotesmessage: TWideStringField;
m_CleaningNotesonceType: TWideStringField;
tvDataRecId: TcxGridDBColumn;
tvDataID: TcxGridDBColumn;
tvDataactive: TcxGridDBColumn;
tvDataserviceType: TcxGridDBColumn;
tvDataonceType: TcxGridDBColumn;
tvDatainterval: TcxGridDBColumn;
tvDataminimumDays: TcxGridDBColumn;
tvDatamessage: TcxGridDBColumn;
m_CleaningNotesonlyWhenRoomIsDirty: TBooleanField;
tvDataonlyWhenRoomIsDirty: TcxGridDBColumn;
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure m_CleaningNotesBeforeDelete(DataSet: TDataSet);
procedure m_CleaningNotesBeforePost(DataSet: TDataSet);
procedure m_CleaningNotesNewRecord(DataSet: TDataSet);
procedure tvDataDblClick(Sender: TObject);
procedure BtnOkClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
procedure tvDataDataControllerSortingChanged(Sender: TObject);
procedure btnDeleteClick(Sender: TObject);
procedure mnuiPrintClick(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 btnInsertClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure chkActiveClick(Sender: TObject);
procedure m_CleaningNotesFilterRecord(DataSet: TDataSet; var Accept: Boolean);
procedure timFilterTimer(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure m_CleaningNotesAfterPost(DataSet: TDataSet);
procedure tvDataCellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState;
var AHandled: Boolean);
procedure tvDataonceTypeCustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
procedure tvDataintervalCustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
procedure tvDataserviceTypeGetDisplayText(Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
var AText: string);
procedure tvDataonceTypeGetDisplayText(Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
var AText: string);
private
FAllowGridEdit : Boolean;
{ Private declarations }
procedure applyFilter;
procedure StopFilter;
function CopyDatasetToRecCleaningNote: recCleaningNotesHolder;
procedure SetAllowGridEdit(const Value: boolean);
procedure SetFilterForDataset(aRSet: TRoomerDataset);
function ConstructSQL: string;
procedure SetEditedValuesIn_M_Dataset;
protected
Lookup : Boolean;
zAct: TActTableAction;
zData: recCleaningNotesHolder;
property AllowGridEdit: boolean read FAllowGridEdit write SetAllowGridEdit;
procedure DoLoadData; override;
procedure UpdateControls; override;
end;
function openCleaningNotes(act : TActTableAction; Lookup : Boolean; var theData : recCleaningNotesHolder) : boolean;
implementation
{$R *.dfm}
uses
prjConst
, uSqlDefinitions
, uItemTypes2
, uMessageList
, uAppGlobal
, uDimages
, uFrmTaxItemLink
, uBookKeepingCodes
, uUtils
, UITypes
, uDateUtils
, DateUtils
, Math
, uCleaningNotesEdit
, uCleaningNotesDefinitions;
//////////////////////////////////////////////////////////////////////////////////////////////
// unit global functions
//////////////////////////////////////////////////////////////////////////////////////////////
function openCleaningNotes(act : TActTableAction; Lookup : Boolean; var theData : recCleaningNotesHolder) : boolean;
var _frmCleaningNotes : TfrmCleaningNotes;
begin
result := false;
_frmCleaningNotes := TfrmCleaningNotes.Create(nil);
try
_frmCleaningNotes.zData := theData;
_frmCleaningNotes.Lookup := Lookup;
_frmCleaningNotes.zAct := act;
_frmCleaningNotes.ShowModal;
if _frmCleaningNotes.modalresult = mrOk then
begin
theData := _frmCleaningNotes.zData;
result := true;
end
else
begin
initCleaningNoteHolder(theData);
end;
finally
freeandnil(_frmCleaningNotes);
end;
end;
///////////////////////////////////////////////////////////////////////
{ Private declarations }
///////////////////////////////////////////////////////////////////////
function TfrmCleaningNotes.CopyDatasetToRecCleaningNote:recCleaningNotesHolder;
begin
Result.ID := m_CleaningNotesID.AsInteger;
Result.Active := m_CleaningNotesActive.AsBoolean;
Result.onlyWhenRoomIsDirty := m_CleaningNotesonlyWhenRoomIsDirty.AsBoolean;
Result.serviceType := m_CleaningNotesserviceType.AsString;
Result.onceType := m_CleaningNotesonceType.asString;
Result.interval := m_CleaningNotesinterval.AsInteger;
Result.minimumDays := m_CleaningNotesminimumDays.AsInteger;
Result.smessage := m_CleaningNotesmessage.AsString;
end;
procedure TfrmCleaningNotes.SetFilterForDataset(aRSet: TRoomerDataset);
var
lFilterExpr: TStringbuilder;
begin
lFilterExpr := TStringbuilder.Create;
try
if chkActive.Checked then
lFilterExpr.Append('(active=1) ')
else
lFilterExpr.Append('(active=0) ');
aRSet.Filter := lFilterExpr.ToString;
aRSet.Filtered := aRSet.Filter <> '';
finally
lFilterExpr.Free;
end;
end;
function TfrmCleaningNotes.ConstructSQL: string;
const
cSQL = 'select * FROM cleaningnotes';
begin
Result := cSQL;
end;
Procedure TfrmCleaningNotes.DoLoadData;
var
rSet : TRoomerDataSet;
begin
inherited;
rSet := CreateNewDataSet;
rSet_bySQL(rSet, ConstructSQL);
try
SetFilterForDataset(rSet);
m_CleaningNotes.Close;
m_CleaningNotes.Open;
rSet.First;
if NOT rSet.Eof then
begin
m_CleaningNotes.DisableControls;
try
m_CleaningNotes.LoadFromDataSet(rSet);
finally
m_CleaningNotes.EnableControls;
end;
end;
finally
rSet.Free;
end;
end;
procedure TfrmCleaningNotes.chkActiveClick(Sender: TObject);
begin
if tvdata.DataController.DataSet.State in [dsEdit, dsInsert] then
begin
tvdata.DataController.Post;
end;
RefreshData;
end;
procedure TfrmCleaningNotes.SetAllowGridEdit(const Value: boolean);
begin
FAllowGridEdit := Value;
tvDataID.Options.Editing := false;
tvDataactive.Options.Editing := AllowGridEdit;
tvDataRecId.Options.Editing := AllowGridEdit;
tvDataserviceType.Options.Editing := AllowGridEdit;
tvDataonceType.Options.Editing := AllowGridEdit;
tvDatainterval.Options.Editing := AllowGridEdit;
tvDataminimumDays.Options.Editing := AllowGridEdit;
tvDatamessage.Options.Editing := AllowGridEdit;
end;
procedure TfrmCleaningNotes.StopFilter;
begin
if tvData.DataController.Filter.AutoDataSetFilter then
begin
timFilter.Enabled := False;
m_CleaningNotes.filtered := False;
tvData.DataController.Filter.Active := False;
tvData.DataController.Filter.Changed;
end else
begin
tvData.DataController.Filter.Root.Clear;
tvData.DataController.Filter.Active := false;
grData.Invalidate(true);
end;
end;
procedure TfrmCleaningNotes.edFilterChange(Sender: TObject);
begin
if edFilter.Text = '' then
begin
StopFilter;
end else
begin
applyFilter;
end;
end;
procedure TfrmCleaningNotes.applyFilter;
var i : Integer;
procedure RestartTimer;
begin
timFilter.Enabled := False;
timFilter.Interval := 500;
timFilter.Interval := 30;
timFilter.Enabled := True;
end;
begin
if tvData.DataController.Filter.AutoDataSetFilter then
begin
m_CleaningNotes.filtered := False;
RestartTimer;
end else
begin
tvData.DataController.Filter.Options := [fcoCaseInsensitive];
tvData.DataController.Filter.Root.BoolOperatorKind := fboOr;
tvData.DataController.Filter.Root.Clear;
for i := 0 to tvData.ColumnCount - 1 do
if tvData.Columns[i].DataBinding.ValueType = 'String' then
tvData.DataController.Filter.Root.AddItem(tvData.Columns[i], foLike, '%'+edFilter.Text+'%', '%'+edFilter.Text+'%');
tvData.DataController.Filter.Active := True;
end;
end;
/////////////////////////////////////////////////////////////
// Form actions
/////////////////////////////////////////////////////////////
procedure TfrmCleaningNotes.FormShow(Sender: TObject);
begin
chkActive.Checked := True;
AllowGridEdit := False; // (ZAct <> actLookup);
RefreshData;
tvData.DataController.DataModeController.GridMode := (ZAct = actLookup);
tvData.DataController.Filter.AutoDataSetFilter := tvData.DataController.DataModeController.GridMode;
tvData.DataController.MultiSelect := true;
grData.SetFocus;
end;
procedure TfrmCleaningNotes.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if tvdata.DataController.DataSet.State in [dsInsert, dsEdit] then
tvdata.DataController.Post;
end;
procedure TfrmCleaningNotes.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose := True;
end;
procedure TfrmCleaningNotes.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key = VK_ESCAPE then
if m_CleaningNotes.State in [dsInsert, dsEdit] then
begin
m_CleaningNotes.Cancel;
Key := 0;
end;
end;
procedure TfrmCleaningNotes.FormKeyPress(Sender: TObject; var Key: Char);
begin
if (ZAct = actLookup) and (ActiveControl <> edFilter) then
begin
if key = chr(13) then
btnOk.click;
end;
end;
////////////////////////////////////////////////////////////////////////////////////////
// memory table
////////////////////////////////////////////////////////////////////////////////////////
procedure TfrmCleaningNotes.m_CleaningNotesAfterPost(DataSet: TDataSet);
begin
glb.ForceTableRefresh;
end;
procedure TfrmCleaningNotes.m_CleaningNotesBeforeDelete(DataSet: TDataSet);
var
s : string;
begin
zData := CopyDatasetToRecCleaningNote;
s := '';
s := s+GetTranslatedText('shDeleteItem')+' '+zData.smessage+' '+chr(10);
s := s+GetTranslatedText('shContinue');
if (MessageDlg(s,mtConfirmation, [mbYes, mbNo], 0) = mrNo) or not Del_CleaningNote(zData) then
abort;
end;
procedure TfrmCleaningNotes.m_CleaningNotesBeforePost(DataSet: TDataSet);
var
nID : integer;
begin
initCleaningNoteHolder(zData);
zData := CopyDatasetToRecCleaningNote;
if tvData.DataController.DataSource.State = dsEdit then
begin
if UPD_CleaningNote(zData) then
begin
glb.ForceTableRefresh;
end else
begin
abort;
exit;
end;
end;
if tvData.DataController.DataSource.State = dsInsert then
begin
if m_CleaningNotesserviceType.AsString = '' then
begin
showmessage(GetTranslatedText('shServiceTypeNeeded'));
tvData.GetColumnByFieldName('serviceType').Focused := True;
abort;
exit;
end;
if m_CleaningNotesonceType.AsString = '' then
begin
showmessage(GetTranslatedText('shOnceTypeNeeded'));
tvData.GetColumnByFieldName('onceType').Focused := True;
abort;
exit;
end;
if ins_CleaningNote(zData,nID) then
m_CleaningNotesID.AsInteger := nID
else
abort;
end;
end;
procedure TfrmCleaningNotes.m_CleaningNotesFilterRecord(DataSet: TDataSet; var Accept: Boolean);
begin
if tvData.DataController.Filter.AutoDataSetFilter AND (edFilter.Text <> '') then
Accept := pos(Lowercase(edFilter.Text), LowerCase(dataset['Description'])) > 0;
end;
procedure TfrmCleaningNotes.m_CleaningNotesNewRecord(DataSet: TDataSet);
begin
dataset['Active'] := true;
dataset['serviceType'] := TCleaningNoteServiceType.ctInterval.ToDB;
dataset['onceType'] := TCleaningNoteOnceType.coCheck_In_Day.ToDB;
dataset['interval'] := 3;
dataset['minimumDays'] := 3;
dataset['message'] := '';
end;
////////////////////////////////////////////////////////////////////////////////////////
// table View Functions
////////////////////////////////////////////////////////////////////////////////////////
procedure TfrmCleaningNotes.tvDataonceTypeCustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
var ADone: Boolean);
begin
with TcxGridDBTableView(Sender).DataController do
aDone := AViewInfo.GridRecord.Values[tvDataserviceType.Index] = TCleaningNoteServiceType.ctInterval.ToDB;
end;
procedure TfrmCleaningNotes.tvDataonceTypeGetDisplayText(Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
var AText: string);
begin
inherited;
aText := TCleaningNoteOnceType.FromString(aText).AsReadableString;
end;
procedure TfrmCleaningNotes.tvDataserviceTypeGetDisplayText(Sender: TcxCustomGridTableItem;
ARecord: TcxCustomGridRecord; var AText: string);
begin
inherited;
aText := TCleaningNoteServiceType.FromString(aText).AsReadableString;
end;
procedure TfrmCleaningNotes.UpdateControls;
begin
inherited;
panBtn.Visible := (Zact = actLookup);
tvData.OptionsData.Editing := FAllowGridEdit;
end;
procedure TfrmCleaningNotes.tvDataDblClick(Sender: TObject);
begin
if ZAct = actLookup then
btnOK.Click
end;
procedure TfrmCleaningNotes.tvDataintervalCustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
var ADone: Boolean);
begin
with TcxGridDBTableView(Sender).DataController do
aDone := (AViewInfo.GridRecord.Values[tvDataserviceType.Index] = TCleaningNoteServiceType.ctOnce.ToDB) and
NOT ((AViewInfo.GridRecord.Values[tvDataonceType.Index] = TCleaningNoteOnceType.coXth_Day.ToDB) OR
(AViewInfo.GridRecord.Values[tvDataonceType.Index] = TCleaningNoteOnceType.coX_Days_After_Check_Out.ToDB));
end;
////////////////////////////////////////////////////////////////////////////
// Filter
/////////////////////////////////////////////////////////////////////////////
procedure TfrmCleaningNotes.timFilterTimer(Sender: TObject);
begin
timFilter.Enabled := False;
m_CleaningNotes.filtered := True;
tvData.DataController.Filter.Refresh;
end;
procedure TfrmCleaningNotes.tvDataCellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
begin
btnEdit.Click;
end;
procedure TfrmCleaningNotes.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;
end;
//////////////////////////////////////////////////////////////////////////
// Buttons
//////////////////////////////////////////////////////////////////////////
procedure TfrmCleaningNotes.BtnOkClick(Sender: TObject);
begin
zData := CopyDatasetToRecCleaningNote;
end;
procedure TfrmCleaningNotes.btnCancelClick(Sender: TObject);
begin
initCleaningNoteHolder(zData);
end;
procedure TfrmCleaningNotes.btnClearClick(Sender: TObject);
begin
edFilter.Text := '';
end;
procedure TfrmCleaningNotes.btnDeleteClick(Sender: TObject);
begin
m_CleaningNotes.Delete;
end;
procedure TfrmCleaningNotes.btnEditClick(Sender: TObject);
begin
zData := CopyDatasetToRecCleaningNote;
if openCleaningNotesEdit(zData) then
begin
m_CleaningNotes.edit;
SetEditedValuesIn_M_Dataset;
m_CleaningNotes.Post;
end;
end;
procedure TfrmCleaningNotes.SetEditedValuesIn_M_Dataset;
begin
m_CleaningNotes['Active'] := zData.active;
m_CleaningNotes['onlyWhenRoomIsDirty'] := zData.onlyWhenRoomIsDirty;
m_CleaningNotes['serviceType'] := zData.serviceType;
m_CleaningNotes['onceType'] := zData.onceType;
m_CleaningNotes['interval'] := zData.interval;
m_CleaningNotes['minimumDays'] := zData.minimumDays;
m_CleaningNotes['message'] := zData.smessage;
end;
procedure TfrmCleaningNotes.btnInsertClick(Sender: TObject);
begin
m_CleaningNotes.insert;
try
zData := CopyDatasetToRecCleaningNote;
if openCleaningNotesEdit(zData) then
begin
SetEditedValuesIn_M_Dataset;
m_CleaningNotes.Post;
end
else
m_CleaningNotes.Cancel;
except
m_CleaningNotes.Cancel;
raise;
end;
end;
//---------------------------------------------------------------------------
// Menu in other actions
//-----------------------------------------------------------------------------
procedure TfrmCleaningNotes.mnuiPrintClick(Sender: TObject);
begin
grPrinter.PrintTitle := caption;
prLink_grData.ReportTitle.Text := caption;
grPrinter.Preview(true, prLink_grData);
end;
procedure TfrmCleaningNotes.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);
end;
procedure TfrmCleaningNotes.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 TfrmCleaningNotes.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 TfrmCleaningNotes.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;
end.