1 | //kt -- Modified with SourceScanner on 8/8/2007
|
---|
2 | unit fOrdersAlert;
|
---|
3 |
|
---|
4 | interface
|
---|
5 |
|
---|
6 | uses
|
---|
7 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
8 | fAutoSz, StdCtrls, ORFn, ORCtrls, DKLang;
|
---|
9 |
|
---|
10 | type
|
---|
11 | TfrmAlertOrders = class(TfrmAutoSz)
|
---|
12 | Label1: TLabel;
|
---|
13 | lstOrders: TCaptionListBox;
|
---|
14 | cmdOK: TButton;
|
---|
15 | cmdCancel: TButton;
|
---|
16 | lblAlertRecipient: TLabel;
|
---|
17 | cboAlertRecipient: TORComboBox;
|
---|
18 | procedure FormCreate(Sender: TObject);
|
---|
19 | procedure cmdOKClick(Sender: TObject);
|
---|
20 | procedure cmdCancelClick(Sender: TObject);
|
---|
21 | procedure cboAlertRecipientNeedData(Sender: TObject; const StartFrom: String; Direction, InsertAt: Integer);
|
---|
22 | procedure cboOnExit(Sender: TObject);
|
---|
23 |
|
---|
24 | private
|
---|
25 | OKPressed: Boolean;
|
---|
26 | end;
|
---|
27 |
|
---|
28 | function ExecuteAlertOrders(SelectedList: TList): Boolean;
|
---|
29 |
|
---|
30 | implementation
|
---|
31 |
|
---|
32 | {$R *.DFM}
|
---|
33 |
|
---|
34 | uses rOrders, uCore, rCore;
|
---|
35 |
|
---|
36 | var
|
---|
37 | AlertRecip: Int64;
|
---|
38 | Provider: String;
|
---|
39 |
|
---|
40 |
|
---|
41 | function ExecuteAlertOrders(SelectedList: TList): Boolean;
|
---|
42 | var
|
---|
43 | frmAlertOrders: TfrmAlertOrders;
|
---|
44 | i: Integer;
|
---|
45 | AnOrder: TOrder;
|
---|
46 | begin
|
---|
47 | Result := False;
|
---|
48 | if SelectedList.Count = 0 then Exit;
|
---|
49 | with SelectedList do
|
---|
50 | AnOrder := TOrder(Items[0]); //use first order's provider
|
---|
51 | Provider := AnOrder.ProviderName;
|
---|
52 | AlertRecip := AnOrder.Provider;
|
---|
53 | frmAlertOrders := TfrmAlertOrders.Create(Application);
|
---|
54 | try
|
---|
55 | ResizeFormToFont(TForm(frmAlertOrders));
|
---|
56 | //AlertRecip := User.DUZ;
|
---|
57 | with SelectedList do for i := 0 to Count - 1 do
|
---|
58 | frmAlertOrders.lstOrders.Items.Add(TOrder(Items[i]).Text);
|
---|
59 | frmAlertOrders.ShowModal;
|
---|
60 | if frmAlertOrders.OKPressed then
|
---|
61 | begin
|
---|
62 | with SelectedList do for i := 0 to Count - 1 do AlertOrder(TOrder(Items[i]),AlertRecip);
|
---|
63 | Result := True;
|
---|
64 | end;
|
---|
65 | finally
|
---|
66 | frmAlertOrders.Release;
|
---|
67 | with SelectedList do for i := 0 to Count - 1 do UnlockOrder(TOrder(Items[i]).ID);
|
---|
68 | end;
|
---|
69 | end;
|
---|
70 |
|
---|
71 | procedure TfrmAlertOrders.FormCreate(Sender: TObject);
|
---|
72 | begin
|
---|
73 | inherited;
|
---|
74 | OKPressed := False;
|
---|
75 | cboAlertRecipient.InitLongList(Provider);
|
---|
76 | cboAlertRecipient.SelectByIEN(AlertRecip);
|
---|
77 | end;
|
---|
78 |
|
---|
79 | procedure TfrmAlertOrders.cmdOKClick(Sender: TObject);
|
---|
80 | begin
|
---|
81 | inherited;
|
---|
82 | cmdOK.SetFocus; //make sure cbo exit events fire
|
---|
83 | OKPressed := True;
|
---|
84 | Close;
|
---|
85 | end;
|
---|
86 |
|
---|
87 | procedure TfrmAlertOrders.cmdCancelClick(Sender: TObject);
|
---|
88 | begin
|
---|
89 | inherited;
|
---|
90 | Close;
|
---|
91 | end;
|
---|
92 |
|
---|
93 | procedure TfrmAlertOrders.cboAlertRecipientNeedData(Sender: TObject;
|
---|
94 | const StartFrom: String; Direction, InsertAt: Integer);
|
---|
95 | begin
|
---|
96 | cboAlertRecipient.ForDataUse(SubSetOfPersons(StartFrom, Direction));
|
---|
97 | end;
|
---|
98 |
|
---|
99 | procedure TfrmAlertOrders.cboOnExit(Sender: TObject);
|
---|
100 | begin
|
---|
101 | with cboAlertRecipient do
|
---|
102 | if (ItemIndex = -1) or (Text = '') then
|
---|
103 | begin
|
---|
104 | AlertRecip := -1;
|
---|
105 | ItemIndex := -1;
|
---|
106 | Text := '';
|
---|
107 | end
|
---|
108 | else
|
---|
109 | begin
|
---|
110 | AlertRecip := ItemIEN;
|
---|
111 | end;
|
---|
112 | end;
|
---|
113 |
|
---|
114 | end.
|
---|