Ignore:
Timestamp:
Jul 7, 2010, 4:31:10 PM (14 years ago)
Author:
Kevin Toppenberg
Message:

Upgrade to version 27

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cprs/trunk/CPRS-Chart/Orders/uODBase.pas

    r456 r829  
    2323procedure PushKeyVars(const NewVals: string);
    2424procedure ExpandOrderObjects(var Txt: string; var ContainsObjects: boolean; msg: string = '');
     25procedure CheckForAutoDCDietOrders(EvtID: integer; DispGrp: integer; CurrentText: string;
     26            var CancelText: string; Sender: TObject);
    2527
    2628implementation
    2729
    2830uses
    29   dShared, Windows, rTemplates;
     31  dShared, Windows, rTemplates, SysUtils, StdCtrls, fOrders, rOrders;
    3032
    3133var
     
    190192end;
    191193
     194// Check for diet orders that will be auto-DCd on release because of start/stop overlaps.
     195// Moved here for visibility because it also needs to be checked on an auto-accept order.
     196procedure CheckForAutoDCDietOrders(EvtID: integer; DispGrp: integer; CurrentText: string;
     197            var CancelText: string; Sender: TObject);
     198const
     199  TX_CX_CUR = 'A new diet order will CANCEL and REPLACE this current diet now unless' + CRLF +
     200              'you specify a start date for when the new diet should replace the current' + CRLF +
     201              'diet:' + CRLF + CRLF;
     202  TX_CX_FUT = 'A new diet order with no expiration date will CANCEL and REPLACE these diets:' + CRLF + CRLF;
     203  TX_CX_DELAYED1 =  'There are other delayed diet orders for this release event:';
     204  TX_CX_DELAYED2 =  'This new diet order may cancel and replace those other diets' + CRLF +
     205                    'IMMEDIATELY ON RELEASE, unless you either:' + CRLF + CRLF +
     206
     207                    '1. Specify an expiration date/time for this order that will' + CRLF +
     208                    '   be prior to the start date/time of those other orders; or' + CRLF + CRLF +
     209
     210                    '2. Specify a later start date/time for this order for when you' + CRLF +
     211                    '   would like it to cancel and replace those other orders.';
     212
     213var
     214  i: integer;
     215  AStringList: TStringList;
     216  AList: TList;
     217  x, PtEvtIFN, PtEvtName: string;
     218  //AResponse: TResponse;
     219begin
     220  if EvtID = 0 then   // check current and future released diets
     221  begin
     222    x := CurrentText;
     223    if Piece(x, #13, 1) <> 'Current Diet:  ' then
     224    begin
     225      AStringList := TStringList.Create;
     226      try
     227        AStringList.Text := x;
     228        CancelText := TX_CX_CUR + #9 + Piece(AStringList[0], ':', 1) + ':' + CRLF + CRLF
     229                 + #9 + Copy(AStringList[0], 16, 99) + CRLF;
     230        if AStringList.Count > 1 then
     231        begin
     232          CancelText := CancelText + CRLF + CRLF +
     233                   TX_CX_FUT + #9 + Piece(AStringList[1], ':', 1) + ':' + CRLF + CRLF
     234                   + #9 + Copy(AStringList[1], 22, 99) + CRLF;
     235          if AStringList.Count > 2 then
     236          for i := 2 to AStringList.Count - 1 do
     237            CancelText := CancelText + #9 + TrimLeft(AStringList[i]) + CRLF;
     238        end;
     239      finally
     240        AStringList.Free;
     241      end;
     242    end;
     243  end
     244  else if Sender is TButton then     // delayed orders code here - on accept only
     245  begin
     246    //AResponse := Responses.FindResponseByName('STOP', 1);
     247    //if (AResponse <> nil) and (AResponse.EValue <> '') then exit;
     248    AList := TList.Create;
     249    try
     250      PtEvtIFN := IntToStr(frmOrders.TheCurrentView.EventDelay.PtEventIFN);
     251      PtEvtName := frmOrders.TheCurrentView.EventDelay.EventName;
     252      LoadOrdersAbbr(AList, frmOrders.TheCurrentView, PtEvtIFN);
     253      for i := AList.Count - 1 downto 0 do
     254      begin
     255        if TOrder(Alist.Items[i]).DGroup <> DispGrp then
     256        begin
     257          TOrder(AList.Items[i]).Free;
     258          AList.Delete(i);
     259        end;
     260      end;
     261      if AList.Count > 0 then
     262      begin
     263        x := '';
     264        RetrieveOrderFields(AList, 0, 0);
     265        CancelText := TX_CX_DELAYED1 + CRLF + CRLF + 'Release event: ' + PtEvtName;
     266        for i := 0 to AList.Count - 1 do
     267          with TOrder(AList.Items[i]) do
     268          begin
     269            x := x + #9 + Text + CRLF;
     270(*            if StartTime <> '' then
     271              x := #9 + x + 'Start:   ' + StartTime + CRLF
     272            else
     273              x := #9 + x + 'Ordered: ' + FormatFMDateTime('mmm dd,yyyy@hh:nn', OrderTime) + CRLF;*)
     274          end;
     275        CancelText := CancelText + CRLF + CRLF + x;
     276        CancelText := CancelText + CRLF + CRLF + TX_CX_DELAYED2;
     277      end;
     278    finally
     279      with AList do for i := 0 to Count - 1 do TOrder(Items[i]).Free;
     280      AList.Free;
     281    end;
     282  end;
     283end;
     284
     285
    192286initialization
    193287  uOrderEventType := #0;
Note: See TracChangeset for help on using the changeset viewer.