unit rpgZoneGatherControl;

interface

uses
  rpgGatherControl, ReportManager, ADODB, ProjectData, rpgGatherData;

type
  TrpgZoneGatherControl = class(TrpgGatherControl)
  private
    FHistoryBeginPhase: Integer;
    FHistoryEndPhase: Integer;
    FBeginPhase: Integer;
    FEndPhase: Integer;
  protected
    function SelectProject: Boolean; override;
    function SameSelect: Boolean; override;

    procedure RefreshGather; override;
  public
    constructor Create(AProjectData: TProjectData); override;
  end;

implementation

uses
  rpgZoneProjGatherSelectFrm, ProjGather, Forms, Controls, Globals, ZhAPI;

{ TrpgZoneGatherControl }

constructor TrpgZoneGatherControl.Create(AProjectData: TProjectData);
begin
  inherited;
  FBeginPhase := 0;
  FEndPhase := 0;
end;

procedure TrpgZoneGatherControl.RefreshGather;
var
  Gather: TZoneProjGather;
begin
  Screen.Cursor := crHourGlass;
  Gather := TZoneProjGather.Create(GatherData.WriteGatherData,
    ReportConfig.XmjCompare, ReportConfig.GclCompare);
  try
    Gather.Gather(FSelectProjs, FBeginPhase, FEndPhase);
    GatherData.LoadRelaData(ProjectData.ProjectID);
    ClearObjects(FHistroyProjs);
    FHistroyProjs.Assign(FSelectProjs);
    FHistoryBeginPhase := FBeginPhase;
    FHistoryEndPhase := FEndPhase;
  finally
    Gather.Free;
    Screen.Cursor := crDefault;
  end;
end;

function TrpgZoneGatherControl.SameSelect: Boolean;
begin
  Result := inherited SameSelect;
  Result := Result and (FHistoryBeginPhase = FBeginPhase) and (FHistoryEndPhase = FEndPhase);
end;

function TrpgZoneGatherControl.SelectProject: Boolean;
begin
  Result := SelectGatherProject(ProjectData.ProjectID, FSelectProjs, FBeginPhase, FEndPhase);
end;

end.
