source: cprs/branches/tmg-cprs/CPRS-Chart/fDateRange.pas@ 838

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

Initial upload of TMG-CPRS 1.0.26.69

File size: 4.2 KB
Line 
1//kt -- Modified with SourceScanner on 7/15/2007
2unit fDateRange;
3
4interface
5
6uses
7 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
8 fAutoSz, ORCtrls, StdCtrls, ORFn, ORDtTm, DKLang;
9
10type
11 TfrmDateRange = class(TfrmAutoSz)
12 txtStart: TORDateBox;
13 txtStop: TORDateBox;
14 lblStart: TLabel;
15 lblStop: TLabel;
16 cmdOK: TButton;
17 cmdCancel: TButton;
18 lblInstruct: TOROffsetLabel;
19 DKLanguageController2: TDKLanguageController;
20 procedure cmdOKClick(Sender: TObject);
21 procedure cmdCancelClick(Sender: TObject);
22 procedure FormCreate(Sender: TObject);
23 private
24 //kt Begin Mod (change Consts to Vars) 7/15/2007
25 TX_INVALID_DATE : string; //kt
26 TC_INVALID_DATE : string; //kt
27 //kt End Mod -------------------
28 OKPressed: Boolean;
29 Flags: string;
30 procedure SetupVars; //kt 7-15-07
31 end;
32
33function ExecuteDateRange(var Start, Stop: string; const AFlag, ATitle, Instruct,
34 StartLabel, StopLabel: string): Boolean;
35
36implementation
37
38{$R *.DFM}
39
40uses rCore;
41
42//const
43//TX_INVALID_DATE = 'The date/time entered could not be validated.'; <-- original line. //kt 7/15/2007
44//TC_INVALID_DATE = 'Unable to interpret date/time entry.'; <-- original line. //kt 7/15/2007
45
46procedure TfrmDateRange.SetupVars;
47//kt Added entire function to replace constant declarations 7/15/2007
48begin
49 TX_INVALID_DATE := DKLangConstW('fDateRange_The_datetime_entered_could_not_be_validated');
50 TC_INVALID_DATE := DKLangConstW('fDateRange_Unable_to_interpret_datetime_entry');
51end;
52
53function ExecuteDateRange(var Start, Stop: string; const AFlag, ATitle, Instruct,
54 StartLabel, StopLabel: string): Boolean;
55var
56 frmDateRange: TfrmDateRange;
57begin
58 Result := False;
59 frmDateRange := TfrmDateRange.Create(Application);
60 try
61 ResizeFormToFont(TForm(frmDateRange));
62 with frmDateRange do
63 begin
64 if Flags <> '' then Flags := AFlag;
65 if ATitle <> '' then Caption := ATitle;
66 if Instruct <> '' then lblInstruct.Caption := Instruct;
67 if StartLabel <> '' then lblStart.Caption := StartLabel;
68 if StopLabel <> '' then lblStop.Caption := StopLabel;
69 txtStart.Text := Start;
70 txtStop.Text := Stop;
71 ShowModal;
72 if OKPressed then
73 begin
74 Start := txtStart.Text;
75 Stop := txtStop.Text;
76 Result := True;
77 end;
78 end;
79 finally
80 frmDateRange.Release;
81 end;
82end;
83
84procedure TfrmDateRange.FormCreate(Sender: TObject);
85begin
86 inherited;
87 OKPressed := False;
88end;
89
90procedure TfrmDateRange.cmdOKClick(Sender: TObject);
91//const
92//TX_BAD_START = 'The start date is not valid.'; <-- original line. //kt 7/15/2007
93//TX_BAD_STOP = 'The stop date is not valid.'; <-- original line. //kt 7/15/2007
94//TX_STOPSTART = 'The stop date must be after the start date.'; <-- original line. //kt 7/15/2007
95var
96 x, ErrMsg: string;
97 TX_BAD_START : string;
98 TX_BAD_STOP : string;
99 TX_STOPSTART : string;
100
101begin
102 SetupVars; //kt added 7/15/2007 to replace constants with vars.
103 TX_BAD_START := DKLangConstW('fDateRange_The_start_date_is_not_valid'); //kt added 7/15/2007
104 TX_BAD_STOP := DKLangConstW('fDateRange_The_stop_date_is_not_valid'); //kt added 7/15/2007
105 TX_STOPSTART := DKLangConstW('fDateRange_The_stop_date_must_be_after_the_start_date'); //kt added 7/15/2007
106 inherited;
107 ErrMsg := '';
108 txtStart.Validate(x);
109 if Length(x) > 0 then ErrMsg := ErrMsg + TX_BAD_START + CRLF;
110 with txtStop do
111 begin
112 Validate(x);
113 if Length(x) > 0 then ErrMsg := ErrMsg + TX_BAD_STOP + CRLF;
114 if (Length(Text) > 0) and (FMDateTime <= txtStart.FMDateTime)
115 then ErrMsg := ErrMsg + TX_STOPSTART;
116 end;
117 if Length(ErrMsg) > 0 then
118 begin
119 InfoBox(ErrMsg, TC_INVALID_DATE, MB_OK);
120 Exit;
121 end;
122
123// if ((Length(txtStart.Text) > 0) and (ValidDateTimeStr(txtStart.Text, Flags) < 0))
124// or ((Length(txtStop.Text) > 0) and (ValidDateTimeStr(txtStop.Text, Flags) < 0)) then
125// begin
126// InfoBox(TX_INVALID_DATE, TC_INVALID_DATE, MB_OK);
127// Exit;
128// end;
129
130 OKPressed := True;
131 Close;
132end;
133
134procedure TfrmDateRange.cmdCancelClick(Sender: TObject);
135begin
136 inherited;
137 Close;
138end;
139
140end.
Note: See TracBrowser for help on using the repository browser.