|
@@ -18,6 +18,8 @@ type
|
|
constructor Create;
|
|
constructor Create;
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
|
|
|
|
|
|
+ function RoundTo(AValue: Double): Double;
|
|
|
|
+
|
|
procedure ClearLinkViewCols;
|
|
procedure ClearLinkViewCols;
|
|
procedure AddLinkViewCol(ACol: TObject);
|
|
procedure AddLinkViewCol(ACol: TObject);
|
|
|
|
|
|
@@ -36,6 +38,9 @@ type
|
|
constructor Create;
|
|
constructor Create;
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
|
|
|
|
|
|
+ procedure ResetLinkViewColumns(AProjectData: TObject);
|
|
|
|
+ procedure RefreshLinkViewColumnsFormat;
|
|
|
|
+
|
|
property Quantity: TDecimal read FQuantity;
|
|
property Quantity: TDecimal read FQuantity;
|
|
property TotalPrice: TDecimal read FTotalPrice;
|
|
property TotalPrice: TDecimal read FTotalPrice;
|
|
property Price: TDecimal read FPrice;
|
|
property Price: TDecimal read FPrice;
|
|
@@ -46,6 +51,7 @@ type
|
|
FProjectData: TObject;
|
|
FProjectData: TObject;
|
|
FCommon: TCalcDecimal;
|
|
FCommon: TCalcDecimal;
|
|
FCompile:TCalcDecimal;
|
|
FCompile:TCalcDecimal;
|
|
|
|
+ FPriceMargin: TCalcDecimal;
|
|
public
|
|
public
|
|
constructor Create(AProjectData: TObject);
|
|
constructor Create(AProjectData: TObject);
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
@@ -55,12 +61,13 @@ type
|
|
|
|
|
|
property Common: TCalcDecimal read FCommon;
|
|
property Common: TCalcDecimal read FCommon;
|
|
property Compile: TCalcDecimal read FCompile;
|
|
property Compile: TCalcDecimal read FCompile;
|
|
|
|
+ property PriceMargin: TCalcDecimal read FPriceMargin;
|
|
end;
|
|
end;
|
|
|
|
|
|
implementation
|
|
implementation
|
|
|
|
|
|
uses
|
|
uses
|
|
- ProjectData;
|
|
|
|
|
|
+ ProjectData, ScUtils;
|
|
|
|
|
|
{ TDecimal }
|
|
{ TDecimal }
|
|
|
|
|
|
@@ -88,18 +95,18 @@ end;
|
|
function TDecimal.GetDisplayFormat(ADigit: Integer): string;
|
|
function TDecimal.GetDisplayFormat(ADigit: Integer): string;
|
|
begin
|
|
begin
|
|
case ADigit of
|
|
case ADigit of
|
|
- 0: Result := '0';
|
|
|
|
- 1: Result := '0.#';
|
|
|
|
- 2: Result := '0.##';
|
|
|
|
- 3: Result := '0.###';
|
|
|
|
- 4: Result := '0.####';
|
|
|
|
- 5: Result := '0.#####';
|
|
|
|
- 6: Result := '0.######';
|
|
|
|
- 7: Result := '0.#######';
|
|
|
|
- 8: Result := '0.########';
|
|
|
|
- 9: Result := '0.#########';
|
|
|
|
|
|
+ 0: Result := '#';
|
|
|
|
+ 1: Result := '#.#';
|
|
|
|
+ 2: Result := '#.##';
|
|
|
|
+ 3: Result := '#.###';
|
|
|
|
+ 4: Result := '#.####';
|
|
|
|
+ 5: Result := '#.#####';
|
|
|
|
+ 6: Result := '#.######';
|
|
|
|
+ 7: Result := '#.#######';
|
|
|
|
+ 8: Result := '#.########';
|
|
|
|
+ 9: Result := '#.#########';
|
|
else
|
|
else
|
|
- Result := '0.##########';
|
|
|
|
|
|
+ Result := '#.##########';
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -111,16 +118,26 @@ begin
|
|
for i := 0 to FLinkViewCols.Count - 1 do
|
|
for i := 0 to FLinkViewCols.Count - 1 do
|
|
begin
|
|
begin
|
|
ViewCol := TsdViewColumn(FLinkViewCols.Items[i]);
|
|
ViewCol := TsdViewColumn(FLinkViewCols.Items[i]);
|
|
|
|
+ if not Assigned(ViewCol) then Continue;
|
|
|
|
+
|
|
ViewCol.DisplayFormat := FFormat;
|
|
ViewCol.DisplayFormat := FFormat;
|
|
ViewCol.EditFormat := FFormat;
|
|
ViewCol.EditFormat := FFormat;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TDecimal.RoundTo(AValue: Double): Double;
|
|
|
|
+begin
|
|
|
|
+ Result := ScRoundTo(AValue, -Digit);
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TDecimal.SetDigit(const Value: Integer);
|
|
procedure TDecimal.SetDigit(const Value: Integer);
|
|
begin
|
|
begin
|
|
- FDigit := Value;
|
|
|
|
- FFormat := GetDisplayFormat(FDigit);
|
|
|
|
- RefreshLinkViewColsFormat;
|
|
|
|
|
|
+ if FDigit <> Value then
|
|
|
|
+ begin
|
|
|
|
+ FDigit := Value;
|
|
|
|
+ FFormat := GetDisplayFormat(FDigit);
|
|
|
|
+ RefreshLinkViewColsFormat;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
{ TCalcDecimal }
|
|
{ TCalcDecimal }
|
|
@@ -140,6 +157,23 @@ begin
|
|
inherited;
|
|
inherited;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TCalcDecimal.RefreshLinkViewColumnsFormat;
|
|
|
|
+begin
|
|
|
|
+ Price.RefreshLinkViewColsFormat;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TCalcDecimal.ResetLinkViewColumns(AProjectData: TObject);
|
|
|
|
+begin
|
|
|
|
+ Price.ClearLinkViewCols;
|
|
|
|
+ with TProjectData(AProjectData).ProjectGLData.sdvProjectGL do
|
|
|
|
+ begin
|
|
|
|
+ Price.AddLinkViewCol(Columns.FindColumn('BasePrice'));
|
|
|
|
+ Price.AddLinkViewCol(Columns.FindColumn('InfoPrice'));
|
|
|
|
+ Price.AddLinkViewCol(Columns.FindColumn('DeltaPrice'));
|
|
|
|
+ Price.AddLinkViewCol(Columns.FindColumn('ValidDeltaPrice'));
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
{ TDecimalManager }
|
|
{ TDecimalManager }
|
|
|
|
|
|
constructor TDecimalManager.Create(AProjectData: TObject);
|
|
constructor TDecimalManager.Create(AProjectData: TObject);
|
|
@@ -147,10 +181,12 @@ begin
|
|
FProjectData := AProjectData;
|
|
FProjectData := AProjectData;
|
|
FCommon := TCalcDecimal.Create;
|
|
FCommon := TCalcDecimal.Create;
|
|
FCompile := TCalcDecimal.Create;
|
|
FCompile := TCalcDecimal.Create;
|
|
|
|
+ FPriceMargin := TCalcDecimal.Create;
|
|
end;
|
|
end;
|
|
|
|
|
|
destructor TDecimalManager.Destroy;
|
|
destructor TDecimalManager.Destroy;
|
|
begin
|
|
begin
|
|
|
|
+ FPriceMargin.Free;
|
|
FCompile.Free;
|
|
FCompile.Free;
|
|
FCommon.Free;
|
|
FCommon.Free;
|
|
inherited;
|
|
inherited;
|
|
@@ -245,8 +281,9 @@ procedure TDecimalManager.ResetLinkViewColumns;
|
|
end;
|
|
end;
|
|
|
|
|
|
begin
|
|
begin
|
|
- ResetCommonLink;
|
|
|
|
- ResetCompileLink;
|
|
|
|
|
|
+ //ResetCommonLink;
|
|
|
|
+ //ResetCompileLink;
|
|
|
|
+ FPriceMargin.ResetLinkViewColumns(FProjectData);
|
|
end;
|
|
end;
|
|
|
|
|
|
end.
|
|
end.
|