Browse Source

Bug 拷贝前一期调差工料的价格信息报错

MaiXinRong 10 years ago
parent
commit
c8c901b2e1

+ 23 - 4
DataModules/ProjectGLDm.pas

@@ -40,6 +40,9 @@ type
     procedure SaveGLPrice;
     procedure SavePM_CurData;
 
+    procedure BeforeBatchOperation;
+    procedure AfterBatchOperation;
+
     function GetValidDeltaPrice(AID: Integer): Double;
     function GetPM_TotalPrice: Double;
     function GetActive: Boolean;
@@ -128,7 +131,7 @@ var
   end;
 
 begin
-  sddProjectGL.BeginUpdate;
+  BeforeBatchOperation;
   vQuery := TADOQuery.Create(nil);
   try
     vQuery.Connection := sdpProjectGL.Connection;
@@ -139,7 +142,7 @@ begin
     LoadInfoPrice;
   finally
     vQuery.Free;
-    sddProjectGL.EndUpdate;
+    AfterBatchOperation;
   end;
 end;
 
@@ -512,7 +515,7 @@ var
   end;
 
 begin
-  sddProjectGL.BeginUpdate;
+  BeforeBatchOperation;
   vQuery := TADOQuery.Create(nil);
   try
     vQuery.Connection := sdpProjectGL.Connection;
@@ -524,8 +527,24 @@ begin
     LoadPM_Calc;
   finally
     vQuery.Free;
-    sddProjectGL.EndUpdate;
+    AfterBatchOperation;
   end;
 end;
 
+procedure TProjectGLData.AfterBatchOperation;
+begin                         
+  sddProjectGL.EndUpdate;
+  sddProjectGL.EnableControls;
+  sddProjectGL.BeforeValueChange := sddProjectGLBeforeValueChange;
+  sddProjectGL.AfterValueChanged := sddProjectGLAfterValueChanged;
+end;
+
+procedure TProjectGLData.BeforeBatchOperation;
+begin
+  sddProjectGL.AfterValueChanged := nil;
+  sddProjectGL.BeforeValueChange := nil;
+  sddProjectGL.DisableControls;         
+  sddProjectGL.BeginUpdate;
+end;
+
 end.

+ 1 - 0
DataModules/StageDm.pas

@@ -364,6 +364,7 @@ end;
 
 procedure TStageData.Save;
 begin
+  sddStage.SaveToFile('E:\1.xml');
   sddStage.Save;
 end;
 

+ 3 - 0
Frames/PriceMarginBillsFme.dfm

@@ -335,6 +335,7 @@ object PriceMarginBillsFrame: TPriceMarginBillsFrame
       end>
     Grid = zgGclBills
     ExtendRowCount = 3
+    Options = []
     Left = 112
     Top = 96
   end
@@ -558,6 +559,7 @@ object PriceMarginBillsFrame: TPriceMarginBillsFrame
       end>
     Grid = zgDetailGclBills
     ExtendRowCount = 3
+    Options = []
     Left = 96
     Top = 496
   end
@@ -637,6 +639,7 @@ object PriceMarginBillsFrame: TPriceMarginBillsFrame
       end>
     Grid = zgDetailGL
     ExtendRowCount = 3
+    Options = [aoAllowEdit, aoAllowDelete, aoAutoInsert]
     Left = 728
     Top = 504
   end

+ 4 - 0
Frames/PriceMarginBillsFme.pas

@@ -179,6 +179,10 @@ begin
   with TProjectData(FPriceMarginBillsData.ProjectData) do
   begin
     saDetailGL.Columns.ColumnByName('Quantity').ReadOnly := PriceMarginReadOnly;
+    if PriceMarginReadOnly then
+      saDetailGL.Options := saDetailGL.Options - [aoAllowDelete]
+    else
+      saDetailGL.Options := saDetailGL.Options + [aoAllowDelete];
   end;
 end;
 

+ 5 - 0
Frames/ProjectGLFme.pas

@@ -64,6 +64,11 @@ begin
   saProjectGL.Columns.ColumnByName('RiskRange').ReadOnly := AReadOnly;
   saProjectGL.Columns.ColumnByName('InfoPrice').ReadOnly := AReadOnly;
   saProjectGL.Columns.ColumnByName('InfoDate').ReadOnly := AReadOnly;
+
+  if AReadOnly then
+    saProjectGL.Options := saProjectGL.Options - [aoAllowInsert, aoAllowDelete]
+  else
+    saProjectGL.Options := saProjectGL.Options + [aoAllowInsert, aoAllowDelete];
 end;
 
 procedure TProjectGLFrame.zgProjectGLMouseDown(Sender: TObject;

+ 3 - 1
Units/ProjectData.pas

@@ -1645,7 +1645,7 @@ procedure TProjectData.CopyPreData;
   const
     sCopySql = 'Insert Into GLPrice (GLID, PhaseID,' +
                '    InfoPrice, InfoDate, DeltaPrice, ValidDeltaPrice,' +
-               '    PM_PreQuantity, PM_PreTotalPrice'+
+               '    PM_PreQuantity, PM_PreTotalPrice)'+
                '  Select GLID, %d,'+
                '    InfoPrice, InfoDate, DeltaPrice, ValidDeltaPrice,'+
                '    PM_PreQuantity+PM_Quantity_F, PM_PreTotalPrice+PM_TotalPrice_F'+
@@ -1658,6 +1658,8 @@ procedure TProjectData.CopyPreData;
 begin
   CopyPreGLPrice;
   PhaseData.CopyPreData;
+  ProjectGLData.LoadCurPhaseInfoPrice;
+  ProjectGLData.LoadStagePM_CalcData;
 end;
 
 function TProjectData.GetStageIndex: Integer;