Index: cprs/trunk/CPRS-Chart/Orders/fOrdersDC.pas
===================================================================
--- cprs/trunk/CPRS-Chart/Orders/fOrdersDC.pas	(revision 456)
+++ cprs/trunk/CPRS-Chart/Orders/fOrdersDC.pas	(revision 829)
@@ -4,9 +4,9 @@
 
 uses
-  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
-  fAutoSz, StdCtrls, ORFn, ORCtrls, ExtCtrls;
+  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, fBase508Form,
+  fAutoSz, StdCtrls, ORFn, ORCtrls, ExtCtrls, ORNet, VA508AccessibilityManager;
 
 type
-  TfrmDCOrders = class(TfrmAutoSz)
+  TfrmDCOrders = class(TfrmBase508Form)
     Label1: TLabel;
     Panel1: TPanel;
@@ -24,8 +24,12 @@
     procedure lstOrdersMeasureItem(Control: TWinControl; Index: Integer;
       var AHeight: Integer);
+    procedure FormDestroy(Sender: TObject);
+    procedure unMarkedOrignalOrderDC(OrderArr: TStringList);
   private
     OKPressed: Boolean;
     DCReason: Integer;
-    function MeasureColumnHeight(TheOrderText: string; Index: Integer):integer;    
+    function MeasureColumnHeight(TheOrderText: string; Index: Integer):integer;
+  public
+    OrderIDArr: TStringList;
   end;
 
@@ -46,8 +50,9 @@
   frmDCOrders: TfrmDCOrders;
   AnOrder: TOrder;
-  i,CanSign, DCType: Integer;
-  NeedReason,NeedRefresh,OnCurrent: Boolean;
+  i, j, CanSign, DCType: Integer;
+  NeedReason,NeedRefresh,OnCurrent, DCNewOrder: Boolean;
   OriginalID,APtEvtID,APtEvtName,AnEvtInfo,tmpPtEvt:  string;
   PtEvtList: TStringList;
+  DCChangeItem: TChangeItem;
 begin
   Result := False;
@@ -55,4 +60,5 @@
   OnCurrent := False;
   NeedRefresh := False;
+  DCNewOrder := false;
   PtEvtList := TStringList.Create;
   if SelectedList.Count = 0 then Exit;
@@ -65,5 +71,8 @@
       AnOrder    := TOrder(Items[i]);
       frmDCOrders.lstOrders.Items.Add(AnOrder.Text);
+      frmDCOrders.OrderIDArr.Add(AnOrder.ID);
       if not ((AnOrder.Status = 11) and (AnOrder.Signature = 2)) then NeedReason := True;
+      if (NeedReason = True) and (AnOrder.Status = 10) and (AnOrder.Signature = 2) then  NeedReason := False;
+      
     end;
     if NeedReason then
@@ -87,8 +96,22 @@
         OriginalID := AnOrder.ID;
         PtEvtList.Add(AnOrder.EventPtr + '^' + AnOrder.EventName);
-        DCOrder(AnOrder, frmDCOrders.DCReason, DCType);
+        if Changes.Orders.Count = 0 then DCNewOrder := false
+        else
+          begin
+            for j := 0 to Changes.Orders.Count - 1 do
+              begin
+                DCChangeItem := TChangeItem(Changes.Orders.Items[j]);
+                if DCChangeItem.ID = AnOrder.ID then
+                  begin
+                    if (Pos('DC', AnOrder.ActionOn) = 0) then
+                       DCNewOrder := True
+                    else DCNewOrder := False;
+                  end;
+              end;
+          end;
+        DCOrder(AnOrder, frmDCOrders.DCReason, DCNewOrder, DCType);
         case DCType of
         DCT_NEWORDER:  begin
-                         Changes.Add(CH_ORD, AnOrder.ID, AnOrder.Text, '', CanSign, AnOrder.ParentID);
+                         Changes.Add(CH_ORD, AnOrder.ID, AnOrder.Text, '', CanSign, AnOrder.ParentID, user.DUZ, AnOrder.DGroupName, True);
                          AnOrder.ActionOn := OriginalID + '=DC';
                        end;
@@ -150,4 +173,5 @@
   inherited;
   OKPressed := False;
+  OrderIDArr := TStringList.Create;
   ListDCReasons(lstReason.Items, DefaultIEN);
   lstReason.SelectByIEN(DefaultIEN);
@@ -179,4 +203,5 @@
 begin
   inherited;
+  unMarkedOrignalOrderDC(Self.OrderIDArr);
   Close;
 end;
@@ -194,5 +219,5 @@
   begin
     Canvas.FillRect(ARect);
-    Canvas.Pen.Color := clSilver;
+    Canvas.Pen.Color := Get508CompliantColor(clSilver);
     Canvas.MoveTo(0, ARect.Bottom - 1);
     Canvas.LineTo(ARect.Right, ARect.Bottom - 1);
@@ -230,3 +255,14 @@
 end;
 
+procedure TfrmDCOrders.FormDestroy(Sender: TObject);
+begin
+  inherited;
+  if self.OrderIDArr <> nil then self.OrderIDArr.Free;
+end;
+
+procedure TfrmDCOrders.unMarkedOrignalOrderDC(OrderArr: TStringList);
+begin
+ CallV('ORWDX1 UNDCORIG', [OrderArr]);
+end;
+
 end.
