unit uDataModuleFamilias;

interface

uses
  SysUtils, Classes, DB, uDAClientDataModule, uDADataTable, uDABINAdapter,
  uDAScriptingProvider, uDACDSDataTable, uROWinInetHttpChannel, uROTypes,
  uROServiceComponent, uRORemoteService, uROClient, uROBinMessage,
  uDADesigntimeCall,
  uIDataModuleFamilias, uBizFamilias;

type
  TDataModuleFamilias = class(TDAClientDataModule, IDataModuleFamilias)
    RORemoteService: TRORemoteService;
    DABinAdapter: TDABINAdapter;
    DADesigntimeCall1: TDADesigntimeCall;
    LoginRemoteService: TRORemoteService;
    ROWinInetHTTPChannel1: TROWinInetHTTPChannel;
    ROBinMessage1: TROBinMessage;
    tbl_Familias: TDACDSDataTable;
    ds_Familias: TDADataSource;
    procedure DAClientDataModuleCreate(Sender: TObject);

  protected
    function _CloneDataTable (const ADataTable : TDACDSDataTable): TDACDSDataTable; overload;
    procedure AsignarClaseNegocio(var AFamilia: TDACDSDataTable); virtual;
  public
    function GetItems : IBizFamilia;
  end;

implementation
{$R *.DFM}

uses
  FactuGES_Intf, uDataModuleConexion, uDataTableUtils, cxControls, uDAInterfaces,
  schFamiliasClient_Intf;

{ TdmFamilias }

procedure TDataModuleFamilias.AsignarClaseNegocio(var AFamilia: TDACDSDataTable);
begin
  AFamilia.BusinessRulesID := BIZ_CLIENT_FAMILIA;
end;

procedure TDataModuleFamilias.DAClientDataModuleCreate(Sender: TObject);
begin
  RORemoteService.Channel := dmConexion.Channel;
  RORemoteService.Message := dmConexion.Message;
end;

function TDataModuleFamilias._CloneDataTable(const ADataTable : TDACDSDataTable): TDACDSDataTable;
begin
  Result := NIL;

  if not Assigned(ADataTable) then
    raise Exception.Create ('No se ha asignado la tabla de origen (CloneDataTable)');

  Result := TDACDSDataTable.Create(NIL);
  CloneDataTable(ADataTable, Result);
end;

function TDataModuleFamilias.GetItems: IBizFamilia;
var
  AFamilia : TDACDSDataTable;
begin
  ShowHourglassCursor;
  try
    AFamilia := _CloneDataTable(tbl_Familias);
    AsignarClaseNegocio(AFamilia);
    Result := (AFamilia as IBizFamilia);
  finally
    HideHourglassCursor;
  end;
end;


end.
