Browse Source

judge of super meter

MaiXinRong 8 years ago
parent
commit
db1430a7f6
3 changed files with 19 additions and 5 deletions
  1. 7 5
      Frames/BillsGatherFme.pas
  2. 3 0
      Units/CalcDecimal.pas
  3. 9 0
      Units/UtilMethods.pas

+ 7 - 5
Frames/BillsGatherFme.pas

@@ -56,7 +56,7 @@ type
 implementation
 implementation
 
 
 uses
 uses
-  ProjectData;
+  ProjectData, UtilMethods, CalcDecimal;
 
 
 {$R *.dfm}
 {$R *.dfm}
 
 
@@ -141,7 +141,7 @@ procedure TBillsGatherFrame.zgGclBillsCellGetColor(Sender: TObject;
   function CheckOverRange(ARecIndex: Integer): Boolean;
   function CheckOverRange(ARecIndex: Integer): Boolean;
   var
   var
     Rec: TsdDataRecord;
     Rec: TsdDataRecord;
-    fQuantity, fDealQuantity, fEndDealQuantity: Double;
+    fQuantity, fDealQuantity, fEndDealQuantity, fCompare: Double;
   begin
   begin
     Rec := saGclBills.DataView.Records[ARecIndex];
     Rec := saGclBills.DataView.Records[ARecIndex];
     Result := False;
     Result := False;
@@ -150,10 +150,12 @@ procedure TBillsGatherFrame.zgGclBillsCellGetColor(Sender: TObject;
     fDealQuantity := Rec.ValueByName('DealQuantity').AsFloat;
     fDealQuantity := Rec.ValueByName('DealQuantity').AsFloat;
     fQuantity := Rec.ValueByName('Quantity').AsFloat;
     fQuantity := Rec.ValueByName('Quantity').AsFloat;
     fEndDealQuantity := Rec.ValueByName('EndDealQuantity').AsFloat;
     fEndDealQuantity := Rec.ValueByName('EndDealQuantity').AsFloat;
+    fCompare := TProjectData(FBillsGatherData.ProjectData).ProjProperties.DecimalManager.Common.Quantity.CompareValue;
     case SupportManager.ConfigInfo.OverRangeType of
     case SupportManager.ConfigInfo.OverRangeType of
-      0: Result := fEndDealQuantity > fQuantity;
-      1: Result := fEndDealQuantity > fDealQuantity;
-      2: Result := (fEndDealQuantity > fQuantity) or (fEndDealQuantity > fDealQuantity);
+      0: Result := QuantityRoundTo(fEndDealQuantity - fQuantity) > fCompare;
+      1: Result := QuantityRoundTo(fEndDealQuantity - fDealQuantity) > fCompare;
+      2: Result := (QuantityRoundTo(fEndDealQuantity - fQuantity) > fCompare)
+                or (QuantityRoundTo(fEndDealQuantity - fQuantity) > fCompare);
     end;
     end;
   end;
   end;
 
 

+ 3 - 0
Units/CalcDecimal.pas

@@ -12,6 +12,7 @@ type
     FFormat: string;
     FFormat: string;
     FLinkViewCols: TList;
     FLinkViewCols: TList;
     FRelaDecimal: TDecimal;
     FRelaDecimal: TDecimal;
+    FCompareValue: Double;
     procedure SetDigit(const Value: Integer);
     procedure SetDigit(const Value: Integer);
 
 
     function GetDisplayFormat(ADigit: Integer): string;
     function GetDisplayFormat(ADigit: Integer): string;
@@ -30,6 +31,7 @@ type
 
 
     property Digit: Integer read FDigit write SetDigit;
     property Digit: Integer read FDigit write SetDigit;
     property Format: string read FFormat;
     property Format: string read FFormat;
+    property CompareValue: Double read FCompareValue;
 
 
     property RelaDecimal: TDecimal read FRelaDecimal write SetRelaDecimal;
     property RelaDecimal: TDecimal read FRelaDecimal write SetRelaDecimal;
   end;
   end;
@@ -156,6 +158,7 @@ begin
   begin
   begin
     FDigit := Value;
     FDigit := Value;
     FFormat := GetDisplayFormat(FDigit);
     FFormat := GetDisplayFormat(FDigit);
+    FCompareValue := GetCompareDigitValue(FDigit);
     RefreshLinkViewColsFormat;
     RefreshLinkViewColsFormat;
   end;
   end;
 end;
 end;

+ 9 - 0
Units/UtilMethods.pas

@@ -12,6 +12,7 @@ type
   TBookmarkRefreshEvent = procedure (AExpandFrame: Boolean) of object;
   TBookmarkRefreshEvent = procedure (AExpandFrame: Boolean) of object;
 
 
   {RoundTo}
   {RoundTo}
+  function GetCompareDigitValue(ADigit: Integer): Double;
   function QuantityRoundTo(AValue: Double): Double;
   function QuantityRoundTo(AValue: Double): Double;
   function PriceRoundTo(AValue: Double): Double;
   function PriceRoundTo(AValue: Double): Double;
   function TotalPriceRoundTo(AValue: Double): Double;
   function TotalPriceRoundTo(AValue: Double): Double;
@@ -158,6 +159,14 @@ begin
   end;
   end;
 end;
 end;
 
 
+function GetCompareDigitValue(ADigit: Integer): Double;
+begin
+  if ADigit < 0 then
+    Result := IntPower(10, ADigit - 1)
+  else
+    Result := 0.1;
+end;
+
 function QuantityRoundTo(AValue: Double): Double;
 function QuantityRoundTo(AValue: Double): Double;
 begin
 begin
   if Assigned(OpenProjectManager.CurProjectData) then
   if Assigned(OpenProjectManager.CurProjectData) then