unit uDataModuleFormasPago;

interface

uses
  SysUtils, Classes, DB, uDADataTable, uDABINAdapter,
  uDAScriptingProvider, uDACDSDataTable, uROWinInetHttpChannel, uROTypes,
  uRORemoteService, uROClient, uROBinMessage,
  uDADesigntimeCall,           uControllerBase,
   uBizFormasPago, uBizFormasPagoPlazos,
  uDARemoteDataAdapter, uDADataStreamer, uDAInterfaces, uRODynamicRequest,
  uDABin2DataStreamer, uDAMemDataTable, uIDataModuleFormasPago, uDataModuleBase;
type
  TDataModuleFormasPago = class(TDataModuleBase, IDataModuleFormasPago)
    RORemoteService: TRORemoteService;
    Bin2DataStreamer: TDABin2DataStreamer;
    rda_FormasPago: TDARemoteDataAdapter;
    tbl_FormasPago: TDAMemDataTable;
    ds_FormasPago: TDADataSource;
    tbl_FormasPagoPlazos: TDAMemDataTable;
    ds_FormasPagoPlazos: TDADataSource;
    procedure DAClientDataModuleCreate(Sender: TObject);
  protected
    function _GetPlazos: IBizFormaPagoPlazos;
  public
    function GetItems: IBizFormaPago;
  end;

implementation

{$R *.DFM}

uses
  FactuGES_Intf, uDataModuleConexion, uDataTableUtils, cxControls,
  schFormasPagoClient_Intf;

{ TdmAlmacens }

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

function TDataModuleFormasPago._GetPlazos: IBizFormaPagoPlazos;
var
  APlazos : TDAMemDataTable;
begin
  ShowHourglassCursor;
  try
    APlazos := CloneDataTable(tbl_FormasPagoPlazos);
    with APlazos do
    begin
      BusinessRulesID := BIZ_CLIENT_FORMAPAGOPLAZOS;
      DetailOptions := DetailOptions -
        [dtDisableLogOfCascadeDeletes, dtDisableLogOfCascadeUpdates];
    end;
    Result := (APlazos as IBizFormaPagoPlazos);
  finally
    HideHourglassCursor;
  end;
end;

function TDataModuleFormasPago.GetItems: IBizFormaPago;
var
  AFormaPago : TDAMemDataTable;
begin
  ShowHourglassCursor;
  try
    AFormaPago := CloneDataTable(tbl_FormasPago);
    AFormaPago.BusinessRulesID := BIZ_CLIENT_FORMAPAGO;
    with TBizFormaPago(AFormaPago.BusinessEventsObj) do
         Plazos := _GetPlazos;

    Result := (AFormaPago as IBizFormaPago);
  finally
    HideHourglassCursor;
  end;
end;

end.
