source: cprs/branches/tmg-cprs/CPRS-Chart/fTIUView.pas@ 1806

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

Initial upload of TMG-CPRS 1.0.26.69

File size: 10.3 KB
Line 
1//kt -- Modified with SourceScanner on 8/7/2007
2unit fTIUView;
3
4interface
5
6uses
7 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ORFN,
8 StdCtrls, ExtCtrls, ORCtrls, ComCtrls, ORDtTm, Spin, uTIU;
9
10type
11 TfrmTIUView = class(TForm)
12 pnlBase: TORAutoPanel;
13 lblBeginDate: TLabel;
14 calBeginDate: TORDateBox;
15 lblEndDate: TLabel;
16 calEndDate: TORDateBox;
17 lblStatus: TLabel;
18 lstStatus: TORListBox;
19 lblAuthor: TLabel;
20 cmdOK: TButton;
21 cmdCancel: TButton;
22 cboAuthor: TORComboBox;
23 lblMaxDocs: TLabel;
24 edMaxDocs: TCaptionEdit;
25 lblContains: TLabel;
26 txtKeyword: TCaptionEdit;
27 Bevel1: TBevel;
28 grpListView: TGroupBox;
29 radListSort: TRadioGroup;
30 lblSortBy: TLabel;
31 cboSortBy: TORComboBox;
32 grpTreeView: TGroupBox;
33 lblGroupBy: TOROffsetLabel;
34 cboGroupBy: TORComboBox;
35 radTreeSort: TRadioGroup;
36 Bevel2: TBevel;
37 cmdClear: TButton;
38 ckShowSubject: TCheckBox;
39 grpWhereEitherOf: TGroupBox;
40 ckTitle: TCheckBox;
41 ckSubject: TCheckBox;
42 procedure cmdOKClick(Sender: TObject);
43 procedure cmdCancelClick(Sender: TObject);
44 procedure lstStatusSelect(Sender: TObject);
45 procedure cboAuthorNeedData(Sender: TObject; const StartFrom: String;
46 Direction, InsertAt: Integer);
47 procedure cmdClearClick(Sender: TObject);
48 private
49 FChanged: Boolean;
50 FBeginDate: string;
51 FFMBeginDate: TFMDateTime;
52 FEndDate: string;
53 FFMEndDate: TFMDateTime;
54 FStatus: string;
55 FAuthor: Int64;
56 FMaxDocs: integer;
57 FShowSubject: Boolean;
58 FSortBy: string;
59 FListAscending: Boolean;
60 FGroupBy: string;
61 FTreeAscending: Boolean;
62 FSearchField: string;
63 FKeyWord: string;
64 FFiltered: Boolean;
65 FCurrentContext: TTIUContext;
66 end;
67
68function SelectTIUView(FontSize: Integer; ShowForm: Boolean; CurrentContext: TTIUContext; var TIUContext: TTIUContext): boolean ;
69
70implementation
71
72{$R *.DFM}
73
74uses rCore, uCore, rTIU(*, fNotes, fDCSumm, rDCSumm*)
75 ,DKLang //kt
76 ;
77
78//const
79// TX_DATE_ERR = 'Enter valid beginning and ending dates or press Cancel.'; <-- original line. //kt 8/7/2007
80// TX_DATE_ERR_CAP = 'Error in Date Range'; <-- original line. //kt 8/7/2007
81// TX_AUTH_ERR = 'You must select an author for this retrieval method.'; <-- original line. //kt 8/7/2007
82// TX_AUTH_ERR_CAP = 'No author selected'; <-- original line. //kt 8/7/2007
83
84var
85 TX_DATE_ERR : string; //kt
86 TX_DATE_ERR_CAP : string; //kt
87 TX_AUTH_ERR : string; //kt
88 TX_AUTH_ERR_CAP : string; //kt
89
90
91procedure SetupVars;
92//kt Added entire function to replace constant declarations 8/7/2007
93begin
94 TX_DATE_ERR := DKLangConstW('fTIUView_Enter_valid_beginning_and_ending_dates_or_press_Cancelx');
95 TX_DATE_ERR_CAP := DKLangConstW('fTIUView_Error_in_Date_Range');
96 TX_AUTH_ERR := DKLangConstW('fTIUView_You_must_select_an_author_for_this_retrieval_methodx');
97 TX_AUTH_ERR_CAP := DKLangConstW('fTIUView_No_author_selected');
98end;
99
100function SelectTIUView(FontSize: Integer; ShowForm: Boolean; CurrentContext: TTIUContext; var TIUContext: TTIUContext): boolean ;
101{ displays select form for Notes and returns a record of the selection }
102var
103 frmTIUView: TfrmTIUView;
104 W, H: Integer;
105 CurrentAuthor: Int64;
106 CurrentStatus: string;
107begin
108 frmTIUView := TfrmTIUView.Create(Application);
109 try
110 with frmTIUView do
111 begin
112 Font.Size := FontSize;
113 W := ClientWidth;
114 H := ClientHeight;
115 ResizeToFont(FontSize, W, H);
116 ClientWidth := W; pnlBase.Width := W;
117 ClientHeight := H; pnlBase.Height := H;
118 FChanged := False;
119 FFiltered := False;
120 FCurrentContext := CurrentContext;
121 calBeginDate.Text := CurrentContext.BeginDate;
122 calEndDate.Text := CurrentContext.EndDate;
123 if calEndDate.Text = '' then calEndDate.Text := 'TODAY';
124 CurrentStatus := CurrentContext.Status;
125 with lstStatus do
126 if CurrentStatus <> '' then
127 SelectByID(CurrentStatus)
128 else
129 SelectByID('1');
130 //lstStatusSelect(frmTIUView); moved down - v24.1 (RV)
131 CurrentAuthor := CurrentContext.Author;
132 with cboAuthor do
133 if CurrentAuthor > 0 then
134 begin
135 InitLongList(ExternalName(CurrentAuthor, 200));
136 if Enabled then SelectByIEN(CurrentAuthor);
137 FAuthor := CurrentAuthor;
138 end
139 else
140 begin
141 InitLongList(User.Name);
142 SelectByIEN(User.DUZ);
143 FAuthor := ItemIEN;
144 end;
145 if CurrentContext.MaxDocs > 0 then
146 edMaxDocs.Text := IntToStr(CurrentContext.MaxDocs)
147 else
148 edMaxDocs.Text := '';
149 FMaxDocs := StrToIntDef(edMaxDocs.Text, 0);
150 txtKeyword.Text := CurrentContext.Keyword;
151 if CurrentContext.SearchField <> '' then
152 begin
153 ckTitle.Checked := (CurrentContext.SearchField[1] in ['T','B']) and (CurrentContext.Keyword <> '');
154 ckSubject.Checked := (CurrentContext.SearchField[1] in ['S','B'])and (CurrentContext.Keyword <> '');
155 end;
156 ckShowSubject.Checked := CurrentContext.ShowSubject;
157 //with radTreeSort do if SortNotesAscending then ItemIndex := 1 else ItemIndex := 0;
158 with radTreeSort do if CurrentContext.TreeAscending then ItemIndex := 0 else ItemIndex := 1;
159 with radListSort do if CurrentContext.ListAscending then ItemIndex := 0 else ItemIndex := 1;
160 cboSortBy.SelectByID(CurrentContext.SortBy);
161 cboGroupBy.SelectByID(CurrentContext.GroupBy);
162 lstStatusSelect(frmTIUView); // from above in v24.1, (RV)
163
164 if ShowForm then ShowModal else cmdOKClick(frmTIUView);
165
166 with TIUContext do
167 begin
168 Changed := FChanged;
169 BeginDate := FBeginDate;
170 FMBeginDate := FFMBeginDate;
171 EndDate := FEndDate;
172 FMEndDate := FFMEndDate;
173 Status := FStatus;
174 Author := FAuthor;
175 MaxDocs := FMaxDocs;
176 ShowSubject := FShowSubject;
177 SortBy := FSortBy;
178 ListAscending := FListAscending;
179 GroupBy := FGroupBy;
180 TreeAscending := FTreeAscending;
181 SearchField := FSearchField;
182 KeyWord := FKeyWord;
183 Filtered := FFiltered;
184 Result := Changed ;
185 end;
186
187 end; {with frmTIUView}
188 finally
189 frmTIUView.Release;
190 end;
191end;
192
193procedure TfrmTIUView.cmdOKClick(Sender: TObject);
194var
195 bdate, edate: TFMDateTime;
196begin
197 SetupVars; //kt added 8/7/2007 to replace constants with vars.
198 FStatus := lstStatus.ItemID;
199
200 if calBeginDate.Text <> '' then
201 bdate := StrToFMDateTime(calBeginDate.Text)
202 else
203 bdate := 0 ;
204
205 if calEndDate.Text <> '' then
206 edate := StrToFMDateTime(calEndDate.Text)
207 else
208 edate := 0 ;
209
210 if (bdate <= edate) then
211 begin
212 FBeginDate := calBeginDate.Text;
213 FFMBeginDate := bdate;
214 FEndDate := calEndDate.Text;
215 FFMEndDate := edate;
216 end
217 else
218 begin
219 InfoBox(TX_DATE_ERR, TX_DATE_ERR_CAP, MB_OK or MB_ICONWARNING);
220 Exit;
221 end;
222
223 FAuthor := cboAuthor.ItemIEN;
224 if (FStatus = '4') and (FAuthor = 0) then
225 begin
226 InfoBox(TX_AUTH_ERR, TX_AUTH_ERR_CAP, MB_OK or MB_ICONWARNING);
227 Exit;
228 end;
229
230 FSortBy := cboSortBy.ItemID;
231 if FSortBy = '' then FSortBy := 'R';
232 FListAscending := (radListSort.ItemIndex = 0);
233 FTreeAscending := (radTreeSort.ItemIndex = 0);
234
235 FKeyWord := txtKeyWord.Text;
236 if (ckTitle.Checked) and (ckSubject.Checked) then
237 FSearchField := 'B'
238 else if ckTitle.Checked then
239 FSearchField := 'T'
240 else if ckSubject.Checked then
241 FSearchField := 'S'
242 else if not (ckTitle.Checked or ckSubject.Checked) then
243 begin
244 FKeyWord := '';
245 FSearchField := '';
246 end;
247 if (FKeyword <> '') then
248 FFiltered := True;
249
250 if ckSubject.Checked then ckShowSubject.Checked := True;
251 FShowSubject := ckShowSubject.Checked;
252 FMaxDocs := StrToIntDef(edMaxDocs.Text, 0);
253 if cboGroupBy.ItemID <> '' then
254 FGroupBy := cboGroupBy.ItemID
255 else
256 FGroupBy := '';
257 FChanged := True;
258 Close;
259end;
260
261procedure TfrmTIUView.cmdCancelClick(Sender: TObject);
262begin
263 FChanged := False;
264 Close;
265end;
266
267procedure TfrmTIUView.lstStatusSelect(Sender: TObject);
268var
269 EnableDates: Boolean;
270begin
271 EnableDates := (lstStatus.ItemID <> '1');
272 lblBeginDate.Enabled := EnableDates;
273 calBeginDate.Enabled := EnableDates;
274 lblEndDate.Enabled := EnableDates;
275 calEndDate.Enabled := EnableDates;
276 if not EnableDates then
277 begin
278 calBeginDate.Text := '';
279 calEndDate.Text := '';
280 end
281 else
282 begin
283 calBeginDate.Text := FCurrentContext.BeginDate;
284 calEndDate.Text := FCurrentContext.EndDate;
285 if FCurrentContext.EndDate = '' then calEndDate.FMDateTime := FMToday;
286 end;
287 if lstStatus.ItemID = '3' then
288// lblAuthor.Caption := 'Expected Cosigner:' <-- original line. //kt 8/7/2007
289 lblAuthor.Caption := DKLangConstW('fTIUView_Expected_Cosignerx') //kt added 8/7/2007
290 else
291// lblAuthor.Caption := 'Author:'; <-- original line. //kt 8/7/2007
292 lblAuthor.Caption := DKLangConstW('fTIUView_Authorx'); //kt added 8/7/2007
293 cboAuthor.Caption := lblAuthor.Caption;
294 if (lstStatus.ItemID = '1') or (lstStatus.ItemID = '5') then
295 begin
296 cboAuthor.ItemIndex := -1;
297 cboAuthor.Enabled := False;
298 lblAuthor.Enabled := False;
299 if FMaxDocs > 0 then
300 edMaxDocs.Text := IntToStr(FMaxDocs)
301 else
302 edMaxDocs.Text := '';
303 edMaxDocs.Enabled := True;
304 lblMaxDocs.Enabled := True;
305 end
306 else
307 begin
308 cboAuthor.Enabled := True;
309 cboAuthor.SelectByIEN(FAuthor);
310 lblAuthor.Enabled := True;
311 edMaxDocs.Text := '';
312 edMaxDocs.Enabled := False;
313 lblMaxDocs.Enabled := False;
314 end;
315end;
316
317
318procedure TfrmTIUView.cboAuthorNeedData(Sender: TObject;
319 const StartFrom: string; Direction, InsertAt: Integer);
320begin
321 cboAuthor.ForDataUse(SubSetOfActiveAndInactivePersons(StartFrom, Direction));
322end;
323
324procedure TfrmTIUView.cmdClearClick(Sender: TObject);
325begin
326 cboSortBy.ItemIndex := -1;
327 cboGroupBy.ItemIndex := -1;
328 ckTitle.Checked := False;
329 ckSubject.Checked := False;
330 txtKeyWord.Text := '';
331 radTreeSort.ItemIndex := 1;
332 radListSort.ItemIndex := 1;
333end;
334
335end.
Note: See TracBrowser for help on using the repository browser.