[459] | 1 | unit fOrdersVerify;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
| 5 | uses
|
---|
| 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
| 7 | fAutoSz, StdCtrls, ORFn, ORCtrls, ExtCtrls;
|
---|
| 8 |
|
---|
| 9 | type
|
---|
| 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 |
|
---|
| 32 | function ExecuteVerifyOrders(SelectedList: TList; ChartReview: Boolean): Boolean;
|
---|
| 33 |
|
---|
| 34 | implementation
|
---|
| 35 |
|
---|
| 36 | {$R *.DFM}
|
---|
| 37 |
|
---|
| 38 | uses Hash, rCore, rOrders;
|
---|
| 39 |
|
---|
| 40 | const
|
---|
| 41 | TX_CHART_REVIEW = 'The following orders will be marked as reviewed -';
|
---|
| 42 |
|
---|
| 43 | function ExecuteVerifyOrders(SelectedList: TList; ChartReview: Boolean): Boolean;
|
---|
| 44 | var
|
---|
| 45 | frmVerifyOrders: TfrmVerifyOrders;
|
---|
| 46 | i: Integer;
|
---|
| 47 | begin
|
---|
| 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;
|
---|
| 75 | end;
|
---|
| 76 |
|
---|
| 77 | procedure TfrmVerifyOrders.FormCreate(Sender: TObject);
|
---|
| 78 | begin
|
---|
| 79 | inherited;
|
---|
| 80 | OKPressed := False;
|
---|
| 81 | end;
|
---|
| 82 |
|
---|
| 83 | procedure TfrmVerifyOrders.cmdOKClick(Sender: TObject);
|
---|
| 84 | const
|
---|
| 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';
|
---|
| 89 | begin
|
---|
| 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;
|
---|
| 106 | end;
|
---|
| 107 |
|
---|
| 108 | procedure TfrmVerifyOrders.cmdCancelClick(Sender: TObject);
|
---|
| 109 | begin
|
---|
| 110 | inherited;
|
---|
| 111 | Close;
|
---|
| 112 | end;
|
---|
| 113 |
|
---|
| 114 |
|
---|
| 115 |
|
---|
| 116 | procedure TfrmVerifyOrders.lstOrdersMeasureItem(Control: TWinControl;
|
---|
| 117 | Index: Integer; var AHeight: Integer);
|
---|
| 118 | var
|
---|
| 119 | x: string;
|
---|
| 120 | ARect: TRect;
|
---|
| 121 | begin
|
---|
| 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;
|
---|
| 132 | end;
|
---|
| 133 |
|
---|
| 134 | procedure TfrmVerifyOrders.lstOrdersDrawItem(Control: TWinControl;
|
---|
| 135 | Index: Integer; Rect: TRect; State: TOwnerDrawState);
|
---|
| 136 | var
|
---|
| 137 | x: string;
|
---|
| 138 | ARect: TRect;
|
---|
| 139 | SaveColor: TColor;
|
---|
| 140 | begin
|
---|
| 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;
|
---|
| 159 | end;
|
---|
| 160 |
|
---|
| 161 | procedure TfrmVerifyOrders.Panel1Resize(Sender: TObject);
|
---|
| 162 | begin
|
---|
| 163 | inherited;
|
---|
| 164 | lstOrders.Invalidate;
|
---|
| 165 | end;
|
---|
| 166 |
|
---|
| 167 | end.
|
---|