[456] | 1 | unit fActivateDeactivate;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
| 5 | uses
|
---|
| 6 | Windows, Messages, SysUtils, StrUtils, Variants, Classes, Graphics, Controls, Forms,
|
---|
| 7 | Dialogs, fAutoSz, StdCtrls, ExtCtrls, ORCtrls,ORFn, rCore, uCore, oRNet, Math, fOrders, ORClasses, rOrders,
|
---|
[830] | 8 | fMeds, rMeds, VA508AccessibilityManager;
|
---|
[456] | 9 |
|
---|
| 10 | type
|
---|
| 11 | TfrmActivateDeactive = class(TfrmAutoSz)
|
---|
| 12 | TActivate: TButton;
|
---|
| 13 | TDeactive: TButton;
|
---|
| 14 | Memo1: TMemo;
|
---|
| 15 | TCancel: TButton;
|
---|
| 16 | procedure TActivateClick(Sender: TObject);
|
---|
| 17 | procedure TDeactiveClick(Sender: TObject);
|
---|
| 18 | procedure TCancelClick(Sender: TObject);
|
---|
| 19 | private
|
---|
| 20 | { Private declarations }
|
---|
| 21 | procedure GetOriginalOrders(OrderID: TStringList; var OriginalOrder: TORStringList);
|
---|
[830] | 22 | procedure DCOriginalOrder(OrderID: string);
|
---|
[456] | 23 | procedure BuildForm(Str1: String);
|
---|
| 24 | function PromptForm(Text: String): String;
|
---|
| 25 | public
|
---|
| 26 | { Public declarations }
|
---|
| 27 |
|
---|
| 28 | procedure fActivateDeactive(OrderID: TStringList); overload;
|
---|
| 29 | procedure fActivateDeactive(OrderID: TStringList; AList: TListBox); overload;
|
---|
| 30 | end;
|
---|
| 31 |
|
---|
| 32 | var
|
---|
| 33 | frmActivateDeactive: TfrmActivateDeactive;
|
---|
| 34 | Act: Boolean;
|
---|
| 35 | Deact: Boolean;
|
---|
| 36 | CancelProcess: Boolean;
|
---|
| 37 |
|
---|
| 38 | implementation
|
---|
| 39 |
|
---|
| 40 | {$R *.dfm}
|
---|
| 41 |
|
---|
| 42 | { TfrmActivateDeactive }
|
---|
| 43 |
|
---|
| 44 | procedure TfrmActivateDeactive.BuildForm(Str1: String);
|
---|
| 45 | var
|
---|
| 46 | str: string;
|
---|
| 47 | begin
|
---|
| 48 | with frmActivateDeactive do
|
---|
| 49 | begin
|
---|
[830] | 50 | str := 'This order is in a pending status. If this pending order is discontinued, the original order will still be active.';
|
---|
| 51 | str := str + CRLF + CRLF + str1;
|
---|
[456] | 52 | str := str + CRLF + CRLF + 'Click:';
|
---|
[830] | 53 | str := str + CRLF + ' "DC BOTH" to discontinue both orders ';
|
---|
| 54 | str := str + CRLF + ' "DC Pending Order" to discontinue only the pending order and return the original order back to an active status ';
|
---|
| 55 | str := str + CRLF + ' "Cancel - No Action Taken" to stop the discontinue process ';
|
---|
[456] | 56 | Memo1.ReadOnly := False;
|
---|
| 57 | Memo1.Text := str;
|
---|
| 58 | Memo1.ReadOnly := True;
|
---|
| 59 | end;
|
---|
| 60 | ResizeAnchoredFormToFont(frmActivateDeactive);
|
---|
| 61 | frmActivateDeactive.ShowModal;
|
---|
| 62 | frmActivateDeactive.Release;
|
---|
| 63 | end;
|
---|
| 64 |
|
---|
| 65 | procedure TfrmActivateDeactive.fActivateDeactive(OrderID: TStringList);
|
---|
| 66 | var
|
---|
[830] | 67 | i,Pos: integer;
|
---|
[456] | 68 | tmpArr: TORStringList;
|
---|
| 69 | ActDeact: string;
|
---|
[830] | 70 | AnOrder: TOrder;
|
---|
[456] | 71 | begin
|
---|
| 72 | //called from order tab
|
---|
| 73 | tmpArr := TORStringList.Create;
|
---|
| 74 | GetOriginalOrders(OrderID,tmpArr);
|
---|
| 75 | with forders.frmOrders.lstOrders do for i := 0 to items.Count-1 do if Selected[i] then
|
---|
| 76 | begin
|
---|
| 77 | AnOrder := TOrder(Items.Objects[i]);
|
---|
| 78 | Pos := tmpArr.IndexOfPiece(AnOrder.ID,U,1);
|
---|
| 79 | if Pos > -1 then
|
---|
| 80 | begin
|
---|
| 81 | ActDeact := PromptForm(AnOrder.Text);
|
---|
[830] | 82 | if ActDeact = 'D' then AnOrder.DCOriginalOrder := True;
|
---|
| 83 | if ActDeact = 'A' then AnOrder.DCOriginalOrder := False;
|
---|
[456] | 84 | if ActDeact = 'C' then Selected[i] := False;
|
---|
| 85 | end;
|
---|
| 86 | end;
|
---|
| 87 | end;
|
---|
| 88 |
|
---|
| 89 | procedure TfrmActivateDeactive.fActivateDeactive(OrderID: TStringList; AList: TListBox);
|
---|
| 90 | var
|
---|
[830] | 91 | i,Pos: integer;
|
---|
[456] | 92 | tmpArr: TORStringList;
|
---|
| 93 | ActDeact: String;
|
---|
[830] | 94 | AMed: TMedListRec;
|
---|
| 95 | AnOrder: TOrder;
|
---|
[456] | 96 | begin
|
---|
| 97 | //called from Med tab
|
---|
| 98 | tmpArr := TORStringList.Create;
|
---|
| 99 | GetOriginalOrders(OrderID,tmpArr);
|
---|
[830] | 100 | AnOrder := TOrder.Create;
|
---|
| 101 | with AList do for i := 0 to items.Count-1 do if Selected[i] then
|
---|
[456] | 102 | begin
|
---|
| 103 | AMed := TMedListRec(Items.Objects[i]);
|
---|
[830] | 104 | if AMed = nil then Continue;
|
---|
[456] | 105 | Pos := tmpArr.IndexOfPiece(AMed.OrderID,U,1);
|
---|
| 106 | if Pos > -1 then
|
---|
| 107 | begin
|
---|
| 108 | ActDeact := PromptForm(Alist.Items.Strings[i]);
|
---|
| 109 | if ActDeact = 'D' then
|
---|
| 110 | begin
|
---|
[830] | 111 | AnOrder := GetOrderByIFN(Piece(tmpArr.Strings[Pos],U,1));
|
---|
| 112 | DCOriginalOrder(AnOrder.ID);
|
---|
| 113 | //AnOrder.DCOriginalOrder := True;
|
---|
[456] | 114 | end;
|
---|
[830] | 115 | if ActDeact = 'A' then AnOrder.DCOriginalOrder := False;
|
---|
[456] | 116 | if ActDeact = 'C' then Selected[i] := False;
|
---|
| 117 | end;
|
---|
| 118 | end;
|
---|
| 119 | end;
|
---|
| 120 |
|
---|
| 121 | procedure TfrmActivateDeactive.GetOriginalOrders(OrderID: TStringList; var OriginalOrder: TORStringList);
|
---|
| 122 | var
|
---|
| 123 | i: integer;
|
---|
| 124 | begin
|
---|
| 125 | CallV('ORWDX1 DCREN', [OrderID]);
|
---|
| 126 | for i := 0 to RPCBrokerV.Results.Count-1 do
|
---|
| 127 | OriginalOrder.Add(RPCBrokerV.Results.Strings[i]);
|
---|
| 128 | end;
|
---|
| 129 |
|
---|
| 130 | function TfrmActivateDeactive.PromptForm(Text: String): String;
|
---|
| 131 | begin
|
---|
| 132 | frmActivateDeactive := TfrmActivateDeactive.create(Application);
|
---|
| 133 | BuildForm(Text);
|
---|
| 134 | if Deact = True then Result := 'D';
|
---|
| 135 | if Act = True then Result := 'A';
|
---|
| 136 | if CancelProcess = True then Result := 'C';
|
---|
| 137 | end;
|
---|
| 138 |
|
---|
| 139 | procedure TfrmActivateDeactive.TActivateClick(Sender: TObject);
|
---|
| 140 | begin
|
---|
| 141 | inherited;
|
---|
| 142 | Act := True;
|
---|
| 143 | Deact := False;
|
---|
| 144 | CancelProcess := False;
|
---|
| 145 | frmActivateDeactive.Close;
|
---|
| 146 | end;
|
---|
| 147 |
|
---|
| 148 | procedure TfrmActivateDeactive.TDeactiveClick(Sender: TObject);
|
---|
| 149 | begin
|
---|
| 150 | inherited;
|
---|
| 151 | Act := False;
|
---|
| 152 | Deact := True;
|
---|
| 153 | CancelProcess := False;
|
---|
| 154 | frmActivateDeactive.Close;
|
---|
| 155 | end;
|
---|
| 156 |
|
---|
| 157 | procedure TfrmActivateDeactive.TCancelClick(Sender: TObject);
|
---|
| 158 | begin
|
---|
| 159 | inherited;
|
---|
| 160 | Act := False;
|
---|
| 161 | Deact := False;
|
---|
| 162 | CancelProcess := True;
|
---|
| 163 | frmActivateDeactive.Close;
|
---|
| 164 | end;
|
---|
| 165 |
|
---|
[830] | 166 | procedure TfrmActivateDeactive.DCOriginalOrder(OrderID: string);
|
---|
| 167 | begin
|
---|
| 168 | CallV('ORWDX1 DCORIG', [OrderID]);
|
---|
| 169 | end;
|
---|
| 170 |
|
---|
[456] | 171 | end.
|
---|