unit SelectOnlineSignPhaseFrm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, JimCombos, StdCtrls, ExtCtrls, sdDB, PNGButton;

type
  TSelectOnlineSignPhaseForm = class(TForm)
    pnlPhase: TPanel;
    jcbPhase: TJimComboBox;
    lblHint: TLabel;
    pbOk: TPNGButton;
    procedure pbOkClick(Sender: TObject);
  private
    function GetPhaseIndex: Integer;
    { Private declarations }
  public
    procedure Init(AProjectRec: TsdDataRecord);

    property PhaseIndex: Integer read GetPhaseIndex;
  end;

function SelectOnlineSignPhase(var APhase: Integer; AProjectRec: TsdDataRecord): Boolean;
function SelectEpurePhase(var APhase: Integer; AProjectRec: TsdDataRecord): Boolean;

implementation

{$R *.dfm}

function SelectOnlineSignPhase(var APhase: Integer; AProjectRec: TsdDataRecord): Boolean;
var
  vSelectFrm: TSelectOnlineSignPhaseForm;
begin
  Result := False;
  vSelectFrm := TSelectOnlineSignPhaseForm.Create(nil);
  try
    vSelectFrm.Init(AProjectRec);
    vSelectFrm.lblHint.Caption := '只能对已审批完成的标段进行签署报表生成';
    Result := vSelectFrm.ShowModal = mrOk;
    if Result then
      APhase := vSelectFrm.PhaseIndex;
  finally
    vSelectFrm.Free;
  end;
end;

function SelectEpurePhase(var APhase: Integer; AProjectRec: TsdDataRecord): Boolean;
var
  vSelectFrm: TSelectOnlineSignPhaseForm;
begin
  Result := False;
  vSelectFrm := TSelectOnlineSignPhaseForm.Create(nil);
  try
    vSelectFrm.Init(AProjectRec);
    vSelectFrm.lblHint.Caption := '只能对已审批完成的标段进行报表生成';
    Result := vSelectFrm.ShowModal = mrOk;
    if Result then
      APhase := vSelectFrm.PhaseIndex;
  finally
    vSelectFrm.Free;
  end;
end;

{ TSelectOnlineSignPhaseForm }

function TSelectOnlineSignPhaseForm.GetPhaseIndex: Integer;
begin
  Result := jcbPhase.ItemIndex + 1;
end;

procedure TSelectOnlineSignPhaseForm.Init(AProjectRec: TsdDataRecord);
var
  iPhase: Integer;
  iPhaseCount: Integer;
begin
  iPhaseCount := AProjectRec.ValueByName('PhaseCount').AsInteger;
  if AProjectRec.ValueByName('AuditStatus').AsInteger <> -1 then
    iPhaseCount := iPhaseCount - 1;
  for iPhase := 1 to iPhaseCount do
    jcbPhase.Items.Add(Format(' 第 %d 期数据', [iPhase]));
  jcbPhase.ItemIndex := jcbPhase.Items.Count - 1;
end;

procedure TSelectOnlineSignPhaseForm.pbOkClick(Sender: TObject);
begin
  if jcbPhase.ItemIndex >= 0 then
    ModalResult := mrOk;
end;

end.
