Prechádzať zdrojové kódy

计量台账,判断无效输入Bug

MaiXinRong 9 rokov pred
rodič
commit
d25f402a38
1 zmenil súbory, kde vykonal 20 pridanie a 2 odobranie
  1. 20 2
      DataModules/BillsMeasureDm.pas

+ 20 - 2
DataModules/BillsMeasureDm.pas

@@ -358,8 +358,10 @@ procedure TBillsMeasureData.sdvBillsMeasureSetText(var Text: String;
       AValue.Owner.ValueByName(AField + 'Formula').AsString := Text;
       Text := FloatToStr(QuantityRoundTo(EvaluateExprs(Text)));
     end;
+    
     vNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(GetBillsID));
-    vNode.Rec.CalcType.AsInteger := 0;
+    if vNode.Rec.CalcType.AsInteger <> 0 then
+      vNode.Rec.CalcType.AsInteger := 0;
   end;
 
   procedure SetTotalPrice(const AField: string);
@@ -383,8 +385,10 @@ procedure TBillsMeasureData.sdvBillsMeasureSetText(var Text: String;
       AValue.Owner.ValueByName(AField + 'Formula').AsString := Text;
       Text := FloatToStr(TotalPriceRoundTo(EvaluateExprs(Text)));
     end;
+
     vNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(GetBillsID));
-    vNode.Rec.CalcType.AsInteger := 1;
+    if vNode.Rec.CalcType.AsInteger <> 1 then
+      vNode.Rec.CalcType.AsInteger := 1;
   end;
 
   procedure DoCurChanged;
@@ -409,9 +413,23 @@ procedure TBillsMeasureData.sdvBillsMeasureSetText(var Text: String;
       Text := FloatToStr(PriceRoundTo(StrToFloatDef(Text, 0)));
   end;
 
+  function CheckValidData: Boolean;
+  begin
+    Result := (AValue.AsString <> Text);
+    if (Pos('Quantity', AColumn.FieldName) > 0) or
+       (Pos('Price', AColumn.FieldName) > 0) then
+    begin
+      if (AValue.AsFloat = 0) and (Text = '') then
+        Result := False;
+    end;
+  end;
+
 begin
   if not Assigned(AValue) then Exit;
   // 修改后数据与原数据相同则不提交
+  if not CheckValidData then
+    Allow := False;
+  if not Allow then Exit;
   if (AValue.AsString = Text) or ((AValue.AsFloat = 0) and (Text = '')) then Exit;
 
   CheckLockedData;