|
@@ -50,6 +50,8 @@ type
|
|
|
|
|
|
function GatherChildren(ANode: TsdIDTreeNode; const AFieldName: string): Double;
|
|
|
procedure UpdateParent(ABillsID: Integer; ADifferTotalPrice: Double; const AFieldName: string);
|
|
|
+ // 经济指标[与其他节点无关]
|
|
|
+ procedure CalculateDesignPrice(ANode: TBillsIDTreeNode);
|
|
|
// 施工图原设计[增量]
|
|
|
procedure CalculateOrg(ABillsID: Integer);
|
|
|
// 设计错漏增减[增量]
|
|
@@ -143,15 +145,38 @@ end;
|
|
|
procedure TBillsCompileData.sdvBillsCompileGetText(var Text: String;
|
|
|
ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
|
|
|
DisplayText: Boolean);
|
|
|
-var
|
|
|
- fDgnPrice: Double;
|
|
|
-begin
|
|
|
- if (Pos('Price', AColumn.FieldName) > 0) or
|
|
|
- (Pos('Quantity', AColumn.FieldName) > 0) then
|
|
|
+
|
|
|
+ procedure GetEditText;
|
|
|
+ var
|
|
|
+ sFormula: string;
|
|
|
+ begin
|
|
|
+ if SameText('OrgQuantity', AColumn.FieldName) then
|
|
|
+ sFormula := ARecord.ValueByName('OrgFormula').AsString
|
|
|
+ else if SameText('MisQuantity', AColumn.FieldName) then
|
|
|
+ sFormula := ARecord.ValueByName('MisFormula').AsString
|
|
|
+ else if SameText('OthQuantity', AColumn.FieldName) then
|
|
|
+ sFormula := ARecord.ValueByName('OthFormula').AsString
|
|
|
+ else
|
|
|
+ sFormula := '';
|
|
|
+ if sFormula <> '' then
|
|
|
+ Text := sFormula;
|
|
|
+ end;
|
|
|
+
|
|
|
+ procedure GetDisplayText;
|
|
|
begin
|
|
|
- if Assigned(AValue) and (AValue.AsFloat = 0) then
|
|
|
- Text := '';
|
|
|
+ if (Pos('Price', AColumn.FieldName) > 0) or
|
|
|
+ (Pos('Quantity', AColumn.FieldName) > 0) then
|
|
|
+ begin
|
|
|
+ if Assigned(AValue) and (AValue.AsFloat = 0) then
|
|
|
+ Text := '';
|
|
|
+ end;
|
|
|
end;
|
|
|
+
|
|
|
+begin
|
|
|
+ if DisplayText then
|
|
|
+ GetDisplayText
|
|
|
+ else
|
|
|
+ GetEditText;
|
|
|
end;
|
|
|
|
|
|
procedure TBillsCompileData.ExpandNodeTo(ALevel: Integer);
|
|
@@ -190,11 +215,14 @@ procedure TBillsCompileData.sdvBillsCompileAfterValueChanged(
|
|
|
var
|
|
|
stnNode: TsdIDTreeNode;
|
|
|
begin
|
|
|
- if SameText(AValue.FieldName, 'OrgQuantity') then
|
|
|
+ if SameText(AValue.FieldName, 'OrgQuantity') or
|
|
|
+ SameText(AValue.FieldName, 'OrgTotalPrice') then
|
|
|
CalculateOrg(AValue.Owner.ValueByName('ID').AsInteger)
|
|
|
- else if SameText(AValue.FieldName, 'MisQuantity') then
|
|
|
+ else if SameText(AValue.FieldName, 'MisQuantity') or
|
|
|
+ SameText(AValue.FieldName, 'MisTotalPrice') then
|
|
|
CalculateMis(AValue.Owner.ValueByName('ID').AsInteger)
|
|
|
- else if SameText(AValue.FieldName, 'OthQuantity') then
|
|
|
+ else if SameText(AValue.FieldName, 'OthQuantity') or
|
|
|
+ SameText(AValue.FieldName, 'OthTotalPrice') then
|
|
|
CalculateOth(AValue.Owner.ValueByName('ID').AsInteger)
|
|
|
else if SameText(AValue.FieldName, 'Price') or
|
|
|
SameText(AValue.FieldName, 'DgnQuantity1') then
|
|
@@ -282,6 +310,18 @@ begin
|
|
|
|
|
|
if SameText(AValue.FieldName, 'ParentID') then
|
|
|
FBeforeChangeParentID := AValue.AsInteger;
|
|
|
+ if SameText(AValue.FieldName, 'OrgQuantity') or
|
|
|
+ SameText(AValue.FieldName, 'MisQuantity') or
|
|
|
+ SameText(AValue.FieldName, 'OthQuantity') or
|
|
|
+ SameText(AValue.FieldName, 'OrgTotalPrice') or
|
|
|
+ SameText(AValue.FieldName, 'MisTotalPrice') or
|
|
|
+ SameText(AValue.FieldName, 'OthTotalPrice') or
|
|
|
+ SameText(AValue.FieldName, 'Price') then
|
|
|
+ begin
|
|
|
+ TBillsRecord(AValue.Owner).CacheOrgTP := AValue.Owner.ValueByName('OrgTotalPrice').AsFloat;
|
|
|
+ TBillsRecord(AValue.Owner).CacheMisTP := AValue.Owner.ValueByName('MisTotalPrice').AsFloat;
|
|
|
+ TBillsRecord(AValue.Owner).CacheOthTP := AValue.Owner.ValueByName('OthTotalPrice').AsFloat;
|
|
|
+ end;
|
|
|
end;
|
|
|
|
|
|
procedure TBillsCompileData.CalculateAll;
|
|
@@ -525,13 +565,23 @@ procedure TBillsCompileData.sdvBillsCompileSetText(var Text: String;
|
|
|
Allow := False;
|
|
|
end;
|
|
|
|
|
|
- procedure SetQuantity;
|
|
|
+ procedure SetQuantity(const APre: string);
|
|
|
begin
|
|
|
- // 0号台账改为三项合计后,不记录输入的功能,但允许公式计算
|
|
|
+ // 0号台账改为三项合计后,不记录输入的公式,但允许公式计算
|
|
|
if CheckStringNull(Text) or CheckNumeric(Text) then
|
|
|
Text := FloatToStr(QuantityRoundTo(StrToFloatDef(Text, 0)))
|
|
|
else
|
|
|
+ begin
|
|
|
+ ARecord.ValueByName(APre + 'Formula').AsString := Text;
|
|
|
Text := FloatToStr(QuantityRoundTo(EvaluateExprs(Text)));
|
|
|
+ end;
|
|
|
+ ARecord.ValueByName('CalcType').AsInteger := 0;
|
|
|
+ end;
|
|
|
+
|
|
|
+ procedure SetTotalPrice;
|
|
|
+ begin
|
|
|
+ Text := FloatToStr(TotalPriceRoundTo(StrToFloatDef(Text, 0)));
|
|
|
+ ARecord.ValueByName('CalcType').AsInteger := 1;
|
|
|
end;
|
|
|
|
|
|
procedure SetDgnQuantity;
|
|
@@ -546,10 +596,16 @@ procedure TBillsCompileData.sdvBillsCompileSetText(var Text: String;
|
|
|
|
|
|
procedure DoCurChanged;
|
|
|
begin
|
|
|
- if SameText(AColumn.FieldName, 'OrgQuantity') or
|
|
|
- SameText(AColumn.FieldName, 'MisQuantity') or
|
|
|
- SameText(AColumn.FieldName, 'OthQuantity') then
|
|
|
- SetQuantity
|
|
|
+ if SameText(AColumn.FieldName, 'OrgQuantity') then
|
|
|
+ SetQuantity('Org')
|
|
|
+ else if SameText(AColumn.FieldName, 'MisQuantity') then
|
|
|
+ SetQuantity('Mis')
|
|
|
+ else if SameText(AColumn.FieldName, 'OthQuantity') then
|
|
|
+ SetQuantity('Oth')
|
|
|
+ else if SameText(AColumn.FieldName, 'OrgTotalPrice') or
|
|
|
+ SameText(AColumn.FieldName, 'MisTotalPrice') or
|
|
|
+ SameText(AColumn.FieldName, 'OthTotalPrice') then
|
|
|
+ SetTotalPrice
|
|
|
else if Pos('DgnQuantity', AColumn.FieldName) = 1 then
|
|
|
SetDgnQuantity
|
|
|
else if SameText(AColumn.FieldName, 'Price') then
|
|
@@ -576,28 +632,45 @@ procedure TBillsCompileData.sdvBillsCompileSetText(var Text: String;
|
|
|
|
|
|
procedure CheckNodeWritable;
|
|
|
var
|
|
|
- vNode: TsdIDTreeNode;
|
|
|
+ vNode: TBillsIDTreeNode;
|
|
|
iCreatePhase: Integer;
|
|
|
begin
|
|
|
if not Allow then Exit;
|
|
|
- vNode := BillsCompileTree.FindNode(ARecord.ValueByName('ID').AsInteger);
|
|
|
+ vNode := TBillsIDTreeNode(BillsCompileTree.FindNode(ARecord.ValueByName('ID').AsInteger));
|
|
|
iCreatePhase := vNode.Rec.ValueByName('CreatePhaseID').AsInteger;
|
|
|
|
|
|
if vNode.HasChildren then
|
|
|
begin
|
|
|
if Text = '' then
|
|
|
Exit
|
|
|
- else if (SameText('Quantity', AColumn.FieldName)) or
|
|
|
- (SameText('TotalPrice', AColumn.FieldName)) then
|
|
|
+ else if (Pos('Quantity', AColumn.FieldName) > 0) or
|
|
|
+ (Pos('TotalPrice', AColumn.FieldName) > 0) then
|
|
|
SetTextErrorHint('该清单有子计算项,不能直接修改!')
|
|
|
else if (Pos('Price', AColumn.FieldName) > 0) then
|
|
|
SetTextErrorHint('仅最底层清单可输入单价!');
|
|
|
+ if not Allow then Exit;
|
|
|
end
|
|
|
else
|
|
|
- if (Pos('TotalPrice', AColumn.FieldName) > 0) and
|
|
|
- (vNode.Rec.ValueByName('Price').AsFloat <> 0) then
|
|
|
- SetTextErrorHint('不可直接输入!如需直接输入金额,请先删除清单单价!');
|
|
|
- if not Allow then Exit;
|
|
|
+ begin
|
|
|
+ if SameText('OrgTotalPrice', AColumn.FieldName) or
|
|
|
+ SameText('MisTotalPrice', AColumn.FieldName) or
|
|
|
+ SameText('OthTotalPrice', AColumn.FieldName) then
|
|
|
+ begin
|
|
|
+ if not vNode.TotalPriceEnable then
|
|
|
+ SetTextErrorHint('该清单不可直接输入金额,如需直接输入金额,请先清空所有数量、单价!');
|
|
|
+ end;
|
|
|
+ if not Allow then Exit;
|
|
|
+
|
|
|
+ if SameText('Price', AColumn.FieldName) or
|
|
|
+ SameText('OrgQuantity', AColumn.FieldName) or
|
|
|
+ SameText('MisQuantity', AColumn.FieldName) or
|
|
|
+ SameText('OthQuantity', AColumn.FieldName) then
|
|
|
+ begin
|
|
|
+ if not vNode.CountPriceEnable then
|
|
|
+ SetTextErrorHint('该清单不可输入数量单价,如需使用数量×单价计算,请先清空所有直接输入的金额!');
|
|
|
+ end;
|
|
|
+ if not Allow then Exit;
|
|
|
+ end;
|
|
|
|
|
|
if SameText('Code', AColumn.FieldName) or
|
|
|
SameText('B_Code', AColumn.FieldName) or
|
|
@@ -614,6 +687,8 @@ begin
|
|
|
if AValue.AsString = Text then Exit;
|
|
|
|
|
|
CheckLockedData;
|
|
|
+ if not Allow then Exit;
|
|
|
+
|
|
|
CheckNodeWritable;
|
|
|
if not Allow then Exit;
|
|
|
|
|
@@ -738,7 +813,6 @@ end;
|
|
|
procedure TBillsCompileData.CalculateMis(ABillsID: Integer);
|
|
|
var
|
|
|
vNode: TBillsIDTreeNode;
|
|
|
- fTotalPrice: Double;
|
|
|
iChild: Integer;
|
|
|
begin
|
|
|
vNode := TBillsIDTreeNode(BillsCompileTree.FindNode(ABillsID));
|
|
@@ -753,11 +827,14 @@ begin
|
|
|
begin
|
|
|
with vNode.Rec do
|
|
|
begin
|
|
|
- fTotalPrice := TotalPriceRoundTo(MisQuantity.AsFloat * Price.AsFloat);
|
|
|
- if MisTotalPrice.AsFloat <> fTotalPrice then
|
|
|
+ // 数量单价模式则计算金额
|
|
|
+ if CalcType.AsInteger = 0 then
|
|
|
+ MisTotalPrice.AsFloat := TotalPriceRoundTo(MisQuantity.AsFloat * Price.AsFloat);
|
|
|
+
|
|
|
+ // 金额与修改前不一样,则向父项增量
|
|
|
+ if MisTotalPrice.AsFloat <> CacheMisTP then
|
|
|
begin
|
|
|
- UpdateParent(vNode.ParentID, fTotalPrice - MisTotalPrice.AsFloat, 'MisTotalPrice');
|
|
|
- MisTotalPrice.AsFloat := fTotalPrice;
|
|
|
+ UpdateParent(vNode.ParentID, MisTotalPrice.AsFloat - CacheMisTP, 'MisTotalPrice');
|
|
|
Quantity.AsFloat := QuantityRoundTo(
|
|
|
OrgQuantity.AsFloat + MisQuantity.AsFloat + OthQuantity.AsFloat);
|
|
|
TotalPrice.AsFloat := TotalPriceRoundTo(
|
|
@@ -766,17 +843,12 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
- if vNode.Rec.DgnQuantity1.AsFloat <> 0 then
|
|
|
- vNode.Rec.DgnPrice.AsFloat := PriceRoundTo(
|
|
|
- vNode.Rec.TotalPrice.AsFloat/vNode.Rec.DgnQuantity1.AsFloat)
|
|
|
- else
|
|
|
- vNode.Rec.DgnPrice.AsFloat := 0;
|
|
|
+ CalculateDesignPrice(vNode);
|
|
|
end;
|
|
|
|
|
|
procedure TBillsCompileData.CalculateOrg(ABillsID: Integer);
|
|
|
var
|
|
|
vNode: TBillsIDTreeNode;
|
|
|
- fTotalPrice: Double;
|
|
|
iChild: Integer;
|
|
|
begin
|
|
|
vNode := TBillsIDTreeNode(BillsCompileTree.FindNode(ABillsID));
|
|
@@ -791,11 +863,14 @@ begin
|
|
|
begin
|
|
|
with vNode.Rec do
|
|
|
begin
|
|
|
- fTotalPrice := TotalPriceRoundTo(OrgQuantity.AsFloat * Price.AsFloat);
|
|
|
- if OrgTotalPrice.AsFloat <> fTotalPrice then
|
|
|
+ // 数量单价模式则计算金额
|
|
|
+ if CalcType.AsInteger = 0 then
|
|
|
+ OrgTotalPrice.AsFloat := TotalPriceRoundTo(OrgQuantity.AsFloat * Price.AsFloat);
|
|
|
+
|
|
|
+ // 金额与修改前不一样,则向父项增量
|
|
|
+ if CacheOrgTP <> OrgTotalPrice.AsFloat then
|
|
|
begin
|
|
|
- UpdateParent(vNode.ParentID, fTotalPrice - OrgTotalPrice.AsFloat, 'OrgTotalPrice');
|
|
|
- OrgTotalPrice.AsFloat := fTotalPrice;
|
|
|
+ UpdateParent(vNode.ParentID, OrgTotalPrice.AsFloat - CacheOrgTP, 'OrgTotalPrice');
|
|
|
Quantity.AsFloat := QuantityRoundTo(
|
|
|
OrgQuantity.AsFloat + MisQuantity.AsFloat + OthQuantity.AsFloat);
|
|
|
TotalPrice.AsFloat := TotalPriceRoundTo(
|
|
@@ -804,17 +879,12 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
- if vNode.Rec.DgnQuantity1.AsFloat <> 0 then
|
|
|
- vNode.Rec.DgnPrice.AsFloat := PriceRoundTo(
|
|
|
- vNode.Rec.TotalPrice.AsFloat/vNode.Rec.DgnQuantity1.AsFloat)
|
|
|
- else
|
|
|
- vNode.Rec.DgnPrice.AsFloat := 0;
|
|
|
+ CalculateDesignPrice(vNode);
|
|
|
end;
|
|
|
|
|
|
procedure TBillsCompileData.CalculateOth(ABillsID: Integer);
|
|
|
var
|
|
|
vNode: TBillsIDTreeNode;
|
|
|
- fTotalPrice: Double;
|
|
|
iChild: Integer;
|
|
|
begin
|
|
|
vNode := TBillsIDTreeNode(BillsCompileTree.FindNode(ABillsID));
|
|
@@ -829,11 +899,14 @@ begin
|
|
|
begin
|
|
|
with vNode.Rec do
|
|
|
begin
|
|
|
- fTotalPrice := TotalPriceRoundTo(OthQuantity.AsFloat * Price.AsFloat);
|
|
|
- if OthTotalPrice.AsFloat <> fTotalPrice then
|
|
|
+ // 数量单价模式则计算金额
|
|
|
+ if CalcType.AsInteger = 0 then
|
|
|
+ OthTotalPrice.AsFloat := TotalPriceRoundTo(OthQuantity.AsFloat * Price.AsFloat);
|
|
|
+
|
|
|
+ // 金额与修改前不一样,则向父项增量
|
|
|
+ if OthTotalPrice.AsFloat <> CacheOthTP then
|
|
|
begin
|
|
|
- UpdateParent(vNode.ParentID, fTotalPrice - OthTotalPrice.AsFloat, 'OthTotalPrice');
|
|
|
- OthTotalPrice.AsFloat := fTotalPrice;
|
|
|
+ UpdateParent(vNode.ParentID, OthTotalPrice.AsFloat - CacheOthTP, 'OthTotalPrice');
|
|
|
Quantity.AsFloat := QuantityRoundTo(
|
|
|
OrgQuantity.AsFloat + MisQuantity.AsFloat + OthQuantity.AsFloat);
|
|
|
TotalPrice.AsFloat := TotalPriceRoundTo(
|
|
@@ -842,11 +915,7 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
- if vNode.Rec.DgnQuantity1.AsFloat <> 0 then
|
|
|
- vNode.Rec.DgnPrice.AsFloat := PriceRoundTo(
|
|
|
- vNode.Rec.TotalPrice.AsFloat/vNode.Rec.DgnQuantity1.AsFloat)
|
|
|
- else
|
|
|
- vNode.Rec.DgnPrice.AsFloat := 0;
|
|
|
+ CalculateDesignPrice(vNode);
|
|
|
end;
|
|
|
|
|
|
function TBillsCompileData.GatherChildren(ANode: TsdIDTreeNode;
|
|
@@ -882,9 +951,8 @@ begin
|
|
|
ValueByName(AFieldName).AsFloat := TotalPriceRoundTo(
|
|
|
ValueByName(AFieldName).AsFloat + ADifferTotalPrice);
|
|
|
TotalPrice.AsFloat := TotalPriceRoundTo(TotalPrice.AsFloat + ADifferTotalPrice);
|
|
|
- if DgnQuantity1.AsFloat <> 0 then
|
|
|
- DgnPrice.AsFloat := PriceRoundTo(TotalPrice.AsFloat/DgnQuantity1.AsFloat);
|
|
|
end;
|
|
|
+ CalculateDesignPrice(vNode);
|
|
|
UpdateParent(vNode.ParentID, ADifferTotalPrice, AFieldName);
|
|
|
end;
|
|
|
|
|
@@ -918,18 +986,19 @@ begin
|
|
|
with ANode.Rec do
|
|
|
begin
|
|
|
// 分项
|
|
|
- OrgTotalPrice.AsFloat := TotalPriceRoundTo(Price.AsFloat * OrgQuantity.AsFloat);
|
|
|
- MisTotalPrice.AsFloat := TotalPriceRoundTo(Price.AsFloat * MisQuantity.AsFloat);
|
|
|
- OthTotalPrice.AsFloat := TotalPriceRoundTo(Price.AsFloat * OthQuantity.AsFloat);
|
|
|
+ if CalcType.AsFloat = 0 then
|
|
|
+ begin
|
|
|
+ OrgTotalPrice.AsFloat := TotalPriceRoundTo(Price.AsFloat * OrgQuantity.AsFloat);
|
|
|
+ MisTotalPrice.AsFloat := TotalPriceRoundTo(Price.AsFloat * MisQuantity.AsFloat);
|
|
|
+ OthTotalPrice.AsFloat := TotalPriceRoundTo(Price.AsFloat * OthQuantity.AsFloat);
|
|
|
+ end;
|
|
|
// 汇总
|
|
|
Quantity.AsFloat := QuantityRoundTo(
|
|
|
OrgQuantity.AsFloat + MisQuantity.AsFloat + OthQuantity.AsFloat);
|
|
|
TotalPrice.AsFloat := TotalPriceRoundTo(
|
|
|
OrgTotalPrice.AsFloat + MisTotalPrice.AsFloat + OthTotalPrice.AsFloat);
|
|
|
- // 经济指标
|
|
|
- if DgnQuantity1.AsFloat <> 0 then
|
|
|
- DgnPrice.AsFloat := PriceRoundTo(TotalPrice.AsFloat/DgnQuantity1.AsFloat);
|
|
|
end;
|
|
|
+ CalculateDesignPrice(ANode);
|
|
|
end;
|
|
|
|
|
|
procedure TBillsCompileData.GatherNode(ANode: TBillsIDTreeNode);
|
|
@@ -953,9 +1022,7 @@ begin
|
|
|
ANode.Rec.OthTotalPrice.AsFloat := TotalPriceRoundTo(fOth);
|
|
|
ANode.Rec.TotalPrice.AsFloat := TotalPriceRoundTo(fOrg + fMis + fOth);
|
|
|
|
|
|
- if ANode.Rec.DgnQuantity1.AsFloat <> 0 then
|
|
|
- ANode.Rec.DgnPrice.AsFloat := PriceRoundTo(
|
|
|
- ANode.Rec.TotalPrice.AsFloat/ANode.Rec.DgnQuantity1.AsFloat);
|
|
|
+ CalculateDesignPrice(ANode);
|
|
|
end;
|
|
|
|
|
|
procedure TBillsCompileData.Calculate(ABillsID: Integer);
|
|
@@ -999,4 +1066,13 @@ begin
|
|
|
UpdateParent(TBillsIDTreeNode(vNode.Parent), fOrg, fMis, fOth);
|
|
|
end;
|
|
|
|
|
|
+procedure TBillsCompileData.CalculateDesignPrice(ANode: TBillsIDTreeNode);
|
|
|
+begin
|
|
|
+ if ANode.Rec.DgnQuantity1.AsFloat <> 0 then
|
|
|
+ ANode.Rec.DgnPrice.AsFloat := PriceRoundTo(
|
|
|
+ ANode.Rec.TotalPrice.AsFloat/ANode.Rec.DgnQuantity1.AsFloat)
|
|
|
+ else
|
|
|
+ ANode.Rec.DgnPrice.Clear;
|
|
|
+end;
|
|
|
+
|
|
|
end.
|