source: cprs/branches/tmg-cprs/CPRS-Chart/Options/fOptionsReportsDefault.pas@ 494

Last change on this file since 494 was 453, checked in by Kevin Toppenberg, 16 years ago

Initial upload of TMG-CPRS 1.0.26.69

File size: 18.2 KB
Line 
1//kt -- Modified with SourceScanner on 8/8/2007
2unit fOptionsReportsDefault;
3
4interface
5
6uses
7 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
8 StdCtrls, ExtCtrls, Spin, fOptions, ComCtrls, ORFn, ORNet, ORCtrls,
9 ORDtTm, rCore, DKLang;
10
11type
12 TfrmOptionsReportsDefault = class(TForm)
13 Label2: TLabel;
14 Label3: TLabel;
15 Label4: TLabel;
16 edtDefaultMax: TCaptionEdit;
17 Bevel1: TBevel;
18 Bevel2: TBevel;
19 Panel1: TPanel;
20 btnOK: TButton;
21 btnReset: TButton;
22 lblDefaultText: TMemo;
23 btnCancel: TButton;
24 odcDfStart: TORDateBox;
25 odcDfStop: TORDateBox;
26 DKLanguageController1: TDKLanguageController;
27 procedure btnOKClick(Sender: TObject);
28 procedure btnCancelClick(Sender: TObject);
29 procedure btnResetClick(Sender: TObject);
30 procedure edtDefaultMaxExit(Sender: TObject);
31 procedure edtDefaultStartKeyPress(Sender: TObject; var Key: Char);
32 procedure edtDefaultEndKeyPress(Sender: TObject; var Key: Char);
33 procedure edtDefaultMaxKeyPress(Sender: TObject; var Key: Char);
34 procedure FormCreate(Sender: TObject);
35 procedure odcDfStartExit(Sender: TObject);
36 procedure odcDfStopExit(Sender: TObject);
37 procedure odcDfStartKeyPress(Sender: TObject; var Key: Char);
38 procedure odcDfStopKeyPress(Sender: TObject; var Key: Char);
39 procedure odcDfStartClick(Sender: TObject);
40 procedure odcDfStopClick(Sender: TObject);
41 procedure edtDefaultMaxClick(Sender: TObject);
42 private
43 { Private declarations }
44 startDate, endDate, maxOcurs: integer;
45 sDate,eDate: String;
46 public
47 { Public declarations }
48 procedure fillLabelText;
49
50 end;
51
52var
53 frmOptionsReportsDefault: TfrmOptionsReportsDefault;
54
55procedure DialogOptionsHSDefault(topvalue, leftvalue, fontsize: integer; var actiontype: Integer);
56
57implementation
58
59uses rOptions, uOptions, fReports, uCore;
60{$R *.DFM}
61
62procedure DialogOptionsHSDefault(topvalue, leftvalue, fontsize: integer; var actiontype: Integer);
63var
64 frmOptionsReportsDefault: TfrmOptionsReportsDefault;
65begin
66 frmOptionsReportsDefault := TfrmOptionsReportsDefault.Create(Application);
67 actiontype := 0;
68 try
69 with frmOptionsReportsDefault do
70 begin
71 if (topvalue < 0) or (leftvalue < 0) then
72 Position := poScreenCenter
73 else
74 begin
75 Position := poDesigned;
76 Top := topvalue;
77 Left := leftvalue;
78 end;
79 ResizeAnchoredFormToFont(frmOptionsReportsDefault);
80 ShowModal;
81 actiontype := btnOK.Tag;
82 end;
83 finally
84 frmOptionsReportsDefault.Release;
85 end;
86end;
87
88procedure TfrmOptionsReportsDefault.btnOKClick(Sender: TObject);
89var
90 valueStartdate, valueEnddate, valueMax, values: string;
91begin
92 if (odcDfStart.Text = sDate) and (odcDfStop.Text = eDate) and (not edtDefaultMax.Modified ) then
93 begin
94 Close;
95 Exit;
96 end;
97
98 if (odcDfStart.Text='') or (odcDfStop.Text='') or (edtDefaultMax.Text='') then
99 begin
100// InfoBox('You have to fill out each box, don''t leave blank!', 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
101 InfoBox(DKLangConstW('fOptionsReportsDefault_You_have_to_fill_out_each_boxx_donxxt_leave_blankx'), DKLangConstW('fOptionsReportsDefault_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
102 Exit;
103 end;
104
105 valueStartdate := odcDfStart.RelativeTime;
106 valueEnddate := odcDfStop.RelativeTime;
107 valueMax := edtDefaultMax.Text;
108 values := valueStartdate + ';' + valueEnddate + ';' + valueMax;
109//if InfoBox('Do you really want to change all of the reports settings to the specified values as following?' <-- original line. //kt 8/8/2007
110 if InfoBox(DKLangConstW('fOptionsReportsDefault_Do_you_really_want_to_change_all_of_the_reports_settings_to_the_specified_values_as_followingx') //kt added 8/8/2007
111// +#13#13' Start date: ' + odcDfStart.Text <-- original line. //kt 8/8/2007
112 +#13#13+DKLangConstW('fOptionsReportsDefault_Start_datex') + odcDfStart.Text //kt added 8/8/2007
113// +#13' End date: ' + odcDfStop.Text <-- original line. //kt 8/8/2007
114 +#13+DKLangConstW('fOptionsReportsDefault_End_datex') + odcDfStop.Text //kt added 8/8/2007
115// +#13' Max occurences: ' + edtDefaultMax.Text <-- original line. //kt 8/8/2007
116 +#13+DKLangConstW('fOptionsReportsDefault_Max_occurencesx') + edtDefaultMax.Text //kt added 8/8/2007
117// +#13#13' Click Yes, all of the CPRS reports except for health summary reports will have these same settings.', <-- original line. //kt 8/8/2007
118 +#13#13+DKLangConstW('fOptionsReportsDefault_Click_Yesx_all_of_the_CPRS_reports_except_for_health_summary_reports_will_have_these_same_settingsx'), //kt added 8/8/2007
119// 'Confirmation', MB_YESNO or MB_ICONQUESTION) = IDYES then <-- original line. //kt 8/8/2007
120 DKLangConstW('fOptionsReportsDefault_Confirmation'), MB_YESNO or MB_ICONQUESTION) = IDYES then //kt added 8/8/2007
121 begin
122 rpcSetDefaultReportsSetting(values);
123 rpcActiveDefaultSetting;
124 frmReports.LoadTreeView;
125 with frmReports.tvReports do
126 begin
127 if Items.Count > 0 then
128 Selected := Items.GetFirstNode;
129 frmReports.tvReportsClick(Selected);
130 end;
131 Close;
132 end
133 else
134 begin
135 odcDfStart.Text := sDate;
136 odcDfStop.Text := eDate;
137 edtDefaultMax.Text := IntToStr(maxOcurs);
138 end;
139end;
140
141
142procedure TfrmOptionsReportsDefault.btnCancelClick(Sender: TObject);
143begin
144 Close;
145end;
146
147procedure TfrmOptionsReportsDefault.btnResetClick(Sender: TObject);
148var
149 startD,endD,maxOc: integer;
150 values,msg,stdate,endate: string;
151 today: TFMDateTime;
152begin
153 rpcRetrieveDefaultSetting(startD,endD,maxOc,msg);
154 today := FMToday;
155 if msg = 'NODEFAULT' then
156 begin
157// InfoBox('No default report settings are available', 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
158 InfoBox(DKLangConstW('fOptionsReportsDefault_No_default_report_settings_are_available'), DKLangConstW('fOptionsReportsDefault_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
159 Exit;
160 end;
161 //if (startD=startDate) and (endD=endDate) and (maxOc=maxOcurs) then
162 // Exit;
163 stdate := DateToStr(FMDateTimeToDateTime(FMDateTimeOffsetBy(today, startD)));
164 endate := DateToStr(FMDateTimeToDateTime(FMDateTimeOffsetBy(today, endD)));
165//if InfoBox('Do you really want to change all of the reports settings to the default values as following?' <-- original line. //kt 8/8/2007
166 if InfoBox(DKLangConstW('fOptionsReportsDefault_Do_you_really_want_to_change_all_of_the_reports_settings_to_the_default_values_as_followingx') //kt added 8/8/2007
167// +#13#13' Start date: ' + stdate <-- original line. //kt 8/8/2007
168 +#13#13+DKLangConstW('fOptionsReportsDefault_Start_datex') + stdate //kt added 8/8/2007
169// +#13' End date: ' + endate <-- original line. //kt 8/8/2007
170 +#13+DKLangConstW('fOptionsReportsDefault_End_datex') + endate //kt added 8/8/2007
171// +#13' Max occurences: ' + IntToStr(maxOc) <-- original line. //kt 8/8/2007
172 +#13+DKLangConstW('fOptionsReportsDefault_Max_occurencesx') + IntToStr(maxOc) //kt added 8/8/2007
173// +#13#13' Click Yes, all of the CPRS reports except for health summary reports will have these same settings.', <-- original line. //kt 8/8/2007
174 +#13#13+DKLangConstW('fOptionsReportsDefault_Click_Yesx_all_of_the_CPRS_reports_except_for_health_summary_reports_will_have_these_same_settingsx'), //kt added 8/8/2007
175// 'Confirmation', MB_YESNO or MB_ICONQUESTION) = IDYES then <-- original line. //kt 8/8/2007
176 DKLangConstW('fOptionsReportsDefault_Confirmation'), MB_YESNO or MB_ICONQUESTION) = IDYES then //kt added 8/8/2007
177 begin
178 rpcDeleteUserLevelReportsSetting;
179 odcDfStart.Text := stdate;
180 odcDfStop.Text := endate;
181 edtDefaultMax.Text := inttostr(maxOc);
182 values := odcDfStart.RelativeTime + ';' + odcDfStop.RelativeTime + ';' + edtDefaultMax.Text;
183 rpcSetDefaultReportsSetting(values);
184 rpcActiveDefaultSetting;
185 sDate := odcDfStart.Text;
186 eDate := odcDfStop.Text;
187 startDate := startD;
188 endDate := endD;
189 maxOcurs := maxOc;
190 fillLabelText;
191 frmReports.LoadTreeView;
192 with frmReports.tvReports do
193 begin
194 if Items.Count > 0 then
195 Selected := Items.GetFirstNode;
196 frmReports.tvReportsClick(Selected);
197 end;
198 end;
199end;
200
201procedure TfrmOptionsReportsDefault.edtDefaultMaxExit(Sender: TObject);
202var
203 newValue: string;
204 I, code: integer;
205begin
206 if edtDefaultMax.Modified then
207 begin
208
209 newValue := edtDefaultMax.Text;
210 if length(newValue) = 0 then
211 begin
212// InfoBox('Invalid value of max occurences', 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
213 InfoBox(DKLangConstW('fOptionsReportsDefault_Invalid_value_of_max_occurences'), DKLangConstW('fOptionsReportsDefault_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
214 edtDefaultMax.Text := '100';
215 end;
216 if length(newValue) > 0 then
217 begin
218 Val(newValue, I, code);
219 if I = 0 then begin end; //added to keep compiler from generating a hint
220 if code <> 0 then
221 begin
222// InfoBox('Invalid value of max occurences', 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
223 InfoBox(DKLangConstW('fOptionsReportsDefault_Invalid_value_of_max_occurences'), DKLangConstW('fOptionsReportsDefault_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
224 edtDefaultMax.Text := inttostr(maxOcurs);
225 end;
226 if code = 0 then
227 if strtoint(edtDefaultMax.Text) <= 0 then
228 begin
229// InfoBox('Invalid value of max occurences', 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
230 InfoBox(DKLangConstW('fOptionsReportsDefault_Invalid_value_of_max_occurences'), DKLangConstW('fOptionsReportsDefault_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
231 edtDefaultMax.Text := inttostr(maxOcurs);
232 end;
233 end;
234 fillLabelText;
235
236 end;
237end;
238
239procedure TfrmOptionsReportsDefault.fillLabelText;
240var
241 fromday,dayto: string;
242begin
243 fromday := DateToStr(FMDateTimeToDateTime(odcDfStart.FMDateTime));
244 dayto := DateToStr(FMDateTimeToDateTime(odcDfStop.FMDateTime));
245//lblDefaultText.Text := 'All of the CPRS reports except for Health Summary reports will be displayed on the CPRS Reports tab from start date: ' <-- original line. //kt 8/8/2007
246 lblDefaultText.Text := DKLangConstW('fOptionsReportsDefault_All_of_the_CPRS_reports_except_for_Health_Summary_reports_will_be_displayed_on_the_CPRS_Reports_tab_from_start_datex') //kt added 8/8/2007
247// + fromday + ' to end date: ' + dayto + '.'; <-- original line. //kt 8/8/2007
248 + fromday + DKLangConstW('fOptionsReportsDefault_to_end_datex') + dayto + '.'; //kt added 8/8/2007
249end;
250
251procedure TfrmOptionsReportsDefault.edtDefaultStartKeyPress(Sender: TObject;
252 var Key: Char);
253begin
254 if Key = #13 then
255 begin
256 Perform(WM_NextDlgCtl, 0, 0);
257 exit;
258 end;
259end;
260
261procedure TfrmOptionsReportsDefault.edtDefaultEndKeyPress(Sender: TObject;
262 var Key: Char);
263begin
264 if Key = #13 then
265 begin
266 Perform(WM_NextDlgCtl, 0, 0);
267 exit;
268 end;
269end;
270
271procedure TfrmOptionsReportsDefault.edtDefaultMaxKeyPress(Sender: TObject;
272 var Key: Char);
273begin
274 if Key = #13 then
275 begin
276 Perform(WM_NextDlgCtl, 0, 0);
277 exit;
278 end;
279end;
280
281procedure TfrmOptionsReportsDefault.FormCreate(Sender: TObject);
282var
283 today : TFMDateTime;
284begin
285 today := FMToday;
286 rpcGetDefaultReportsSetting(startDate,endDate,maxOcurs);
287 odcDfStart.text := DateToStr(FMDateTimeToDateTime(FMDateTimeOffsetBy(today, startDate)));
288 sDate := odcDfStart.Text;
289 odcDfStop.text := DateToStr(FMDateTimeToDateTime(FMDateTimeOffsetBy(today, endDate)));
290 eDate := odcDfStop.Text;
291 if maxOcurs <> 0 then
292 begin
293 edtDefaultMax.Text := inttostr(maxOcurs);
294 fillLabelText;
295 end;
296//lblDefaultText.Text := 'Click dots in boxes to set start and end dates. You can also input values directly.'; <-- original line. //kt 8/8/2007
297 lblDefaultText.Text := DKLangConstW('fOptionsReportsDefault_Click_dots_in_boxes_to_set_start_and_end_datesx_You_can_also_input_values_directlyx'); //kt added 8/8/2007
298//btnCancel.caption := 'Cancel'; <-- original line. //kt 8/8/2007
299 btnCancel.caption := DKLangConstW('fOptionsReportsDefault_Cancel'); //kt added 8/8/2007
300 if (not User.ToolsRptEdit) then // For users with Reports settings edit parameter not set.
301 begin
302// lblDefaultText.Text := 'Settings can only be viewed (no editing provided).'; <-- original line. //kt 8/8/2007
303 lblDefaultText.Text := DKLangConstW('fOptionsReportsDefault_Settings_can_only_be_viewed_xno_editing_providedxx'); //kt added 8/8/2007
304 btnReset.visible := false;
305 btnOK.visible := false;
306// btnCancel.caption := 'Close'; <-- original line. //kt 8/8/2007
307 btnCancel.caption := DKLangConstW('fOptionsReportsDefault_Close'); //kt added 8/8/2007
308 odcDfStart.readOnly := true;
309 odcDfStart.enabled := false;
310 odcDfStart.onExit := nil;
311 odcDfStart.onKeyPress := nil;
312 odcDfStop.readOnly := true;
313 odcDfStop.enabled := false;
314 odcDfStop.onExit := nil;
315 odcDfStop.onKeyPress := nil;
316 edtDefaultMax.readOnly := true;
317 end;
318end;
319
320procedure TfrmOptionsReportsDefault.odcDfStartExit(Sender: TObject);
321//const
322//TX_BAD_START = 'The start date is not valid.'; <-- original line. //kt 8/8/2007
323//TX_STOPSTART = 'The start date must not be after the stop date.'; <-- original line. //kt 8/8/2007
324
325var
326 TX_BAD_START : string; //kt
327 TX_STOPSTART : string; //kt
328 x,ErrMsg,datestart,datestop: String;
329begin
330 TX_BAD_START := DKLangConstW('fOptionsReportsDefault_The_start_date_is_not_validx');
331 TX_STOPSTART := DKLangConstW('fOptionsReportsDefault_The_start_date_must_not_be_after_the_stop_datex');
332 if odcDfStart.text = '' then
333 begin
334// InfoBox(TX_BAD_START, 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
335 InfoBox(TX_BAD_START, DKLangConstW('fOptionsReportsDefault_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
336 odcDfStart.Text := sDate;
337 odcDfStart.Setfocus;
338 odcDfStart.SelectAll;
339 exit;
340 end;
341
342 ErrMsg := '';
343 odcDfStart.Validate(x);
344 if Length(x) > 0 then
345 begin
346 ErrMsg := TX_BAD_START;
347// InfoBox(TX_BAD_START, 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
348 InfoBox(TX_BAD_START, DKLangConstW('fOptionsReportsDefault_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
349 odcDfStart.Text := sDate;
350 odcDfStart.Setfocus;
351 odcDfStart.SelectAll;
352 exit;
353 end;
354 datestart := odcDfStart.RelativeTime;
355 datestop := odcDfStop.RelativeTime;
356 delete(datestart,1,1);
357 delete(datestop,1,1);
358 if StrToIntDef(datestop,0) < StrToIntDef(datestart,0) then
359 begin
360// InfoBox(TX_STOPSTART, 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
361 InfoBox(TX_STOPSTART, DKLangConstW('fOptionsReportsDefault_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
362 odcDfStart.Text := odcDfStop.Text;
363 odcDfStart.SetFocus;
364 odcDfStart.SelectAll;
365 exit;
366 end;
367 odcDfStart.Text := DateToStr(FMDateTimeToDateTime(odcDfStart.FMDateTime));
368 fillLabelText;
369end;
370
371procedure TfrmOptionsReportsDefault.odcDfStopExit(Sender: TObject);
372//const
373//TX_BAD_STOP = 'The stop date is not valid.'; <-- original line. //kt 8/8/2007
374//TX_BAD_ORDER = 'The stop date must not be earlier than start date.'; <-- original line. //kt 8/8/2007
375var
376 x, ErrMsg,datestart,datestop: string;
377 TX_BAD_STOP : string; //kt
378 TX_BAD_ORDER : string; //kt
379begin
380 TX_BAD_STOP := DKLangConstW('fOptionsReportsDefault_The_stop_date_is_not_validx'); //kt added 8/8/2007
381 TX_BAD_ORDER := DKLangConstW('fOptionsReportsDefault_The_stop_date_must_not_be_earlier_than_start_datex'); //kt added 8/8/2007
382 if odcDfStop.text = '' then
383 begin
384// InfoBox(TX_BAD_STOP, 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
385 InfoBox(TX_BAD_STOP, DKLangConstW('fOptionsReportsDefault_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
386 odcDfStop.Text := eDate;
387 odcDfStop.Setfocus;
388 odcDfStop.SelectAll;
389 exit;
390 end;
391
392 ErrMsg := '';
393 odcDfStop.Validate(x);
394 if Length(x) > 0 then
395 begin
396 ErrMsg := TX_BAD_STOP;
397// InfoBox(TX_BAD_STOP, 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
398 InfoBox(TX_BAD_STOP, DKLangConstW('fOptionsReportsDefault_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
399 odcDfStop.Visible := True;
400 odcDfStop.Text := eDate;
401 odcDfStop.Setfocus;
402 odcDfStop.SelectAll;
403 exit;
404 end;
405 datestart := odcDfStart.RelativeTime;
406 datestop := odcDfStop.RelativeTime;
407 delete(datestart,1,1);
408 delete(datestop,1,1);
409 if StrToIntDef(datestop,0) < StrToIntDef(datestart,0) then
410 begin
411// InfoBox(TX_BAD_ORDER, 'Warning', MB_OK or MB_ICONWARNING); <-- original line. //kt 8/8/2007
412 InfoBox(TX_BAD_ORDER, DKLangConstW('fOptionsReportsDefault_Warning'), MB_OK or MB_ICONWARNING); //kt added 8/8/2007
413 odcDfStop.Text := odcDfStart.Text;
414 odcDfStop.SetFocus;
415 odcDfStop.SelectAll;
416 exit;
417 end;
418 odcDfStop.Text := DateToStr(FMDateTimeToDateTime(odcDfStop.FMDateTime));
419 fillLabelText;
420end;
421
422
423procedure TfrmOptionsReportsDefault.odcDfStartKeyPress(Sender: TObject;
424 var Key: Char);
425begin
426 if Key = #13 then
427 begin
428 Perform(WM_NextDlgCtl, 0, 0);
429 exit;
430 end;
431 if Key = #27 then //Escape
432 begin
433 Key := #0;
434 btnCancel.Click;
435 end;
436end;
437
438procedure TfrmOptionsReportsDefault.odcDfStopKeyPress(Sender: TObject;
439 var Key: Char);
440begin
441 if Key = #13 then
442 begin
443 Perform(WM_NextDlgCtl, 0, 0);
444 exit;
445 end;
446 if Key = #27 then //Escape
447 begin
448 Key := #0;
449 btnCancel.Click;
450 end;
451end;
452
453procedure TfrmOptionsReportsDefault.odcDfStartClick(Sender: TObject);
454begin
455 odcDfStart.SelectAll;
456end;
457
458procedure TfrmOptionsReportsDefault.odcDfStopClick(Sender: TObject);
459begin
460 odcDfStop.SelectAll;
461end;
462
463procedure TfrmOptionsReportsDefault.edtDefaultMaxClick(Sender: TObject);
464begin
465 edtDefaultMax.SelectAll;
466end;
467
468end.
Note: See TracBrowser for help on using the repository browser.