unit uDataModuleStock;

interface

uses {vcl:} SysUtils, Classes, DB, DBClient,
     {RemObjects:} uDAClientDataModule, uDADataTable, uDABINAdapter,
  uROServiceComponent, uRORemoteService, uROClient, uROBinMessage,
  uROWinInetHttpChannel, uDAScriptingProvider, uDACDSDataTable,
  uBizStock;

type
  TdmStock = class(TDAClientDataModule)
    RORemoteService: TRORemoteService;
    tbl_StockEDI: TDACDSDataTable;
    tbl_StockVARELA: TDACDSDataTable;
    tbl_StockPrendasCentros: TDACDSDataTable;
    ds_StockPrendasCentros: TDADataSource;
    tbl_StockEDIInventario: TDACDSDataTable;
    procedure DAClientDataModuleCreate(Sender: TObject);
  public
    function GetItemsStockVarela : IBizStockVARELA;
    function GetItemsStockEDI : IBizStockEDI;
    function GetItemsStockEDIInventario : IBizStockEDIInventario;
    function GetItemsStockPrendasCentros : IBizStockPrendasCentros;
  end;

var
  dmStock: TdmStock;

implementation

{$R *.DFM}

uses
  uDataModuleBase, Controls, Forms, cxControls, uDataTableUtils;


procedure TdmStock.DAClientDataModuleCreate(Sender: TObject);
begin
  RORemoteService.Channel := dmBase.Channel;
  RORemoteService.Message := dmBase.Message;
end;

function TdmStock.GetItemsStockEDI: IBizStockEDI;
var
  dtItemsStockEDI: TDACDSDataTable;
begin
  ShowHourglassCursor;
  try
    dtItemsStockEDI := TDACDSDataTable.Create(NIL);
    CloneDataTable(tbl_StockEDI, dtItemsStockEDI);
    dtItemsStockEDI.BusinessRulesID := BIZ_STOCK_EDI;
    Result := (dtItemsStockEDI as IBizStockEDI);
  finally
    HideHourglassCursor;
  end;
end;

function TdmStock.GetItemsStockEDIInventario: IBizStockEDIInventario;
var
  dtItemsStockEDIInventario: TDACDSDataTable;
begin
  ShowHourglassCursor;
  try
    dtItemsStockEDIInventario := TDACDSDataTable.Create(NIL);
    CloneDataTable(tbl_StockEDIInventario, dtItemsStockEDIInventario);
    dtItemsStockEDIInventario.BusinessRulesID := BIZ_STOCK_EDIINVENTARIO;
    Result := (dtItemsStockEDIInventario as IBizStockEDIInventario);
  finally
    HideHourglassCursor;
  end;
end;

function TdmStock.GetItemsStockPrendasCentros: IBizStockPrendasCentros;
var
  dtItemsStock: TDACDSDataTable;
begin
  ShowHourglassCursor;
  try
    dtItemsStock := TDACDSDataTable.Create(NIL);
    CloneDataTable(tbl_StockPrendasCentros, dtItemsStock);
    dtItemsStock.BusinessRulesID := BIZ_STOCK_PRENDAS_CENTROS;
    Result := (dtItemsStock as IBizStockPrendasCentros);
  finally
    HideHourglassCursor;
  end;
end;

function TdmStock.GetItemsStockVarela: IBizStockVARELA;
var
  dtItemsStockVARELA: TDACDSDataTable;
begin
  ShowHourglassCursor;
  try
    dtItemsStockVARELA := TDACDSDataTable.Create(NIL);
    CloneDataTable(tbl_StockVARELA, dtItemsStockVARELA);
    dtItemsStockVARELA.BusinessRulesID := BIZ_STOCK_VARELA;
    Result := (dtItemsStockVARELA as IBizStockVARELA);
  finally
    HideHourglassCursor;
  end;
end;

initialization
  dmStock := TdmStock.Create(nil);

finalization
  FreeAndNil(dmStock);

end.

