unit uDataModuleReferencias;

interface

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

type
  TDataModuleReferencias = class(TDAClientDataModule, IDataModuleReferencias)
    RORemoteService: TRORemoteService;
    DABinAdapter: TDABINAdapter;
    DADesigntimeCall1: TDADesigntimeCall;
    LoginRemoteService: TRORemoteService;
    ROWinInetHTTPChannel1: TROWinInetHTTPChannel;
    ROBinMessage1: TROBinMessage;
    tbl_Referencias: TDACDSDataTable;
    ds_Referencias: TDADataSource;
    procedure DAClientDataModuleCreate(Sender: TObject);
  protected
    function _CloneDataTable (const ADataTable : TDACDSDataTable): TDACDSDataTable; overload;
  public
    function GetItems: IBizReferencia;
  end;

implementation

{$R *.DFM}

uses
  FactuGES_Intf, cxControls, uDataModuleConexion, uDataTableUtils, 
  schReferenciasClient_Intf;

{ TdmAlmacens }

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

function TDataModuleReferencias._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 TDataModuleReferencias.GetItems: IBizReferencia;
var
  AReferencia : TDACDSDataTable;
begin
  ShowHourglassCursor;
  try
    AReferencia := _CloneDataTable(tbl_Referencias);
    AReferencia.BusinessRulesID := BIZ_CLIENT_REFERENCIA;

    Result := (AReferencia as IBizReferencia);
  finally
    HideHourglassCursor;
  end;
end;


end.
