Quellcode durchsuchen

北绕城,变更清单汇总表

MaiXinRong vor 6 Jahren
Ursprung
Commit
5a06f87318

+ 84 - 0
DataModules/ReportMemoryDm/rmBGBillsGatherDm.dfm

@@ -0,0 +1,84 @@
+object rmBGBillsGatherData: TrmBGBillsGatherData
+  OldCreateOrder = False
+  Left = 864
+  Top = 318
+  Height = 150
+  Width = 215
+  object cdsBGBills: TClientDataSet
+    Active = True
+    Aggregates = <>
+    IndexFieldNames = 'TenderID;PartID;BGLCode;IndexCode'
+    Params = <>
+    Left = 48
+    Top = 40
+    Data = {
+      820100009619E0BD01000000180000001100000000000300000082010854656E
+      6465724944040001000000000006506172744944040001000000000009496E64
+      6578436F646501004A000000010005574944544802000200640006425F436F64
+      6501004A0000000100055749445448020002006400044E616D6502004A000000
+      010005574944544802000200FE0105556E69747301004A000000010005574944
+      54480200020028000550726963650800040000000000085175616E7469747908
+      000400000000000A546F74616C507269636508000400000000000B4375725175
+      616E7469747908000400000000000D437572546F74616C507269636508000400
+      000000000B5072655175616E7469747908000400000000000D507265546F7461
+      6C507269636508000400000000000B456E645175616E74697479080004000000
+      00000D456E64546F74616C507269636508000400000000000750657263656E74
+      08000400000000000742474C436F646502004A00000001000557494454480200
+      0200FE010000}
+    object cdsBGBillsTenderID: TIntegerField
+      FieldName = 'TenderID'
+    end
+    object cdsBGBillsPartID: TIntegerField
+      FieldName = 'PartID'
+    end
+    object cdsBGBillsIndexCode: TWideStringField
+      FieldName = 'IndexCode'
+      Size = 50
+    end
+    object cdsBGBillsB_Code: TWideStringField
+      FieldName = 'B_Code'
+      Size = 50
+    end
+    object cdsBGBillsName: TWideStringField
+      FieldName = 'Name'
+      Size = 255
+    end
+    object cdsBGBillsUnits: TWideStringField
+      FieldName = 'Units'
+    end
+    object cdsBGBillsPrice: TFloatField
+      FieldName = 'Price'
+    end
+    object cdsBGBillsQuantity: TFloatField
+      FieldName = 'Quantity'
+    end
+    object cdsBGBillsTotalPrice: TFloatField
+      FieldName = 'TotalPrice'
+    end
+    object cdsBGBillsCurQuantity: TFloatField
+      FieldName = 'CurQuantity'
+    end
+    object cdsBGBillsCurTotalPrice: TFloatField
+      FieldName = 'CurTotalPrice'
+    end
+    object cdsBGBillsPreQuantity: TFloatField
+      FieldName = 'PreQuantity'
+    end
+    object cdsBGBillsPreTotalPrice: TFloatField
+      FieldName = 'PreTotalPrice'
+    end
+    object cdsBGBillsEndQuantity: TFloatField
+      FieldName = 'EndQuantity'
+    end
+    object cdsBGBillsEndTotalPrice: TFloatField
+      FieldName = 'EndTotalPrice'
+    end
+    object cdsBGBillsPercent: TFloatField
+      FieldName = 'Percent'
+    end
+    object cdsBGBillsBGLCode: TWideStringField
+      FieldName = 'BGLCode'
+      Size = 255
+    end
+  end
+end

+ 676 - 0
DataModules/ReportMemoryDm/rmBGBillsGatherDm.pas

