source: cprs/branches/foia-cprs/CPRS-Chart/Orders/fOrdersPrint.pas@ 638

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

Adding foia-cprs branch

File size: 10.9 KB
RevLine 
[459]1unit fOrdersPrint;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls, ORCtrls, ORfn, ExtCtrls, rOrders, fFrame;
8
9type
10 TfrmOrdersPrint = class(TForm)
11 ckChartCopy: TCheckBox;
12 ckLabels: TCheckBox;
13 ckRequisitions: TCheckBox;
14 ckWorkCopy: TCheckBox;
15 lstChartDevice: TORListBox;
16 lstLabelDevice: TORListBox;
17 lstReqDevice: TORListBox;
18 lstWorkDevice: TORListBox;
19 cmdChart: TORAlignButton;
20 cmdLabels: TORAlignButton;
21 cmdReqs: TORAlignButton;
22 cmdWork: TORAlignButton;
23 cmdOK: TORAlignButton;
24 cmdCancel: TORAlignButton;
25 pnlBase: TORAutoPanel;
26 lblDevice: TLabel;
27 lblPartOne: TMemo;
28 lblPart2: TMemo;
29 procedure SetupControls(PrintParams: TPrintParams);
30 procedure cmdChartClick(Sender: TObject);
31 procedure cmdLabelsClick(Sender: TObject);
32 procedure cmdReqsClick(Sender: TObject);
33 procedure cmdWorkClick(Sender: TObject);
34 procedure cmdOKClick(Sender: TObject);
35 procedure cmdCancelClick(Sender: TObject);
36 procedure ckChartCopyClick(Sender: TObject);
37 procedure ckLabelsClick(Sender: TObject);
38 procedure ckRequisitionsClick(Sender: TObject);
39 procedure ckWorkCopyClick(Sender: TObject);
40 procedure DeviceListClick(Sender: TObject);
41 procedure FormKeyUp(Sender: TObject; var Key: Word;
42 Shift: TShiftState);
43 private
44 FPrintIt: boolean;
45 FSelectAll: boolean;
46 FDevices: string;
47 FNature: char;
48 procedure SetupPrompting(CheckBox: TCheckBox; DeviceList: TORListBox; ChangeButton: TORAlignButton;
49 PromptParam: char; DeviceParam: string);
50 end;
51
52var
53 frmOrdersPrint: TfrmOrdersPrint;
54 PrintParams: TPrintParams;
55 AnyPrompts: boolean;
56 ResultList: TStringList;
57
58const
59 NO_WIN_PRINT = False;
60
61procedure SetupOrdersPrint(OrderList: TStringList; var DeviceInfo: string; Nature: Char; SelectAll: Boolean; var PrintIt: Boolean);
62
63implementation
64
65{$R *.DFM}
66
67uses
68 fDeviceSelect, uCore, ORNet, fOrders;
69
70procedure SetupOrdersPrint(OrderList: TStringList; var DeviceInfo: string; Nature: Char; SelectAll: Boolean; var PrintIt: Boolean);
71{displays device and copy selection form for printing orders, and returns a record of the selections}
72var
73 frmOrdersPrint: TfrmOrdersPrint;
74begin
75 frmOrdersPrint := TfrmOrdersPrint.Create(Application);
76 try
77 frmFrame.CCOWBusy := True;
78 ResizeFormToFont(TForm(frmOrdersPrint));
79 with frmOrdersPrint do
80 begin
81 FSelectAll := SelectAll;
82 FPrintIt := False;
83 FNature := Nature;
84 if Nature = #0 then
85 begin
86 cmdCancel.Caption := 'Cancel Print';
87 lblPart2.Text := 'Greyed out items are not available.';
88 end;
89 OrderPrintDeviceInfo(OrderList, PrintParams, Nature);
90 SetupControls(PrintParams);
91 if (PrintParams.AnyPrompts) {or FSelectAll} then ShowModal;
92 DeviceInfo := FDevices;
93 PrintIt := FPrintIt;
94 end;
95 finally
96 frmFrame.CCOWBusy := False;
97 frmOrdersPrint.Release;
98 end;
99end;
100
101procedure TfrmOrdersPrint.SetupControls(PrintParams: TPrintParams);
102begin
103 with PrintParams do
104 begin
105 SetupPrompting(ckChartCopy , lstChartDevice, cmdChart , PromptForChartCopy , ChartCopyDevice);
106 SetupPrompting(ckLabels , lstLabelDevice, cmdLabels, PromptForLabels , LabelDevice);
107 SetupPrompting(ckRequisitions, lstReqDevice, cmdReqs , PromptForRequisitions, RequisitionDevice);
108 SetupPrompting(ckWorkCopy , lstWorkDevice, cmdWork , PromptForWorkCopy , WorkCopyDevice);
109 FDevices := lstChartDevice.ItemID + U +
110 lstLabelDevice.ItemID + U +
111 lstReqDevice.ItemID + U +
112 lstWorkDevice.ItemID;
113 FPrintIt := not (FDevices = '^^^');
114 end;
115end;
116
117procedure TfrmOrdersPrint.SetupPrompting(CheckBox: TCheckBox; DeviceList: TORListBox; ChangeButton: TORAlignButton;
118 PromptParam: char; DeviceParam: string);
119{ 0 - no prompts - copy is automatically generated.
120 checkbox checked and disabled, device defaulted and button disabled
121 1 - prompt for copy and ask which printer should be used.
122 checkbox unchecked and enabled, device defaulted and button enabled
123 2 - prompt for copy and automatically print to the
124 printer defined in the XXXXX COPY PRINT DEVICE field.
125 checkbox unchecked and enabled, device defaulted and button disabled
126 * - don't print.
127 checkbox unchecked and disabled, device empty and button disabled
128}
129begin
130 case PromptParam of
131 '0', #0: begin
132 CheckBox.Checked := DeviceParam <> '';
133 CheckBox.Enabled := False;
134 DeviceList.Clear;
135 if DeviceParam <> '' then
136 begin
137 DeviceList.Items.Add(DeviceParam);
138 DeviceList.Font.Color := clGrayText;
139 DeviceList.ItemIndex := 0;
140 CheckBox.Font.Style := CheckBox.Font.Style + [fsBold];
141 CheckBox.Font.Color := clInfoText;
142 CheckBox.Color := clInfoBk;
143 end
144 else
145 begin
146 CheckBox.State := cbUnchecked;
147 CheckBox.Enabled := False;
148 end;
149 ChangeButton.Enabled := False;
150 end;
151 '1': begin
152 CheckBox.State := cbUnchecked;
153 CheckBox.Enabled := True;
154 DeviceList.Clear;
155 if DeviceParam <> '' then DeviceList.Items.Add(DeviceParam);
156 ChangeButton.Enabled := False;
157 end;
158 '2': begin
159 CheckBox.State := cbUnchecked;
160 CheckBox.Enabled := True;
161 DeviceList.Clear;
162 if DeviceParam <> '' then
163 DeviceList.Items.Add(DeviceParam)
164 else
165 begin
166 CheckBox.State := cbUnchecked;
167 CheckBox.Enabled := False;
168 end;
169 ChangeButton.Enabled := False;
170 end;
171 '*': begin
172 CheckBox.State := cbUnchecked;
173 CheckBox.Enabled := False;
174 DeviceList.Clear;
175 ChangeButton.Enabled := False;
176 end;
177 end;
178end;
179
180procedure TfrmOrdersPrint.cmdChartClick(Sender: TObject);
181var
182 x: string;
183begin
184 x := SelectDevice(Self, Encounter.Location, NO_WIN_PRINT,'');
185 if x <> '' then with lstChartDevice do
186 begin
187 Clear;
188 Items.Add(x);
189 end;
190end;
191
192procedure TfrmOrdersPrint.cmdLabelsClick(Sender: TObject);
193var
194 x: string;
195begin
196 x := SelectDevice(Self, Encounter.Location, NO_WIN_PRINT,'');
197 if x <> '' then with lstLabelDevice do
198 begin
199 Clear;
200 Items.Add(x);
201 end;
202end;
203
204procedure TfrmOrdersPrint.cmdReqsClick(Sender: TObject);
205var
206 x: string;
207begin
208 x := SelectDevice(Self, Encounter.Location, NO_WIN_PRINT,'');
209 if x <> '' then with lstReqDevice do
210 begin
211 Clear;
212 Items.Add(x);
213 end;
214end;
215
216procedure TfrmOrdersPrint.cmdWorkClick(Sender: TObject);
217var
218 x: string;
219begin
220 x := SelectDevice(Self, Encounter.Location, NO_WIN_PRINT,'');
221 if x <> '' then with lstWorkDevice do
222 begin
223 Clear;
224 Items.Add(x);
225 end;
226end;
227
228procedure TfrmOrdersPrint.cmdOKClick(Sender: TObject);
229const
230 TX_NO_SELECTION = 'No copies were selected for printing. Check a copy type, or Cancel.';
231 TX_NO_SELECTION_CAP = 'Nothing Selected!';
232begin
233 if not ckChartCopy.Checked then lstChartDevice.ItemIndex := -1 else lstChartDevice.ItemIndex := 0;
234 if not ckLabels.Checked then lstLabelDevice.ItemIndex := -1 else lstLabelDevice.ItemIndex := 0;
235 if not ckRequisitions.Checked then lstReqDevice.ItemIndex := -1 else lstReqDevice.ItemIndex := 0;
236 if not ckWorkCopy.Checked then lstWorkDevice.ItemIndex := -1 else lstWorkDevice.ItemIndex := 0;
237 FDevices := Piece(lstChartDevice.ItemID, ';', 1) + U +
238 Piece(lstLabelDevice.ItemID, ';', 1) + U +
239 Piece(lstReqDevice.ItemID, ';', 1) + U +
240 Piece(lstWorkDevice.ItemID, ';', 1);
241 if FDevices = '^^^' then
242 begin
243 FPrintIt := False;
244 InfoBox(TX_NO_SELECTION, TX_NO_SELECTION_CAP, MB_OK)
245 end
246 else
247 begin
248 FPrintIt := True;
249 Close;
250 end;
251end;
252
253procedure TfrmOrdersPrint.cmdCancelClick(Sender: TObject);
254// Force autoprint of 'don't prompt' items, regardless of continue/cancel selection.
255begin
256 if FNature = #0 then FDevices := '^^^'
257 else with PrintParams do
258 begin
259 if (PromptForChartCopy = '0') or (PromptForChartCopy = #0) then
260 begin
261 if not ckChartCopy.Checked then lstChartDevice.ItemIndex := -1
262 else lstChartDevice.ItemIndex := 0;
263 end
264 else lstChartDevice.ItemIndex := -1;
265
266 if (PromptForLabels = '0') or (PromptForLabels = #0) then
267 begin
268 if not ckLabels.Checked then lstLabelDevice.ItemIndex := -1
269 else lstLabelDevice.ItemIndex := 0;
270 end
271 else lstLabelDevice.ItemIndex := -1;
272
273 if (PromptForRequisitions = '0') or (PromptForRequisitions = #0) then
274 begin
275 if not ckRequisitions.Checked then lstReqDevice.ItemIndex := -1
276 else lstReqDevice.ItemIndex := 0;
277 end
278 else lstReqDevice.ItemIndex := -1;
279
280 if (PromptForWorkCopy = '0') or (PromptForWorkCopy = #0) then
281 begin
282 if not ckWorkCopy.Checked then lstWorkDevice.ItemIndex := -1
283 else lstWorkDevice.ItemIndex := 0;
284 end
285 else lstWorkDevice.ItemIndex := -1;
286
287 FDevices := Piece(lstChartDevice.ItemID, ';', 1) + U +
288 Piece(lstLabelDevice.ItemID, ';', 1) + U +
289 Piece(lstReqDevice.ItemID, ';', 1) + U +
290 Piece(lstWorkDevice.ItemID, ';', 1);
291 end;
292
293 FPrintIt := (FDevices <> '^^^');
294 Close;
295end;
296
297procedure TfrmOrdersPrint.ckChartCopyClick(Sender: TObject);
298begin
299 cmdChart.Enabled := (ckChartCopy.Checked) and (PrintParams.PromptForChartCopy <> '2');
300end;
301
302procedure TfrmOrdersPrint.ckLabelsClick(Sender: TObject);
303begin
304 cmdLabels.Enabled := (ckLabels.Checked) and (PrintParams.PromptForLabels <> '2');
305end;
306
307procedure TfrmOrdersPrint.ckRequisitionsClick(Sender: TObject);
308begin
309 cmdReqs.Enabled := (ckRequisitions.Checked) and (PrintParams.PromptForRequisitions <> '2');
310end;
311
312procedure TfrmOrdersPrint.ckWorkCopyClick(Sender: TObject);
313begin
314 cmdWork.Enabled := (ckWorkCopy.Checked) and (PrintParams.PromptForWorkCopy <> '2');
315end;
316
317procedure TfrmOrdersPrint.DeviceListClick(Sender: TObject);
318begin
319 TORListBox(Sender).ItemIndex := -1;
320end;
321
322procedure TfrmOrdersPrint.FormKeyUp(Sender: TObject; var Key: Word;
323 Shift: TShiftState);
324begin
325 if Key = VK_ESCAPE then
326 begin
327 Key := 0;
328 Close;
329 end;
330end;
331
332end.
333
Note: See TracBrowser for help on using the repository browser.