source: cprs/branches/tmg-cprs/CPRS-Chart/Orders/fOrdersPrint.pas@ 908

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

Initial upload of TMG-CPRS 1.0.26.69

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