@@ -0,0 +1,676 @@
+unit rmBGBillsGatherDm;
+
+interface
+
+uses
+  SysUtils, Classes, DB, DBClient, rmSelectProjectFrm, ProjectData,
+  BillsTree, sdDB;
+
+type
+  TBGBills = class
+  private
+    FIndexCode: string;
+    FB_Code: string;
+    FName: string;
+    FUnits: string;
+    FPrice: Double;
+    FQuantity: Double;
+    FTotalPrice: Double;
+    FCurQuantity: Double;
+    FCurTotalPrice: Double;
+    FPreQuantity: Double;
+    FPreTotalPrice: Double;
+    FEndQuantity:  Double;
+    FEndTotalPrice: Double;
+    procedure SetB_Code(const Value: string);
+    function GetPercent: Double;
+  public
+    procedure Calcualte;
+
+    property B_Code: string read FB_Code write SetB_Code;
+    property IndexCode: string read FIndexCode;
+    property Name: string read FName write FName;
+    property Units: string read FUnits write FUnits;
+    property Price: Double read FPrice write FPrice;
+    property Quantity: Double read FQuantity write FQuantity;
+    property TotalPrice: Double read FTotalPrice write FTotalPrice;
+    property CurQuantity: Double read FCurQuantity write FCurQuantity;
+    property CurTotalPrice: Double read FCurTotalPrice;
+    property PreQuantity: Double read FPreQuantity write FPreQuantity;
+    property PreTotalPrice: Double read FPreTotalPrice;
+    property EndQuantity: Double read FEndQuantity;
+    property EndTotalPrice: Double read FEndTotalPrice;
+    property Percent: Double read GetPercent;
+  end;
+
+  TBGLData = class
+  private
+    FBGLCode: string;
+    FBGBillsList: TList;
+    function GetBGBills(AIndex: Integer): TBGBills;
+    function GetBGBillsCount: Integer;
+  public
+    constructor Create(const ACode: string);
+    destructor Destroy; override;
+
+    function AddBGBills: TBGBills;
+    function FindBGBills(const AB_Code: string): TBGBills;
+
+    procedure Calculate;
+
+    property BGLCode: string read FBGLCode;
+
+    property BGBills[AIndex: Integer]: TBGBills read GetBGBills;
+    property BGBillsCount: Integer read GetBGBillsCount;
+  end;
+
+  TTenderData = class
+  private
+    FSerialNo: Integer;
+    FID: Integer;
+    FName: String;
+    FBGLs: TList;
+
+    FTotalPrice: Double;
+    FCurTotalPrice: Double;
+    FPreTotalPrice: Double;
+    FEndTotalPrice: Double;
+
+    function GetBGLCount: Integer;
+    function GetBGLData(AIndex: Integer): TBGLData;
+    function GetPercent: Double;
+  public
+    constructor Create(ASerialNo, AID: Integer; const AName: string);
+    destructor Destroy; override;
+
+    procedure Calculate;
+    function AddBGL(const ACode: string): TBGLData;
+    function FindBGL(const ACode: string): TBGLData;
+
+    property SerialNo: Integer read FSerialNo;
+    property ID: Integer read FID;
+    property Name: string read FName;
+
+    property BGL[AIndex: Integer]: TBGLData read GetBGLData;
+    property BGLCount: Integer read GetBGLCount;
+
+    property TotalPrice: Double read FTotalPrice;
+    property CurTotalPrice: Double read FCurTotalPrice;
+    property PreTotalPrice: Double read FPreTotalPrice;
+    property EndTotalPrice: Double read FEndTotalPrice;
+    property Percent: Double read GetPercent;
+  end;
+
+  TGatherData = class
+  private
+    FTenders: TList;
+
+    FTotalPrice: Double;
+    FCurTotalPrice: Double;
+    FPreTotalPrice: Double;
+    FEndTotalPrice: Double;
+
+    function GetTender(AIndex: Integer): TTenderData;
+    function GetTenderCount: Integer;
+    function GetPercent: Double;
+  public
+    constructor Create;
+    destructor Destroy; override;
+
+    function AddTender(AIndex, AID: Integer; const AName: string): TTenderData;
+    procedure Calculate;
+
+    property Tender[AIndex: Integer]: TTenderData read GetTender;
+    property TenderCount: Integer read GetTenderCount;
+
+    property TotalPrice: Double read FTotalPrice;
+    property CurTotalPrice: Double read FCurTotalPrice;
+    property PreTotalPrice: Double read FPreTotalPrice;
+    property EndTotalPrice: Double read FEndTotalPrice;
+    property Percent: Double read GetPercent;
+  end;
+
+  TrmBGBillsGatherData = class(TDataModule)
+    cdsBGBills: TClientDataSet;
+    cdsBGBillsTenderID: TIntegerField;
+    cdsBGBillsPartID: TIntegerField;
+    cdsBGBillsIndexCode: TWideStringField;
+    cdsBGBillsB_Code: TWideStringField;
+    cdsBGBillsName: TWideStringField;
+    cdsBGBillsUnits: TWideStringField;
+    cdsBGBillsPrice: TFloatField;
+    cdsBGBillsQuantity: TFloatField;
+    cdsBGBillsTotalPrice: TFloatField;
+    cdsBGBillsCurQuantity: TFloatField;
+    cdsBGBillsCurTotalPrice: TFloatField;
+    cdsBGBillsPreQuantity: TFloatField;
+    cdsBGBillsPreTotalPrice: TFloatField;
+    cdsBGBillsEndQuantity: TFloatField;
+    cdsBGBillsEndTotalPrice: TFloatField;
+    cdsBGBillsPercent: TFloatField;
+    cdsBGBillsBGLCode: TWideStringField;
+  private
+    FGatherData: TGatherData;
+    FProjectName: string;
+    FProjectData: TProjectData;
+
+    procedure BeforeGather;
+    procedure AfterGather;
+
+    procedure OpenProjectData(AProject: TSelectProject; AProjectIndex: Integer);
+    procedure FreeProjectData;
+
+    procedure GatherBGBills(ABGL: TBGLData; ABGLID: Integer);
+    procedure GatherBGL(ATenderData: TTenderData);
+    procedure GatherMeasureData(ATenderData: TTenderData);
+    procedure GatherProject(AProject: TSelectProject; AProjectIndex: Integer);
+
+    procedure CalculateGatherData;
+
+    procedure WriteData;
+  public
+    function AssignData(AProjects: TList): TDataSet;
+  end;
+
+implementation
+
+uses
+  ZhAPI, UtilMethods, DateUtils, Globals, BGLDm, mDataRecord;
+
+{$R *.dfm}
+
+{ TGatherData }
+
+function TGatherData.AddTender(AIndex, AID: Integer;
+  const AName: string): TTenderData;
+begin
+  Result := TTenderData.Create(AIndex, AID, AName);
+  FTenders.Add(Result);
+end;
+
+procedure TGatherData.Calculate;
+var
+  i: Integer;
+begin
+  FTotalPrice := 0;
+  FCurTotalPrice := 0;
+  FPreTotalPrice := 0;
+  FEndTotalPrice := 0;
+  for i := 0 to TenderCount - 1 do
+  begin
+    Tender[i].Calculate;
+    FTotalPrice := FTotalPrice + Tender[i].TotalPrice;
+    FCurTotalPrice := FCurTotalPrice + Tender[i].CurTotalPrice;
+    FPreTotalPrice := FPreTotalPrice + Tender[i].PreTotalPrice;
+    FEndTotalPrice := FEndTotalPrice + Tender[i].EndTotalPrice;
+  end;
+end;
+
+constructor TGatherData.Create;
+begin
+  FTenders := TList.Create;
+end;
+
+destructor TGatherData.Destroy;
+begin
+  ClearObjects(FTenders);
+  FTenders.Free;
+  inherited;
+end;
+
+function TGatherData.GetPercent: Double;
+begin
+  if FTotalPrice <> 0 then
+    Result := CommonRoundTo(FEndTotalPrice / FTotalPrice * 100, -2)
+  else
+    Result := 0;
+end;
+
+function TGatherData.GetTender(AIndex: Integer): TTenderData;
+begin
+  Result := TTenderData(FTenders[AIndex]);
+end;
+
+function TGatherData.GetTenderCount: Integer;
+begin
+  Result := FTenders.Count;
+end;
+
+{ TTenderData }
+
+function TTenderData.AddBGL(const ACode: string): TBGLData;
+begin
+  Result := TBGLData.Create(ACode);
+  FBGLs.Add(Result);
+end;
+
+procedure TTenderData.Calculate;
+var
+  i, j: Integer;
+  vBGL: TBGLData;
+begin
+  FTotalPrice := 0;
+  FPreTotalPrice := 0;
+  FCurTotalPrice := 0;
+  FEndTotalPrice := 0;
+  for i := 0 to BGLCount - 1 do
+  begin
+    vBGL := BGL[i];
+    vBGL.Calculate;
+    for j := 0 to vBGL.BGBillsCount - 1 do
+    begin
+      FTotalPrice := FTotalPrice + vBGL.BGBills[j].TotalPrice;
+      FCurTotalPrice := FCurTotalPrice + vBGL.BGBills[j].CurTotalPrice;
+      FPreTotalPrice := FPreTotalPrice + vBGL.BGBills[j].PreTotalPrice;
+      FEndTotalPrice := FEndTotalPrice + vBGL.BGBills[j].EndTotalPrice;
+    end;
+  end;
+end;
+
+constructor TTenderData.Create(ASerialNo, AID: Integer; const AName: string);
+begin
+  FSerialNo := ASerialNo;
+  FID := AID;
+  FName := AName;
+  FBGLs := TList.Create;
+end;
+
+destructor TTenderData.Destroy;
+begin
+  ClearObjects(FBGLs);
+  FBGLs.Free;
+  inherited;
+end;
+
+function TTenderData.FindBGL(const ACode: string): TBGLData;
+var
+  i: Integer;
+begin
+  Result := nil;
+  for i := 0 to BGLCount - 1 do
+  begin
+    if (ACode = BGL[i].BGLCode) then
+    begin
+      Result := BGL[i];
+      Break;
+    end;
+  end;
+end;
+
+function TTenderData.GetBGLCount: Integer;
+begin
+  Result := FBGLs.Count;
+end;
+
+function TTenderData.GetBGLData(AIndex: Integer): TBGLData;
+begin
+  Result := TBGLData(FBGLs[AIndex]);
+end;
+
+function TTenderData.GetPercent: Double;
+begin
+  if FTotalPrice <> 0 then
+    Result := CommonRoundTo(FEndTotalPrice / FTotalPrice * 100, -2)
+  else
+    Result := 0;
+end;
+
+{ TBGLData }
+
+function TBGLData.AddBGBills: TBGBills;
+begin
+  Result := TBGBills.Create;
+  FBGBillsList.Add(Result);
+end;
+
+procedure TBGLData.Calculate;
+var
+  i: Integer;
+begin
+  for i := 0 to BGBillsCount - 1 do
+    BGBills[i].Calcualte;
+end;
+
+constructor TBGLData.Create(const ACode: string);
+begin
+  FBGLCode := ACode;
+  FBGBillsList := TList.Create;
+end;
+
+destructor TBGLData.Destroy;
+begin
+  ClearObjects(FBGBillsList);
+  FBGBillsList.Free;
+  inherited;
+end;
+
+function TBGLData.FindBGBills(const AB_Code: string): TBGBills;
+var
+  i: Integer;
+begin
+  Result := nil;
+  for i := 0 to BGBillsCount - 1 do
+  begin
+    if (AB_Code = BGBills[i].B_Code) then
+    begin
+      Result := BGBills[i];
+      Break;
+    end;
+  end;
+end;
+
+function TBGLData.GetBGBills(AIndex: Integer): TBGBills;
+begin
+  Result := TBGBills(FBGBillsList[AIndex]);
+end;
+
+function TBGLData.GetBGBillsCount: Integer;
+begin
+  Result := FBGBillsList.Count;
+end;
+
+{ TrmBGBillsGatherData }
+
+procedure TrmBGBillsGatherData.AfterGather;
+begin
+  cdsBGBills.EnableControls;
+  FGatherData.Free;
+end;
+
+function TrmBGBillsGatherData.AssignData(AProjects: TList): TDataSet;
+var
+  iProject: Integer;
+  SelectProject: TSelectProject;
+begin
+  BeforeGather;
+  try
+    for iProject := 0 to AProjects.Count - 1 do
+      GatherProject(TSelectProject(AProjects.Items[iProject]), iProject);
+    CalculateGatherData;
+    WriteData;
+  finally
+    Result := cdsBGBills;
+    AfterGather;
+  end;
+end;
+
+procedure TrmBGBillsGatherData.BeforeGather;
+begin
+  FGatherData := TGatherData.Create;
+  cdsBGBills.DisableControls;
+  cdsBGBills.Active := True;
+  cdsBGBills.EmptyDataSet;
+end;
+
+procedure TrmBGBillsGatherData.CalculateGatherData;
+begin
+  FGatherData.Calculate;
+end;
+
+procedure TrmBGBillsGatherData.FreeProjectData;
+begin
+  if not Assigned(OpenProjectManager.FindProjectData(FProjectData.ProjectID)) then
+    FProjectData.Free;
+end;
+
+procedure TrmBGBillsGatherData.GatherBGBills(ABGL: TBGLData;
+  ABGLID: Integer);
+var
+  vBGBills: TBGBills;
+begin
+  with FProjectData.BGLData do
+  begin
+    cdsBGBills.Filter := 'BGID = ' + IntToStr(ABGLID);
+    cdsBGBills.Filtered := True;
+    try
+      cdsBGBills.First;
+      while not cdsBGBills.Eof do
+      begin
+        vBGBills := ABGL.AddBGBills;
+        vBGBills.B_Code := cdsBGBillsB_Code.AsString;
+        vBGBills.Name := cdsBGBillsName.AsString;
+        vBGBills.Units := cdsBGBillsUnits.AsString;
+        vBGBills.Price := cdsBGBillsPrice.AsFloat;
+        vBGBills.Quantity := cdsBGBillsQuantity.AsFloat;
+        vBGBills.TotalPrice := cdsBGBillsTotalPrice.AsFloat;
+        cdsBGBills.Next;
+      end;
+    finally
+      cdsBGBills.Filtered := False;
+    end;
+  end;
+end;
+
+procedure TrmBGBillsGatherData.GatherBGL(ATenderData: TTenderData);
+var
+  vBGL: TBGLData;
+begin
+  with FProjectData.BGLData do
+  begin
+    cdsBGL.First;
+    while not cdsBGL.Eof do
+    begin
+      vBGL := ATenderData.AddBGL(cdsBGLCode.AsString);
+      GatherBGBills(vBGL, cdsBGLID.AsInteger);
+      cdsBGL.Next;
+    end;
+  end;
+end;
+
+procedure TrmBGBillsGatherData.GatherMeasureData(ATenderData: TTenderData);
+
+  procedure GatherCur(ANode: TMeasureBillsIDTreeNode);
+  var
+    sgsCode, sgsNum: TStrings;
+    i: Integer;
+    sCode: string;
+    fNumber: Double;
+    vBGL: TBGLData;
+    vBGBills: TBGBills;
+  begin
+    sgsCode := TStringList.Create;
+    sgsNum := TStringList.Create;
+    try
+      sgsCode.Delimiter := ';';
+      sgsNum.Delimiter := ';';
+      sgsCode.DelimitedText := ANode.StageRec.QcBGLCode.AsString;
+      sgsNum.DelimitedText := ANode.StageRec.QcBGLNum.AsString;
+      for i := 0 to sgsCode.Count - 1 do
+      begin
+        sCode := sgsCode[i];
+        fNumber := StrToFloatDef(sgsNum[i], 0);
+        vBGL := ATenderData.FindBGL(sCode);
+        if Assigned(vBGL) then
+        begin
+          vBGBills := vBGL.FindBGBills(ANode.Rec.B_Code.AsString);
+          if Assigned(vBGBills) then
+            vBGBills.CurQuantity := vBGBills.CurQuantity + fNumber;
+        end;
+      end;
+    finally
+      sgsCode.Free;
+      sgsNum.Free;
+    end;
+  end;
+
+  procedure GatherPre(ANode: TMeasureBillsIDTreeNode);
+  var
+    sgsCode, sgsNum: TStrings;
+    i: Integer;
+    sCode: string;
+    fNumber: Double;
+    vBGL: TBGLData;
+    vBGBills: TBGBills;
+  begin
+    sgsCode := TStringList.Create;
+    sgsNum := TStringList.Create;
+    try
+      sgsCode.Delimiter := ';';
+      sgsNum.Delimiter := ';';
+      sgsCode.DelimitedText := ANode.StageRec.PreQcBGLCode.AsString;
+      sgsNum.DelimitedText := ANode.StageRec.PreQcBGLNum.AsString;
+      for i := 0 to sgsCode.Count - 1 do
+      begin
+        sCode := sgsCode[i];
+        fNumber := StrToFloatDef(sgsNum[i], 0);
+        vBGL := ATenderData.FindBGL(sCode);
+        if Assigned(vBGL) then
+        begin
+          vBGBills := vBGL.FindBGBills(ANode.Rec.B_Code.AsString);
+          if Assigned(vBGBills) then
+            vBGBills.PreQuantity := vBGBills.PreQuantity + fNumber;
+        end;
+      end;
+    finally
+      sgsCode.Free;
+      sgsNum.Free;
+    end;
+  end;
+
+var
+  i: Integer;
+  vNode: TMeasureBillsIDTreeNode;
+begin
+  for i := 0 to FProjectData.BillsMeasureData.BillsMeasureTree.Count - 1 do
+  begin
+    vNode := TMeasureBillsIDTreeNode(FProjectData.BillsMeasureData.BillsMeasureTree.Items[i]);
+    if (vNode.HasChildren) or (not Assigned(vNode.StageRec)) then Continue;
+
+    if (vNode.StageRec.QcBGLCode.AsString <> '') then
+      GatherCur(vNode);
+    if (vNode.StageRec.PreQcBGLCode.AsString <> '') then
+      GatherPre(vNode);
+  end;
+end;
+
+procedure TrmBGBillsGatherData.GatherProject(AProject: TSelectProject;
+  AProjectIndex: Integer);
+var
+  vTenderData: TTenderData;
+begin
+  OpenProjectData(AProject, AProjectIndex);
+  try
+    vTenderData := FGatherData.AddTender(AProjectIndex, AProject.ProjectID, FProjectName);
+    GatherBGL(vTenderData);
+    GatherMeasureData(vTenderData);
+  finally
+    FreeProjectData;
+  end;
+end;
+
+procedure TrmBGBillsGatherData.OpenProjectData(AProject: TSelectProject;
+  AProjectIndex: Integer);
+var
+  Rec: TsdDataRecord;
+begin
+  FProjectData := OpenProjectManager.FindProjectData(AProject.ProjectID);
+  Rec := ProjectManager.sddProjectsInfo.FindKey('idxID', AProject.ProjectID);
+  if not Assigned(FProjectData) then
+  begin
+    FProjectData := TProjectData.Create;
+    FProjectData.OpenForReport3(GetMyProjectsFilePath + Rec.ValueByName('FileName').AsString);
+  end;
+  FProjectName := Rec.ValueByName('Name').AsString;
+end;
+
+procedure TrmBGBillsGatherData.WriteData;
+
+  procedure WriteBGLData(ATenderID: Integer; ABGL: TBGLData);
+  var
+    i: Integer;
+    vBills: TBGBills;
+  begin
+    for i := 0 to ABGL.BGBillsCount - 1 do
+    begin
+      vBills := ABGL.BGBills[i];
+      cdsBGBills.Append;
+      cdsBGBillsTenderID.AsInteger := ATenderID;
+      cdsBGBillsPartID.AsInteger := 2;
+      cdsBGBillsIndexCode.AsString := vBills.IndexCode;
+      cdsBGBillsB_Code.AsString := vBills.B_Code;
+      cdsBGBillsName.AsString := vBills.Name;
+      cdsBGBillsUnits.AsString := vBills.Units;
+      cdsBGBillsPrice.AsFloat := vBills.Price;
+      cdsBGBillsQuantity.AsFloat := vBills.Quantity;
+      cdsBGBillsTotalPrice.AsFloat := vBills.TotalPrice;
+      cdsBGBillsCurQuantity.AsFloat := vBills.CurQuantity;
+      cdsBGBillsCurTotalPrice.AsFloat := vBills.CurTotalPrice;
+      cdsBGBillsPreQuantity.AsFloat := vBills.PreQuantity;
+      cdsBGBillsPreTotalPrice.AsFloat := vBills.PreTotalPrice;
+      cdsBGBillsEndQuantity.AsFloat := vBills.EndQuantity;
+      cdsBGBillsEndTotalPrice.AsFloat := vBills.EndTotalPrice;
+      cdsBGBillsPercent.AsFloat := vBills.Percent;
+      cdsBGBillsBGLCode.AsString := ABGL.BGLCode;
+      cdsBGBills.Post;
+    end;
+  end;
+
+  procedure WriteTenderData(ATender: TTenderData);
+  var
+    iBGL: Integer;
+  begin
+    cdsBGBills.Append;
+    cdsBGBillsTenderID.AsInteger := ATender.SerialNo;
+    cdsBGBillsPartID.AsInteger := 1;
+    cdsBGBillsName.AsString := ATender.Name;
+    cdsBGBills.Post;
+    for iBGL := 0 to ATender.BGLCount - 1 do
+      WriteBGLData(ATender.SerialNo, ATender.BGL[iBGL]);
+    cdsBGBills.Append;
+    cdsBGBillsTenderID.AsInteger := ATender.SerialNo;
+    cdsBGBillsPartID.AsInteger := 3;
+    cdsBGBillsName.AsString := 'С¼Æ';
+    cdsBGBillsTotalPrice.AsFloat := ATender.TotalPrice;
+    cdsBGBillsCurTotalPrice.AsFloat := ATender.CurTotalPrice;
+    cdsBGBillsPreTotalPrice.AsFloat := ATender.PreTotalPrice;
+    cdsBGBillsEndTotalPrice.AsFloat := ATender.EndTotalPrice;
+    cdsBGBillsPercent.AsFloat := ATender.Percent;
+    cdsBGBills.Post;
+  end;
+
+  procedure WriteGatherData;
+  begin 
+    cdsBGBills.Append;
+    cdsBGBillsTenderID.AsInteger := FGatherData.TenderCount + 1;
+    cdsBGBillsName.AsString := 'ºÏ¼Æ';
+    cdsBGBillsTotalPrice.AsFloat := FGatherData.TotalPrice;
+    cdsBGBillsCurTotalPrice.AsFloat := FGatherData.CurTotalPrice;
+    cdsBGBillsPreTotalPrice.AsFloat := FGatherData.PreTotalPrice;
+    cdsBGBillsEndTotalPrice.AsFloat := FGatherData.EndTotalPrice;
+    cdsBGBillsPercent.AsFloat := FGatherData.Percent;
+    cdsBGBills.Post;
+  end;
+
+var
+  i: Integer;
+begin
+  for i := 0 to FGatherData.TenderCount - 1 do
+    WriteTenderData(FGatherData.Tender[i]);
+  WriteGatherData;
+end;
+
+{ TBGBills }
+
+procedure TBGBills.Calcualte;
+begin
+  FCurTotalPrice := FCurQuantity * FPrice;
+  FPreTotalPrice := FPreQuantity * FPrice;
+  FEndQuantity := FCurQuantity + FPreQuantity;
+  FEndTotalPrice := FEndQuantity * FPrice;
+end;
+
+function TBGBills.GetPercent: Double;
+begin
+  if FTotalPrice <> 0 then
+    Result := CommonRoundTo(FEndTotalPrice / FTotalPrice * 100, -2)
+  else
+    Result := 0;
+end;
+
+procedure TBGBills.SetB_Code(const Value: string);
+begin
+  FB_Code := Value;
+  FIndexCode := B_CodeToIndexCode(FB_Code);
+end;
+
+end.

