Преглед изворни кода

Bug #890 台账分解,用户删除数量/金额时,应同步清除公式

MaiXinRong пре 9 година
родитељ
комит
d24e19ae62

+ 11 - 2
DataModules/BillsCompileDm.pas

@@ -556,7 +556,10 @@ procedure TBillsCompileData.sdvBillsCompileSetText(var Text: String;
   begin
     sPre := StringReplace(AFieldName, 'Quantity', '', [rfIgnoreCase, rfReplaceAll]);
     if CheckStringNull(Text) or CheckNumeric(Text) then
-      Text := FloatToStr(QuantityRoundTo(StrToFloatDef(Text, 0)))
+    begin
+      ARecord.ValueByName(sPre + 'Formula').AsString := '';
+      Text := FloatToStr(QuantityRoundTo(StrToFloatDef(Text, 0)));
+    end
     else
     begin
       ARecord.ValueByName(sPre + 'Formula').AsString := Text;
@@ -571,7 +574,10 @@ procedure TBillsCompileData.sdvBillsCompileSetText(var Text: String;
   begin
     sPre := StringReplace(AFieldName, 'TotalPrice', '', [rfIgnoreCase, rfReplaceAll]);
     if CheckStringNull(Text) or CheckNumeric(Text) then
-      Text := FloatToStr(TotalPriceRoundTo(StrToFloatDef(Text, 0)))
+    begin
+      ARecord.ValueByName(sPre + 'Formula').AsString := '';
+      Text := FloatToStr(TotalPriceRoundTo(StrToFloatDef(Text, 0)));
+    end
     else
     begin
       ARecord.ValueByName(sPre + 'Formula').AsString := Text;
@@ -885,6 +891,7 @@ begin
             OrgQuantity.AsFloat + MisQuantity.AsFloat + OthQuantity.AsFloat);
         TotalPrice.AsFloat := TotalPriceRoundTo(
             OrgTotalPrice.AsFloat + MisTotalPrice.AsFloat + OthTotalPrice.AsFloat);
+        CacheMisTP := MisTotalPrice.AsFloat;
       end;
     end;
   end;
@@ -921,6 +928,7 @@ begin
             OrgQuantity.AsFloat + MisQuantity.AsFloat + OthQuantity.AsFloat);
         TotalPrice.AsFloat := TotalPriceRoundTo(
             OrgTotalPrice.AsFloat + MisTotalPrice.AsFloat + OthTotalPrice.AsFloat);
+        CacheOrgTP := OrgTotalPrice.AsFloat;
       end;
     end;
   end;
@@ -957,6 +965,7 @@ begin
             OrgQuantity.AsFloat + MisQuantity.AsFloat + OthQuantity.AsFloat);
         TotalPrice.AsFloat := TotalPriceRoundTo(
             OrgTotalPrice.AsFloat + MisTotalPrice.AsFloat+ OthTotalPrice.AsFloat);
+        CacheOthTP := OthTotalPrice.AsFloat;
       end;
     end;
   end;

+ 6 - 9
DataModules/BillsDm.pas

@@ -423,16 +423,15 @@ end;
 procedure TBillsData.LockedBaseData;
 var
   iIndex: Integer;
+  Rec: TBillsRecord;
 begin
   sddBills.BeginUpdate;
   for iIndex := 0 to sddBills.RecordCount - 1 do
   begin
-    if not sddBills.Records[iIndex].ValueByName('LockedLevel').AsBoolean then
-      sddBills.Records[iIndex].ValueByName('LockedLevel').AsBoolean := True;
-    if not sddBills.Records[iIndex].ValueByName('LockedInfo').AsBoolean then
-      sddBills.Records[iIndex].ValueByName('LockedInfo').AsBoolean := True;
-    if sddBills.Records[iIndex].ValueByName('NewPrice').AsFloat <> 0 then
-      sddBills.Records[iIndex].ValueByName('LockedNewPrice').AsBoolean := True;
+    Rec := TBillsRecord(sddBills.Records[iIndex]);
+    Rec.SetBoolValue(Rec.LockLevel, True);
+    Rec.SetBoolValue(Rec.LockInfo, True);
+    Rec.SetBoolValue(Rec.LockNewPrice, Rec.NewPrice.AsFloat <> 0);
   end;
   sddBills.EndUpdate;
 end;
@@ -515,13 +514,11 @@ end;
 procedure TBillsData.DisableEvents;
 begin
   sddBills.BeforeValueChange := nil;
-  sddBills.AfterValueChanged := nil;
 end;
 
 procedure TBillsData.EnableEvents;
 begin
-  {sddBills.BeforeValueChange := sddBillsBeforeValueChange;
-  sddBills.AfterValueChanged := sddBillsAfterValueChanged;}
+  sddBills.BeforeValueChange := sddBillsBeforeValueChange;
 end;
 
 procedure TBillsData.UnLockedBaseData;

