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