unit uListaObras;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxGraphics, cxControls, cxContainer, cxEdit, cxTextEdit,
  cxMaskEdit, cxDropDownEdit, cxLookupEdit, cxDBLookupEdit,
  cxDBLookupComboBox, DB, uDADataTable, uCustomView, uViewBase,
  uViewBarraSeleccion, uBizObras, ExtCtrls, StdCtrls,
  Grids, DBGrids;

type
  TfListaObras = class(TForm)
    DADataSource: TDADataSource;
    Label1: TLabel;
    Label5: TLabel;
    Bevel1: TBevel;
    cxObras: TcxLookupComboBox;
    pnlSeleccion: TPanel;
    bSeleccionar: TButton;
    bCancelar: TButton;
    procedure bSeleccionarClick(Sender: TObject);
  private
    FObras: IBizObra;
    function GetObras: IBizObra;
    procedure SetObra(const Value: IBizObra);
  public
    property Obras: IBizObra read GetObras write SetObra;
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  end;

implementation
{$R *.dfm}

uses uDataModuleObras, schObrasClient_Intf;

{ TfListaObras }

constructor TfListaObras.Create(AOwner: TComponent);
begin
  inherited;
end;

destructor TfListaObras.Destroy;
begin
  FObras := Nil;
  inherited;
end;

function TfListaObras.GetObras: IBizObra;
begin
  Result := FObras;
end;

procedure TfListaObras.SetObra(const Value: IBizObra);
begin
  FObras := Value;
  if Assigned(FObras) then
  begin
    DADataSource.DataTable := FObras.DataTable;
    FObras.DataTable.Active := True;
    cxObras.ItemIndex := 0;
  end
  else
    DADataSource.DataTable := Nil;
end;

procedure TfListaObras.bSeleccionarClick(Sender: TObject);
begin
  FObras.First;
  FObras.Locate(fld_OBRASNOMBRE, cxObras.Text);
end;

end.
