unit uListaAlmacenes;

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, uBizAlmacenes, ExtCtrls, StdCtrls,
  Grids, DBGrids;

type
  TfListaAlmacenes = class(TForm)
    DADataSource: TDADataSource;
    Label1: TLabel;
    Label5: TLabel;
    Bevel1: TBevel;
    cxAlmacenes: TcxLookupComboBox;
    pnlSeleccion: TPanel;
    bSeleccionar: TButton;
    bCancelar: TButton;
    procedure bSeleccionarClick(Sender: TObject);
  private
    FAlmacenes: IBizAlmacen;
    function GetAlmacenes: IBizAlmacen;
    procedure SetAlmacen(const Value: IBizAlmacen);
  public
    property Almacenes: IBizAlmacen read GetAlmacenes write SetAlmacen;
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  end;

implementation
{$R *.dfm}

uses uDataModuleAlmacenes, schAlmacenesClient_Intf;

{ TfListaAlmacenes }

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

destructor TfListaAlmacenes.Destroy;
begin
  FAlmacenes := Nil;
  inherited;
end;

function TfListaAlmacenes.GetAlmacenes: IBizAlmacen;
begin
  Result := FAlmacenes;
end;

procedure TfListaAlmacenes.SetAlmacen(const Value: IBizAlmacen);
begin
  FAlmacenes := Value;
  if Assigned(FAlmacenes) then
  begin
    DADataSource.DataTable := FAlmacenes.DataTable;
    FAlmacenes.DataTable.Active := True;
    cxAlmacenes.ItemIndex := 0;
  end
  else
    DADataSource.DataTable := Nil;
end;

procedure TfListaAlmacenes.bSeleccionarClick(Sender: TObject);
begin
  FAlmacenes.First;
  FAlmacenes.Locate(fld_ALMACENESNOMBRE, cxAlmacenes.Text);
end;

end.
