|  | @@ -3,13 +3,13 @@ unit rpgGatherControl;
 | 
	
		
			
				|  |  |  interface
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  uses
 | 
	
		
			
				|  |  | -  Classes, rpgGatherData, ADODB, ReportManager;
 | 
	
		
			
				|  |  | +  Classes, rpgGatherData, ADODB, ReportManager, ProjectData;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  type
 | 
	
		
			
				|  |  |    TrpgGatherControl = class
 | 
	
		
			
				|  |  |    private
 | 
	
		
			
				|  |  |      // 当前打开项目,根据其筛选项目
 | 
	
		
			
				|  |  | -    FProjectID: Integer;
 | 
	
		
			
				|  |  | +    FProjectData: TProjectData;
 | 
	
		
			
				|  |  |      // 当前汇总的报表 -- 主要用于读取报表中的附加信息
 | 
	
		
			
				|  |  |      FTemplate: TTemplateNode;
 | 
	
		
			
				|  |  |      FHistroyProjs: TList;
 | 
	
	
		
			
				|  | @@ -21,9 +21,12 @@ type
 | 
	
		
			
				|  |  |      function SelectProject: Boolean;
 | 
	
		
			
				|  |  |      function SameSelect: Boolean;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    procedure CopyTables(const AFileName, ATableName: string);
 | 
	
		
			
				|  |  | +    procedure CopyRelaData;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      procedure RefreshGather;
 | 
	
		
			
				|  |  |    public
 | 
	
		
			
				|  |  | -    constructor Create(AProjectID: Integer);
 | 
	
		
			
				|  |  | +    constructor Create(AProjectData: TProjectData);
 | 
	
		
			
				|  |  |      destructor Destroy; override;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      function RefreshConnection(ATemplate: TTemplateNode): TADOConnection;
 | 
	
	
		
			
				|  | @@ -33,16 +36,17 @@ implementation
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  uses
 | 
	
		
			
				|  |  |    ZhAPI, GatherProjInfo, ProjGather, ProjGatherSelectFrm, Globals, Forms,
 | 
	
		
			
				|  |  | -  Controls;
 | 
	
		
			
				|  |  | +  Controls, UtilMethods, SysUtils;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  { TrpgGatherControl }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -constructor TrpgGatherControl.Create(AProjectID: Integer);
 | 
	
		
			
				|  |  | +constructor TrpgGatherControl.Create(AProjectData: TProjectData);
 | 
	
		
			
				|  |  |  begin
 | 
	
		
			
				|  |  | -  FProjectID := AProjectID;
 | 
	
		
			
				|  |  | +  FProjectData := AProjectData;
 | 
	
		
			
				|  |  |    FHistroyProjs := TList.Create;
 | 
	
		
			
				|  |  |    FSelectProjs := TList.Create;
 | 
	
		
			
				|  |  |    FGatherData := TrpgGatherData.Create;
 | 
	
		
			
				|  |  | +  CopyRelaData;
 | 
	
		
			
				|  |  |  end;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  destructor TrpgGatherControl.Destroy;
 | 
	
	
		
			
				|  | @@ -54,6 +58,20 @@ begin
 | 
	
		
			
				|  |  |    inherited;
 | 
	
		
			
				|  |  |  end;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +procedure TrpgGatherControl.CopyRelaData;
 | 
	
		
			
				|  |  | +var
 | 
	
		
			
				|  |  | +  sTempFile: string;
 | 
	
		
			
				|  |  | +begin
 | 
	
		
			
				|  |  | +  sTempFile := GetTempFileName;
 | 
	
		
			
				|  |  | +  try
 | 
	
		
			
				|  |  | +    FProjectData.SaveTempDataBaseFile(sTempFile);
 | 
	
		
			
				|  |  | +    CopyTables(sTempFile, 'ProjProperties');
 | 
	
		
			
				|  |  | +  finally
 | 
	
		
			
				|  |  | +    if FileExists(sTempFile) then
 | 
	
		
			
				|  |  | +      DeleteFile(sTempFile);
 | 
	
		
			
				|  |  | +  end;
 | 
	
		
			
				|  |  | +end;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  function TrpgGatherControl.RefreshConnection(ATemplate: TTemplateNode): TADOConnection;
 | 
	
		
			
				|  |  |  begin
 | 
	
		
			
				|  |  |    FTemplate := ATemplate;
 | 
	
	
		
			
				|  | @@ -79,7 +97,7 @@ begin
 | 
	
		
			
				|  |  |        Gather.Gather(FSelectProjs, FTemplate.InteractInfo.SpecialProjGatherTypes)
 | 
	
		
			
				|  |  |      else
 | 
	
		
			
				|  |  |        Gather.Gather(FSelectProjs, nil);
 | 
	
		
			
				|  |  | -    FGatherData.LoadRelaData(FProjectID);
 | 
	
		
			
				|  |  | +    FGatherData.LoadRelaData(FProjectData.ProjectID);
 | 
	
		
			
				|  |  |      ClearObjects(FHistroyProjs);
 | 
	
		
			
				|  |  |      FHistroyProjs.Assign(FSelectProjs);
 | 
	
		
			
				|  |  |    finally
 | 
	
	
		
			
				|  | @@ -132,9 +150,28 @@ end;
 | 
	
		
			
				|  |  |  function TrpgGatherControl.SelectProject: Boolean;
 | 
	
		
			
				|  |  |  begin
 | 
	
		
			
				|  |  |    if FTemplate.IsExtra then
 | 
	
		
			
				|  |  | -    Result := SelectGatherProject(FProjectID, FHistroyProjs, FSelectProjs, FTemplate.InteractInfo.SpecialProjGatherTypes)
 | 
	
		
			
				|  |  | +    Result := SelectGatherProject(FProjectData.ProjectID, FHistroyProjs, FSelectProjs, FTemplate.InteractInfo.SpecialProjGatherTypes)
 | 
	
		
			
				|  |  |    else
 | 
	
		
			
				|  |  | -    Result := SelectGatherProject(FProjectID, FHistroyProjs, FSelectProjs);
 | 
	
		
			
				|  |  | +    Result := SelectGatherProject(FProjectData.ProjectID, FHistroyProjs, FSelectProjs);
 | 
	
		
			
				|  |  | +end;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +procedure TrpgGatherControl.CopyTables(const AFileName,
 | 
	
		
			
				|  |  | +  ATableName: string);
 | 
	
		
			
				|  |  | +const
 | 
	
		
			
				|  |  | +  sCopySql = 'Select * Into %s' +
 | 
	
		
			
				|  |  | +             '  From %s In ''%s''';
 | 
	
		
			
				|  |  | +var
 | 
	
		
			
				|  |  | +  vQuery: TADOQuery;
 | 
	
		
			
				|  |  | +begin
 | 
	
		
			
				|  |  | +  vQuery := TADOQuery.Create(nil);
 | 
	
		
			
				|  |  | +  try
 | 
	
		
			
				|  |  | +    vQuery.Connection := FGatherData.Connection;
 | 
	
		
			
				|  |  | +    vQuery.SQL.Clear;
 | 
	
		
			
				|  |  | +    vQuery.SQL.Add(Format(sCopySql, [ATableName, ATableName, AFileName]));
 | 
	
		
			
				|  |  | +    vQuery.ExecSQL;
 | 
	
		
			
				|  |  | +  finally
 | 
	
		
			
				|  |  | +    vQuery.Free;
 | 
	
		
			
				|  |  | +  end;
 | 
	
		
			
				|  |  |  end;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  end.
 |