Pārlūkot izejas kodu

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

MaiXinRong 9 gadi atpakaļ
vecāks
revīzija
45d8389397

+ 8 - 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;

+ 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

+ 14 - 0
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;
@@ -646,4 +648,16 @@ begin
     CommonExpand(stnNode);
 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.