source: cprs/branches/foia-cprs/CPRS-Chart/fTIUView.pas@ 1359

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

Adding foia-cprs branch

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