+ 8 - 4
Units/ReportManager.pas

@@ -8,7 +8,7 @@ uses
   rmGclBillsAuditCompareDm, rmDealInfosDm, rmXmjBGLDetailDm,
   rmOtherReport1Dm, rmGcl_XmjBillsDm, rmGclBillsPlaneDm,
   rmMentalCustomized1Dm, rmCustomized2Dm, rmHaBaiCustomizedDm,
-  rmWeiWuZjjlGatherDm, rmZhongKaiDm, rmWuJiuZqzfGatherDm,
+  rmWeiWuZjjlGatherDm, rmZhongKaiDm, rmWuJiuZqzfGatherDm, rmBGBillsGatherDm,
   rmTestFrm,
   ReportInteractInfo,
   Classes, ScFileArchiver, IniFiles, Graphics, DB, ProjectData,
@@ -227,6 +227,7 @@ type
     FrmWeiWuZjjlGatherData: TrmWeiWuZjjlGatherData;
     FrmZhongKaiData: TrmZhongKaiData;
     FrmWuJiuZqzfGatherData: TrmWuJiuZqzfGatherData;
+    FrmBGBillsGatherData: TrmBGBillsGatherData;
 
     FMemoryQuery: TADOQuery;
 
@@ -667,6 +668,7 @@ begin
   FrmWeiWuZjjlGatherData := TrmWeiWuZjjlGatherData.Create(nil);
   FrmZhongKaiData := TrmZhongKaiData.Create(nil);
   FrmWuJiuZqzfGatherData := TrmWuJiuZqzfGatherData.Create(nil);
