{
===============================================================================
  Copyright (©) 2007. Rodax Software.
===============================================================================
  Los contenidos de este fichero son propiedad de Rodax Software titular del
  copyright. Este fichero sólo podrá ser copiado, distribuido y utilizado,
  en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
  acuerdo con los términos y condiciones establecidas en el acuerdo/contrato
  bajo el que se suministra.
  -----------------------------------------------------------------------------
  Web:  www.rodax-software.com
===============================================================================
  Fecha primera versión: 
  Versión actual: 1.0.0
  Fecha versión actual: 
===============================================================================
  Modificaciones:

    Fecha         Comentarios
    ---------------------------------------------------------------------------
===============================================================================
}

unit uDataModuleBancaElectronica;

interface

uses
  SysUtils, Classes, DB, uDADataTable, uDABINAdapter,
  uDAScriptingProvider, uDACDSDataTable, uROWinInetHttpChannel, uROTypes,
  uRORemoteService, uROClient, uROBinMessage,
  uDADesigntimeCall,
  uDataModuleBase, 
  uIDataModuleBancaElectronica, uBizBancaElectronica, uDADataStreamer,
  uDABin2DataStreamer;

type
  TDataModuleBancaElectronica = class(TDataModuleBase, IDataModuleBancaElectronica)
    RORemoteService: TRORemoteService;
    Bin2DataStreamer: TDABin2DataStreamer;
    procedure DAClientDataModuleCreate(Sender: TObject);
  public
    function GetItems: IBizIBizBanca;
    function GetItem(const ID : Integer) : IBizIBizBanca;
    function NewItem : IBizIBizBanca;
  end;

implementation

{$R *.DFM}

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

{ TDataModuleBancaElectronica }

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

function TDataModuleBancaElectronica.GetItems: IBizIBizBanca;
var
  AIBizBanca : TDAMemDataTable;
begin
  ShowHourglassCursor;
  try
    AIBizBanca := CloneDataTable(tbl_BancaElectronica);
    AIBizBanca.BusinessRulesID := BIZ_CLIENT_IBIZBANCA;
    Result := (AIBizBanca as IBizIBizBanca);
  finally
    HideHourglassCursor;
  end;
end;

function TDataModuleBancaElectronica.NewItem: IBizIBizBanca;
begin
  Result := GetItem(ID_NULO)
end;

function TDataModuleBancaElectronica.GetItem(const ID: Integer): IBizIBizBanca;
var
  Condicion: TDAWhereExpression;
begin
  ShowHourglassCursor;
  try
    Result := Self.GetItems;

    with Result.DataTable.DynamicWhere do
    begin
      // (ID = :ID)
      Condicion := NewBinaryExpression(NewField('', fld_BancaElectronicaID), NewConstant(ID, datInteger), dboEqual);

      if IsEmpty then
         Expression := Condicion
      else
         Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
    end;

  finally
    HideHourglassCursor;
  end;
end;

end.
