-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathuCleaningNotesEdit.pas
135 lines (116 loc) · 4.07 KB
/
uCleaningNotesEdit.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
unit uCleaningNotesEdit;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, uDImages, hData, Vcl.StdCtrls, sButton, Vcl.ExtCtrls, sPanel, cxClasses, cxPropertiesStore, sMemo, sEdit, sCheckBox,
sComboBox, sLabel
, uRoomerForm, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore, dxSkinCaramel,
dxSkinCoffee, dxSkinDarkSide, dxSkinTheAsphaltWorld, dxSkinsDefaultPainters, dxSkinsdxStatusBarPainter,
cxGridTableView, cxStyles, dxPScxCommon, dxPScxGridLnk, dxStatusBar;
type
TfrmCleaningNotesEdit = class(TfrmBaseRoomerForm)
panBtn: TsPanel;
btnCancel: TsButton;
BtnOk: TsButton;
sLabel1: TsLabel;
__cbxServiceType: TsComboBox;
lblOnceType: TsLabel;
__cbxOnceType: TsComboBox;
cbxActive: TsCheckBox;
__lblInterval: TsLabel;
edtInterval: TsEdit;
lblMinimumDays: TsLabel;
edtMinimumDays: TsEdit;
sLabel5: TsLabel;
edtMessage: TsMemo;
cbxOnlyWhenRoomIsDirty: TsCheckBox;
procedure FormShow(Sender: TObject);
procedure __cbxOnceTypeCloseUp(Sender: TObject);
procedure __cbxServiceTypeCloseUp(Sender: TObject);
private
protected
procedure UpdateControls; override;
procedure DoLoadData; override;
public
{ Public declarations }
zData : recCleaningNotesHolder;
procedure EditsToRecordHolder;
end;
function openCleaningNotesEdit(var theData : recCleaningNotesHolder) : boolean;
implementation
{$R *.dfm}
uses PrjConst,
uRoomerLanguage,
uAppGlobal,
uUtils
, uCleaningNotesDefinitions;
function openCleaningNotesEdit(var theData : recCleaningNotesHolder) : boolean;
var
_FrmCleaningNotesEdit: TFrmCleaningNotesEdit;
begin
result := false;
_FrmCleaningNotesEdit := TFrmCleaningNotesEdit.Create(nil);
try
_FrmCleaningNotesEdit.zData := theData;
_FrmCleaningNotesEdit.ShowModal;
if _FrmCleaningNotesEdit.modalresult = mrOk then
begin
_FrmCleaningNotesEdit.EditsToRecordHolder;
theData := _FrmCleaningNotesEdit.zData;
result := true;
end
finally
freeandnil(_FrmCleaningNotesEdit);
end;
end;
procedure TfrmCleaningNotesEdit.DoLoadData;
begin
inherited;
cbxActive.Checked := zData.active;
__cbxServiceType.ItemIndex := TCleaningNoteServiceType.FromString(zData.serviceType).ToItemIndex;
__cbxOnceType.ItemIndex := TCleaningNoteOnceType.FromString(zData.onceType).ToItemIndex;
edtInterval.Text := InttoStr(zData.interval);
edtMinimumDays.Text := InttoStr(zData.minimumDays);
cbxOnlyWhenRoomIsDirty.Checked := zData.onlyWhenRoomIsDirty;
edtMessage.Text := zData.smessage;
end;
procedure TFrmCleaningNotesEdit.EditsToRecordHolder;
begin
zData.active := cbxActive.Checked;
zData.serviceType := TCleaningNoteServiceType.FromItemIndex(__cbxServiceType.itemIndex).ToDb;
zData.onlyWhenRoomIsDirty := cbxOnlyWhenRoomIsDirty.Checked;
zData.onceType := TCleaningNoteOnceType.FromItemIndex(__cbxOnceType.ItemIndex).ToDb;
zData.interval := StrToIntDef(edtInterval.Text, 3);
zData.minimumDays := StrToIntDef(edtMinimumDays.Text, 1);
zData.smessage := edtMessage.Text;
end;
procedure TfrmCleaningNotesEdit.FormShow(Sender: TObject);
begin
TCleaningNoteServiceType.AsStrings(__cbxServiceType.Items);
TCleaningNoteOnceType.AsStrings(__cbxOnceType.items);
RefreshData;
end;
procedure TfrmCleaningNotesEdit.__cbxOnceTypeCloseUp(Sender: TObject);
begin
UpdateControls;
end;
procedure TfrmCleaningNotesEdit.__cbxServiceTypeCloseUp(Sender: TObject);
begin
UpdateControls;
end;
procedure TFrmCleaningNotesEdit.UpdateControls;
begin
inherited;
__cbxOnceType.Visible := __cbxServiceType.ItemIndex > 0;
if __cbxServiceType.ItemIndex = 0 then
begin
__lblInterval.Caption := GetTranslatedText('shCleaningNotesIntervalLabel');
end else
begin
__lblInterval.Caption := GetTranslatedText('shCleaningNotesOnceLabel');
end;
lblOnceType.Visible := __cbxOnceType.Visible;
__lblInterval.Visible := (NOT __cbxOnceType.Visible) OR (__cbxOnceType.ItemIndex IN [3,4]);
edtInterval.Visible := __lblInterval.Visible;
end;
end.