source: cprs/trunk/CPRS-Chart/Orders/fOrdersVerify.pas@ 1698

Last change on this file since 1698 was 829, checked in by Kevin Toppenberg, 14 years ago

Upgrade to version 27

File size: 4.4 KB
Line 
1unit fOrdersVerify;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 fAutoSz, StdCtrls, ORFn, ORCtrls, ExtCtrls, VA508AccessibilityManager;
8
9type
10 TfrmVerifyOrders = class(TfrmAutoSz)
11 Panel1: TPanel;
12 lblVerify: TLabel;
13 lstOrders: TCaptionListBox;
14 Panel2: TPanel;
15 lblESCode: TLabel;
16 txtESCode: TCaptionEdit;
17 cmdOK: TButton;
18 cmdCancel: TButton;
19 procedure FormCreate(Sender: TObject);
20 procedure cmdOKClick(Sender: TObject);
21 procedure cmdCancelClick(Sender: TObject);
22 procedure lstOrdersMeasureItem(Control: TWinControl; Index: Integer;
23 var AHeight: Integer);
24 procedure lstOrdersDrawItem(Control: TWinControl; Index: Integer;
25 Rect: TRect; State: TOwnerDrawState);
26 procedure Panel1Resize(Sender: TObject);
27 private
28 OKPressed: Boolean;
29 ESCode: string;
30 end;
31
32function ExecuteVerifyOrders(SelectedList: TList; ChartReview: Boolean): Boolean;
33
34implementation
35
36{$R *.DFM}
37
38uses Hash, rCore, rOrders;
39
40const
41 TX_CHART_REVIEW = 'The following orders will be marked as reviewed -';
42
43function ExecuteVerifyOrders(SelectedList: TList; ChartReview: Boolean): Boolean;
44var
45 frmVerifyOrders: TfrmVerifyOrders;
46 i: Integer;
47begin
48 Result := False;
49 if SelectedList.Count = 0 then Exit;
50 frmVerifyOrders := TfrmVerifyOrders.Create(Application);
51 try
52 ResizeFormToFont(TForm(frmVerifyOrders));
53 if ChartReview then
54 begin
55 frmVerifyOrders.lblVerify.Caption := TX_CHART_REVIEW;
56 frmVerifyOrders.Caption := 'Chart Review';
57 end;
58 with SelectedList do for i := 0 to Count - 1 do
59 frmVerifyOrders.lstOrders.Items.Add(TOrder(Items[i]).Text);
60 frmVerifyOrders.ShowModal;
61 if frmVerifyOrders.OKPressed then
62 begin
63 with SelectedList do for i := 0 to Count - 1 do
64 begin
65 if ChartReview
66 then VerifyOrderChartReview(TOrder(Items[i]), frmVerifyOrders.ESCode)
67 else VerifyOrder(TOrder(Items[i]), frmVerifyOrders.ESCode);
68 end;
69 Result := True;
70 end;
71 finally
72 frmVerifyOrders.Release;
73 with SelectedList do for i := 0 to Count - 1 do UnlockOrder(TOrder(Items[i]).ID);
74 end;
75end;
76
77procedure TfrmVerifyOrders.FormCreate(Sender: TObject);
78begin
79 inherited;
80 OKPressed := False;
81end;
82
83procedure TfrmVerifyOrders.cmdOKClick(Sender: TObject);
84const
85 TX_NO_CODE = 'An electronic signature code must be entered to verify orders.';
86 TC_NO_CODE = 'Electronic Signature Code Required';
87 TX_BAD_CODE = 'The electronic signature code entered is not valid.';
88 TC_BAD_CODE = 'Invalid Electronic Signature Code';
89begin
90 inherited;
91 if Length(txtESCode.Text) = 0 then
92 begin
93 InfoBox(TX_NO_CODE, TC_NO_CODE, MB_OK);
94 Exit;
95 end;
96 if not ValidESCode(txtESCode.Text) then
97 begin
98 InfoBox(TX_BAD_CODE, TC_BAD_CODE, MB_OK);
99 txtESCode.SetFocus;
100 txtESCode.SelectAll;
101 Exit;
102 end;
103 ESCode := Encrypt(txtESCode.Text);
104 OKPressed := True;
105 Close;
106end;
107
108procedure TfrmVerifyOrders.cmdCancelClick(Sender: TObject);
109begin
110 inherited;
111 Close;
112end;
113
114
115
116procedure TfrmVerifyOrders.lstOrdersMeasureItem(Control: TWinControl;
117 Index: Integer; var AHeight: Integer);
118var
119 x: string;
120 ARect: TRect;
121begin
122 inherited;
123 with lstOrders do if Index < Items.Count then
124 begin
125 ARect := ItemRect(Index);
126 Canvas.FillRect(ARect);
127 x := FilteredString(Items[Index]);
128 AHeight := WrappedTextHeightByFont(Canvas, Font, x, ARect);
129 if AHeight < 13 then AHeight := 15;
130 end;
131end;
132
133procedure TfrmVerifyOrders.lstOrdersDrawItem(Control: TWinControl;
134 Index: Integer; Rect: TRect; State: TOwnerDrawState);
135var
136 x: string;
137 ARect: TRect;
138 SaveColor: TColor;
139begin
140 inherited;
141 with lstOrders do
142 begin
143 ARect := Rect;
144 ARect.Left := ARect.Left + 2;
145 Canvas.FillRect(ARect);
146 Canvas.Pen.Color := Get508CompliantColor(clSilver);
147 SaveColor := Canvas.Brush.Color;
148 Canvas.MoveTo(ARect.Left, ARect.Bottom - 1);
149 Canvas.LineTo(ARect.Right, ARect.Bottom - 1);
150 if Index < Items.Count then
151 begin
152 x := FilteredString(Items[Index]);
153 DrawText(Canvas.Handle, PChar(x), Length(x), ARect, DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
154 Canvas.Brush.Color := SaveColor;
155 ARect.Right := ARect.Right + 4;
156 end;
157 end;
158end;
159
160procedure TfrmVerifyOrders.Panel1Resize(Sender: TObject);
161begin
162 inherited;
163 lstOrders.Invalidate;
164end;
165
166end.
Note: See TracBrowser for help on using the repository browser.