unit tpPartTenderSetFme;

interface

uses
  tpPartTenderSet, tpPartTenderFme,
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, sdGridDBA, StdCtrls, JimLabels, ZJGrid, ExtCtrls;

type
  TtpPartTenderSetFrame = class(TFrame)
    pnlPartTenders: TPanel;
    zgPartTendersInfo: TZJGrid;
    labGatherTenders: TJimGradLabel;
    pnlCurPartTender: TPanel;
    sprTenderData: TSplitter;
    procedure zgPartTendersInfoCurrentChanged(Sender: TObject; Col,
      Row: Integer);
  private
    FPartTenderSetData: TtpPartTenderSet;
    FCurPartTenderFrame: TtpPartTenderFrame;

    procedure AssignTenderInfo;
  public
    constructor Create(APartTenderSetData: TtpPartTenderSet);
    destructor Destroy; override;

    procedure RefreshData;
  end;

implementation

uses
  UtilMethods, tpPartTender;

{$R *.dfm}

{ TtpPartTenderSetFrame }

procedure TtpPartTenderSetFrame.AssignTenderInfo;
var
  i: Integer;
  vPartTender: TtpPartTender;
begin
  zgPartTendersInfo.RowCount := FPartTenderSetData.TenderCount + 1;
  for i := 0 to FPartTenderSetData.TenderCount - 1 do
  begin
    vPartTender := FPartTenderSetData.PartTender[i];
    zgPartTendersInfo.Cells[1, i+1].Text := vPartTender.BeginPeg + '~' + vPartTender.EndPeg;
    zgPartTendersInfo.Cells[1, i+1].Align := gaCenterLeft;
  end;
end;

constructor TtpPartTenderSetFrame.Create(
  APartTenderSetData: TtpPartTenderSet);
begin
  inherited Create(nil);
  zgPartTendersInfo.Cells[1, 0].Text := '±ê¶Î';

  FPartTenderSetData := APartTenderSetData;
  FPartTenderSetData.SetFrame := Self;
  FCurPartTenderFrame := TtpPartTenderFrame.Create;
  AlignControl(FCurPartTenderFrame, pnlCurPartTender, alClient);
end;

destructor TtpPartTenderSetFrame.Destroy;
begin
  FCurPartTenderFrame.Free;
  inherited;
end;

procedure TtpPartTenderSetFrame.RefreshData;
begin
  AssignTenderInfo;
  FCurPartTenderFrame.PartTenderData := FPartTenderSetData.PartTender[0];
end;

procedure TtpPartTenderSetFrame.zgPartTendersInfoCurrentChanged(
  Sender: TObject; Col, Row: Integer);
var
  iTender: Integer;
begin
  iTender := zgPartTendersInfo.CurRow - 1;
  FCurPartTenderFrame.PartTenderData := FPartTenderSetData.PartTender[iTender];
end;

end.