+ 5 - 9
DataModules/StageDm.pas

@@ -464,18 +464,14 @@ end;
 procedure TStageData.UpdateComplete(ABillsID: Integer; AQuantity,
   ATotalPrice: Double);
 var
-  Rec: TsdDataRecord;
+  Rec: TStageRecord;
 begin
   if ABillsID = -1 then Exit;
   Rec := StageRecord(ABillsID);
-  Rec.ValueByName('GatherQuantity').AsFloat := QuantityRoundTo(
-      Rec.ValueByName('GatherQuantity').AsFloat + AQuantity);
-  Rec.ValueByName('GatherTotalPrice').AsFloat := TotalPriceRoundTo(
-      Rec.ValueByName('GatherTotalPrice').AsFloat + ATotalPrice);
-  Rec.ValueByName('EndGatherQuantity').AsFloat := QuantityRoundTo(
-      Rec.ValueByName('EndGatherQuantity').AsFloat + AQuantity);
-  Rec.ValueByName('EndGatherTotalPrice').AsFloat := TotalPriceRoundTo(
-      Rec.ValueByName('EndGatherTotalPrice').AsFloat + ATotalPrice);
+  Rec.GatherQuantity.AsFloat := QuantityRoundTo(Rec.GatherQuantity.AsFloat + AQuantity);
+  Rec.GatherTotalPrice.AsFloat := TotalPriceRoundTo(Rec.GatherTotalPrice.AsFloat + ATotalPrice);
+  Rec.EndGatherQuantity.AsFloat := QuantityRoundTo(Rec.EndGatherQuantity.AsFloat + AQuantity);
+  Rec.EndGatherTotalPrice.AsFloat := TotalPriceRoundTo(Rec.EndGatherTotalPrice.AsFloat + ATotalPrice);
   // ÊýÁ¿²»ÏòÉÏ»ã×Ü
   UpdateParentRecord(ABillsID, ATotalPrice, 'GatherTotalPrice');
 end;

+ 1 - 0
Frames/BillsCompileFme.dfm

@@ -63,6 +63,7 @@ object BillsCompileFrame: TBillsCompileFrame
       Selection.TransparentColor = False
       FrozenCol = 0
       FrozenRow = 0
+      OnCellTextChanged = zgBillsCompileCellTextChanged
       OnCustomPaste = zgBillsCompileCustomPaste
       OnCopy = zgBillsCompileCopy
       OnPaste = zgBillsCompilePaste

+ 19 - 8
Frames/BillsCompileFme.pas

@@ -67,6 +67,8 @@ type
     procedure actnImportGclBillsToXmjUpdate(Sender: TObject);
     procedure actnImportGclBillsToXmjExecute(Sender: TObject);
     procedure actnImportPlaneFxBillsToXmjExecute(Sender: TObject);
+    procedure zgBillsCompileCellTextChanged(Sender: TObject; Col,
+      Row: Integer);
   private
     FBillsCompileData: TBillsCompileData;
     FShowIDField: Boolean;
@@ -227,13 +229,7 @@ begin
     dxpmBillsCompile.PopupFromCursorPos
   else
   begin
-    if CheckExprsColumn then
-      laEdtExprs.Text := zgBillsCompile.CurCell.EditText
-    else
-      laEdtExprs.Text := '';
-    with stdBillsCompile.DataView do
-      if Assigned(Current) then
-        laEdtExprs.ReadOnly := Current.ValueByName('LockedInfo').AsBoolean;
+
   end;
 end;
 
@@ -287,7 +283,10 @@ begin
   iCol := zgBillsCompile.CurCol-zgBillsCompile.FixedColCount;
   Result := (iCol = stdBillsCompile.VisibleCol('OrgQuantity'))
          or (iCol = stdBillsCompile.VisibleCol('MisQuantity'))
-         or (iCol = stdBillsCompile.VisibleCol('OthQuantity'));
+         or (iCol = stdBillsCompile.VisibleCol('OthQuantity'))
+         or (iCol = stdBillsCompile.VisibleCol('OrgTotalPrice'))
+         or (iCol = stdBillsCompile.VisibleCol('MisTotalPrice'))
+         or (iCol = stdBillsCompile.VisibleCol('OthTotalPirce'));
 end;
 
 procedure TBillsCompileFrame.laEdtExprsKeyDown(Sender: TObject;
@@ -610,4 +609,16 @@ begin
   end;
 end;
 
+procedure TBillsCompileFrame.zgBillsCompileCellTextChanged(Sender: TObject;
+  Col, Row: Integer);
+begin
+  if CheckExprsColumn then
+    laEdtExprs.Text := zgBillsCompile.CurCell.EditText
+  else
+    laEdtExprs.Text := '';
+  with stdBillsCompile.DataView do
+    if Assigned(Current) then
+      laEdtExprs.ReadOnly := Current.ValueByName('LockedInfo').AsBoolean;
+end;
+
 end.