1 | unit fOrdersComplete;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
7 | fAutoSz, StdCtrls, ORFn, ORCtrls;
|
---|
8 |
|
---|
9 | type
|
---|
10 | TfrmCompleteOrders = class(TfrmAutoSz)
|
---|
11 | Label1: TLabel;
|
---|
12 | lstOrders: TCaptionListBox;
|
---|
13 | cmdOK: TButton;
|
---|
14 | cmdCancel: TButton;
|
---|
15 | lblESCode: TLabel;
|
---|
16 | txtESCode: TCaptionEdit;
|
---|
17 | procedure FormCreate(Sender: TObject);
|
---|
18 | procedure cmdOKClick(Sender: TObject);
|
---|
19 | procedure cmdCancelClick(Sender: TObject);
|
---|
20 | private
|
---|
21 | OKPressed: Boolean;
|
---|
22 | ESCode: string;
|
---|
23 | end;
|
---|
24 |
|
---|
25 | function ExecuteCompleteOrders(SelectedList: TList): Boolean;
|
---|
26 |
|
---|
27 | implementation
|
---|
28 |
|
---|
29 | {$R *.DFM}
|
---|
30 |
|
---|
31 | uses Hash, rCore, rOrders;
|
---|
32 |
|
---|
33 | function ExecuteCompleteOrders(SelectedList: TList): Boolean;
|
---|
34 | var
|
---|
35 | frmCompleteOrders: TfrmCompleteOrders;
|
---|
36 | i: Integer;
|
---|
37 | begin
|
---|
38 | Result := False;
|
---|
39 | if SelectedList.Count = 0 then Exit;
|
---|
40 | frmCompleteOrders := TfrmCompleteOrders.Create(Application);
|
---|
41 | try
|
---|
42 | ResizeFormToFont(TForm(frmCompleteOrders));
|
---|
43 | with SelectedList do for i := 0 to Count - 1 do
|
---|
44 | frmCompleteOrders.lstOrders.Items.Add(TOrder(Items[i]).Text);
|
---|
45 | frmCompleteOrders.ShowModal;
|
---|
46 | if frmCompleteOrders.OKPressed then
|
---|
47 | begin
|
---|
48 | with SelectedList do
|
---|
49 | for i := 0 to Count - 1 do CompleteOrder(TOrder(Items[i]), frmCompleteOrders.ESCode);
|
---|
50 | Result := True;
|
---|
51 | end;
|
---|
52 | finally
|
---|
53 | frmCompleteOrders.Release;
|
---|
54 | with SelectedList do for i := 0 to Count - 1 do UnlockOrder(TOrder(Items[i]).ID);
|
---|
55 | end;
|
---|
56 | end;
|
---|
57 |
|
---|
58 | procedure TfrmCompleteOrders.FormCreate(Sender: TObject);
|
---|
59 | begin
|
---|
60 | inherited;
|
---|
61 | OKPressed := False;
|
---|
62 | end;
|
---|
63 |
|
---|
64 | procedure TfrmCompleteOrders.cmdOKClick(Sender: TObject);
|
---|
65 | const
|
---|
66 | TX_NO_CODE = 'An electronic signature code must be entered to complete orders.';
|
---|
67 | TC_NO_CODE = 'Electronic Signature Code Required';
|
---|
68 | TX_BAD_CODE = 'The electronic signature code entered is not valid.';
|
---|
69 | TC_BAD_CODE = 'Invalid Electronic Signature Code';
|
---|
70 | begin
|
---|
71 | inherited;
|
---|
72 | if Length(txtESCode.Text) = 0 then
|
---|
73 | begin
|
---|
74 | InfoBox(TX_NO_CODE, TC_NO_CODE, MB_OK);
|
---|
75 | Exit;
|
---|
76 | end;
|
---|
77 | if not ValidESCode(txtESCode.Text) then
|
---|
78 | begin
|
---|
79 | InfoBox(TX_BAD_CODE, TC_BAD_CODE, MB_OK);
|
---|
80 | txtESCode.SetFocus;
|
---|
81 | txtESCode.SelectAll;
|
---|
82 | Exit;
|
---|
83 | end;
|
---|
84 | ESCode := Encrypt(txtESCode.Text);
|
---|
85 | OKPressed := True;
|
---|
86 | Close;
|
---|
87 | end;
|
---|
88 |
|
---|
89 | procedure TfrmCompleteOrders.cmdCancelClick(Sender: TObject);
|
---|
90 | begin
|
---|
91 | inherited;
|
---|
92 | Close;
|
---|
93 | end;
|
---|
94 |
|
---|
95 | end.
|
---|