source: cprs/branches/tmg-cprs/CPRS-Chart/Orders/fOrdersAlert.pas@ 1802

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

Initial upload of TMG-CPRS 1.0.26.69

File size: 2.9 KB
RevLine 
[453]1//kt -- Modified with SourceScanner on 8/8/2007
2unit fOrdersAlert;
3
4interface
5
6uses
7 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
8 fAutoSz, StdCtrls, ORFn, ORCtrls, DKLang;
9
10type
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
28function ExecuteAlertOrders(SelectedList: TList): Boolean;
29
30implementation
31
32{$R *.DFM}
33
34uses rOrders, uCore, rCore;
35
36var
37 AlertRecip: Int64;
38 Provider: String;
39
40
41function ExecuteAlertOrders(SelectedList: TList): Boolean;
42var
43 frmAlertOrders: TfrmAlertOrders;
44 i: Integer;
45 AnOrder: TOrder;
46begin
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;
69end;
70
71procedure TfrmAlertOrders.FormCreate(Sender: TObject);
72begin
73 inherited;
74 OKPressed := False;
75 cboAlertRecipient.InitLongList(Provider);
76 cboAlertRecipient.SelectByIEN(AlertRecip);
77end;
78
79procedure TfrmAlertOrders.cmdOKClick(Sender: TObject);
80begin
81 inherited;
82 cmdOK.SetFocus; //make sure cbo exit events fire
83 OKPressed := True;
84 Close;
85end;
86
87procedure TfrmAlertOrders.cmdCancelClick(Sender: TObject);
88begin
89 inherited;
90 Close;
91end;
92
93procedure TfrmAlertOrders.cboAlertRecipientNeedData(Sender: TObject;
94 const StartFrom: String; Direction, InsertAt: Integer);
95begin
96 cboAlertRecipient.ForDataUse(SubSetOfPersons(StartFrom, Direction));
97end;
98
99procedure TfrmAlertOrders.cboOnExit(Sender: TObject);
100begin
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;
112end;
113
114end.
Note: See TracBrowser for help on using the repository browser.