source: cprs/branches/foia-cprs/CPRS-Chart/Orders/fOrdersAlert.pas@ 1806

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

Adding foia-cprs branch

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