浏览代码

哈白定制表,金额调整

MaiXinRong 9 年之前
父节点
当前提交
8db7c1b20b
共有 1 个文件被更改,包括 37 次插入6 次删除
  1. 37 6
      DataModules/ReportMemoryDm/rmHaBaiCustomizedDm.pas

+ 37 - 6
DataModules/ReportMemoryDm/rmHaBaiCustomizedDm.pas

@@ -15,6 +15,8 @@ type
 
   TGclNode = class
   private
+    FProjectCount: Integer;
+
     FB_Code: string;
     FIndexCode: string;
     FName: string;
@@ -46,6 +48,8 @@ type
   public
     constructor Create(AProjectCount: Integer);
 
+    procedure Calculate;
+
     property B_Code: string read FB_Code write SetB_Code;
     property IndexCode: string read FIndexCode;
     property Name: string read FName write FName;
@@ -154,6 +158,7 @@ type
 
     function AddGclNode(ANode: TBillsIDTreeNode; AProjectIndex: Integer): TGclNode;
 
+    procedure ReCalculateTotalPrice;
     procedure Calculate;
 
     property GclChapterCount: Integer read GetGclChapterCount;
@@ -319,6 +324,7 @@ begin
   try
     for iProject := 0 to AProjects.Count - 1 do
       GatherProject(TSelectProject(AProjects.Items[iProject]), iProject);
+    FGclControl.ReCalculateTotalPrice;
     FGclControl.Calculate;
     WriteData;
   finally
@@ -822,14 +828,31 @@ end;
 
 { TGclNode }
 
+procedure TGclNode.Calculate;
+var
+  i: Integer;
+begin
+  FTotalPrice := FPrice * FQuantity;
+  FCurGatherTotalPrice := FPrice * FCurGatherQuantity;
+  FEndGatherTotalPrice := FPrice * FEndGatherTotalPrice;
+  FPreGatherTotalPrice := FPrice * FPreGatherTotalPrice;
+  for i := 0 to FProjectCount - 1 do
+  begin
+    FP_TotalPrice[i] := FPrice * FP_Quantity[i];
+    FP_CurGatherTotalPrice[i] := FPrice * FP_CurGatherQuantity[i];
+    FP_EndGatherTotalPrice[i] := FPrice * FP_EndGatherQuantity[i];
+  end;
+end;
+
 constructor TGclNode.Create(AProjectCount: Integer);
 begin
-  SetLength(FP_Quantity, AProjectCount);
-  SetLength(FP_TotalPrice, AProjectCount);
-  SetLength(FP_CurGatherQuantity, AProjectCount);
-  SetLength(FP_CurGatherTotalPrice, AProjectCount);
-  SetLength(FP_EndGatherQuantity, AProjectCount);
-  SetLength(FP_EndGatherTotalPrice, AProjectCount);
+  FProjectCount := AProjectCount;
+  SetLength(FP_Quantity, FProjectCount);
+  SetLength(FP_TotalPrice, FProjectCount);
+  SetLength(FP_CurGatherQuantity, FProjectCount);
+  SetLength(FP_CurGatherTotalPrice, FProjectCount);
+  SetLength(FP_EndGatherQuantity, FProjectCount);
+  SetLength(FP_EndGatherTotalPrice, FProjectCount);
 end;
 
 function TGclNode.GetCurPercent: Double;
@@ -1060,6 +1083,14 @@ begin
   CalculateChapterGather;
 end;
 
+procedure TGclControl.ReCalculateTotalPrice;
+var
+  iGcl: Integer;
+begin
+  for iGcl := 0 to FGclNodes.Count - 1 do
+    TGclNode(FGclNodes[iGcl]).Calculate;
+end;
+
 { TGclChapter }
 
 procedure TGclChapter.AddGclNode(AGclNode: TGclNode);