+  FrmBGBillsGatherData := TrmBGBillsGatherData.Create(nil);
 
   FMemoryQuery := TADOQuery.Create(nil);
 
@@ -692,6 +694,7 @@ begin
 
   FMemoryQuery.Free;
 
+  FrmBGBillsGatherData.Free;
   FrmWuJiuZqzfGatherData.Free;
   FrmZhongKaiData.Free;
   FrmWeiWuZjjlGatherData.Free;
@@ -738,7 +741,7 @@ end;
 function TMemoryReportManager.GetMemoryDataSet(
   ADataSetID: Integer; AProjectData: TProjectData): TDataSet;
 begin
-  //ADataSetID := 59;
+  //ADataSetID := 60;
   case ADataSetID of
     1: Result := FrmGridHeaderData.AssginData(AProjectData);   // 各表表头
     2: Result := FrmGclBillsBGData.AssignData(AProjectData, rmtPhaseGather, rmgtGather); // 工程量清单[本期完成]
@@ -759,7 +762,7 @@ begin
        // 内蒙古哈白定制表(支表2, 支表3, 支表14, 支表3-1, 支表4-1, 会签)
        52, 53, 54, 55,
        // 内蒙古306国道定制(支表2, 支表3, 支表3-1, 支表4-1)
-       57, 58:
+       57, 58, 60:
        // 中开高速定制表(支表2, 支表3)
         Result := SelectProjectsAndAssignData(ADataSetID);
     14: Result := FrmGclBillsBGData.AssignData(AProjectData, rmtPhaseDeal, rmgtGather); // 工程量清单[本期合同]
@@ -906,8 +909,9 @@ begin
       53: Result := FrmHaBaiCustomizedData.AssignData(FTenders, hbgt3, False);
       54: Result := FrmHaBaiCustomizedData.AssignData(FTenders, hbgt3_1, False);
       55: Result := FrmHaBaiCustomizedData.AssignData(FTenders, hbgt4_1, False);
-      57: Result := FrmZhongKaiData.AssignData(FTenders, zkgt2);                
+      57: Result := FrmZhongKaiData.AssignData(FTenders, zkgt2);
       58: Result := FrmZhongKaiData.AssignData(FTenders, zkgt3);
+      60: Result := FrmBGBillsGatherData.AssignData(FTenders);
       else Result := FrmBillsGatherData.AssignData(FTenders);
     end;
   end;