unit ProjGatherSelectFrm;

interface

uses
  ProjGatherSelectFme,
  sdIDTree, sdDB,
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, sdGridDBA, sdGridTreeDBA, StdCtrls, ZJGrid, ZJCells, ExtCtrls;

type
  TProjGatherSelectForm = class(TForm)
    btnOk: TButton;
    btnCancel: TButton;
    pnlTop: TPanel;
    procedure btnOkClick(Sender: TObject);
  private
    FSelectFrame: TProjGatherSelectFrame;

    FBeginPhaseIndex: Integer;
    FEndPhaseIndex: Integer;

    procedure RefreshDiffWindows;
  public
    constructor Create(AProjectID: Integer; AProjs: TList; ASpecialProjTypes: TStrings);
    destructor Destroy; override;

    procedure AssignResult(AProjs: TList);
  end;

function SelectGatherProject(AProjectID: Integer; AProjs: TList; ASpecialProjTypes: TStrings = nil): Boolean;

implementation

uses
  UtilMethods;

{$R *.dfm}

function SelectGatherProject(AProjectID: Integer; AProjs: TList; ASpecialProjTypes: TStrings = nil): Boolean;
var
  vSelectFrm: TProjGatherSelectForm;
begin
  vSelectFrm := TProjGatherSelectForm.Create(AProjectID, AProjs, ASpecialProjTypes);
  try
    Result := vSelectFrm.ShowModal = mrOk;
    if Result then
      vSelectFrm.AssignResult(AProjs);
  finally
    vSelectFrm.Free;
  end;
end;

{ TProjGatherSelectForm }

constructor TProjGatherSelectForm.Create(AProjectID: Integer;
  AProjs: TList; ASpecialProjTypes: TStrings);
begin
  inherited Create(nil);

  FSelectFrame := TProjGatherSelectFrame.Create(AProjectID, ASpecialProjTypes);
  AlignControl(FSelectFrame, pnlTop, alClient);
  FSelectFrame.LoadHistorySelects(AProjs);

  RefreshDiffWindows;
end;

destructor TProjGatherSelectForm.Destroy;
begin
  FSelectFrame.Free;
  inherited;
end;

procedure TProjGatherSelectForm.btnOkClick(Sender: TObject);
begin
  if FSelectFrame.zgResult.RowCount > 1 then
    ModalResult := mrOk
  else
    WarningMessage('Çë¹´Ñ¡»ã×ÜÏîÄ¿¡£', Handle);
end;

procedure TProjGatherSelectForm.AssignResult(AProjs: TList);
begin
  FSelectFrame.AssignResult(AProjs);
end;

procedure TProjGatherSelectForm.RefreshDiffWindows;
begin
  ClientHeight := 523;
  ClientWidth := 827;
end;

end.
