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

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

Initial Upload of Official WV CPRS 1.0.26.76

File size: 4.4 KB
RevLine 
[456]1unit fOrdersVerify;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 fAutoSz, StdCtrls, ORFn, ORCtrls, ExtCtrls;
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 > 255 then AHeight := 255;
130 if AHeight < 13 then AHeight := 15;
131 end;
132end;
133
134procedure TfrmVerifyOrders.lstOrdersDrawItem(Control: TWinControl;
135 Index: Integer; Rect: TRect; State: TOwnerDrawState);
136var
137 x: string;
138 ARect: TRect;
139 SaveColor: TColor;
140begin
141 inherited;
142 with lstOrders do
143 begin
144 ARect := Rect;
145 ARect.Left := ARect.Left + 2;
146 Canvas.FillRect(ARect);
147 Canvas.Pen.Color := clSilver;
148 SaveColor := Canvas.Brush.Color;
149 Canvas.MoveTo(ARect.Left, ARect.Bottom - 1);
150 Canvas.LineTo(ARect.Right, ARect.Bottom - 1);
151 if Index < Items.Count then
152 begin
153 x := FilteredString(Items[Index]);
154 DrawText(Canvas.Handle, PChar(x), Length(x), ARect, DT_LEFT or DT_NOPREFIX or DT_WORDBREAK);
155 Canvas.Brush.Color := SaveColor;
156 ARect.Right := ARect.Right + 4;
157 end;
158 end;
159end;
160
161procedure TfrmVerifyOrders.Panel1Resize(Sender: TObject);
162begin
163 inherited;
164 lstOrders.Invalidate;
165end;
166
167end.
Note: See TracBrowser for help on using the repository browser.