unit uDataModuleInventario; interface uses SysUtils, Classes, DB, uDADataTable, uDABINAdapter, uDAScriptingProvider, uDACDSDataTable, uROWinInetHttpChannel, uROTypes, uRORemoteService, uROClient, uROBinMessage, uDADesigntimeCall, uDataModuleBase, uIDataModuleInventario, uBizInventario, uDARemoteDataAdapter, uDADataStreamer, uDABin2DataStreamer, uDAInterfaces, uDAMemDataTable, uDADataAdapter, uBizMovimientosDetalleColor; type TDataModuleInventario = class(TDataModuleBase, IDataModuleInventario) RORemoteService: TRORemoteService; Bin2DataStreamer: TDABin2DataStreamer; rda_Inventario: TDARemoteDataAdapter; tbl_DetalleReservas: TDAMemDataTable; ds_DetalleReservas: TDADataSource; tbl_Inventario: TDAMemDataTable; ds_Inventario: TDADataSource; tbl_Movimientos_Detalle_Color: TDAMemDataTable; ds_Movimientos_Detalle_Color: TDADataSource; tbl_Inventario_Color: TDAMemDataTable; ds_Inventario_Color: TDADataSource; procedure DAClientDataModuleCreate(Sender: TObject); private function _GetDetalleColores : IBizMovimientosDetalleColor; public function GetItems : IBizInventario; overload; function GetItems(const ID_ALMACEN : Integer) : IBizInventario; overload; function GetDetalleReservas: IBizDetalleReservas; function GetDetalleReservasVacio: IBizDetalleReservas; function GetInventarioColor(const ID_ALMACEN, ID_ARTICULO : Integer) : IBizInventarioColor; end; implementation {$R *.DFM} uses FactuGES_Intf, uDataModuleConexion, uDataTableUtils, cxControls, schInventarioClient_Intf; { TdmArticulos } procedure TDataModuleInventario.DAClientDataModuleCreate(Sender: TObject); begin RORemoteService.Channel := dmConexion.Channel; RORemoteService.Message := dmConexion.Message; end; function TDataModuleInventario.GetDetalleReservas: IBizDetalleReservas; var ADetalleReservas : TDAMemDataTable; begin ShowHourglassCursor; try ADetalleReservas := CloneDataTable(tbl_DetalleReservas); ADetalleReservas.BusinessRulesID := BIZ_CLIENT_DETALLE_RESERVAS_INV; Result := (ADetalleReservas as IBizDetalleReservas); finally HideHourglassCursor; end; end; function TDataModuleInventario.GetDetalleReservasVacio: IBizDetalleReservas; begin ShowHourglassCursor; try Result := Self.GetDetalleReservas; with Result.DataTable.Where do begin if NotEmpty then AddOperator(opAND); OpenBraket; AddText(fld_DetalleReservasID + ' = ' + IntToStr(ID_NULO)); CloseBraket; end; finally HideHourglassCursor; end; end; function TDataModuleInventario.GetInventarioColor(const ID_ALMACEN, ID_ARTICULO : Integer): IBizInventarioColor; var AInventarioColor : TDAMemDataTable; Condicion: TDAWhereExpression; begin ShowHourglassCursor; try AInventarioColor := CloneDataTable(tbl_Inventario_Color); AInventarioColor.BusinessRulesID := BIZ_CLIENT_INVENTARIO_COLOR; Result := (AInventarioColor as IBizInventarioColor); with Result.DataTable.DynamicWhere do begin // (ID_ALMACEN = :ID_ALMACEN) Condicion := NewBinaryExpression(NewField('', fld_Inventario_ColorID_ALMACEN), NewConstant(ID_ALMACEN, datInteger), dboEqual); if IsEmpty then Expression := Condicion else Expression := NewBinaryExpression(Expression, Condicion, dboAnd); end; with Result.DataTable.DynamicWhere do begin // (ID_ARTICULO = :ID_ARTICULO) Condicion := NewBinaryExpression(NewField('', fld_Inventario_ColorID_ARTICULO), NewConstant(ID_ARTICULO, datInteger), dboEqual); if IsEmpty then Expression := Condicion else Expression := NewBinaryExpression(Expression, Condicion, dboAnd); end; finally HideHourglassCursor; end; end; function TDataModuleInventario.GetItems(const ID_ALMACEN: Integer): IBizInventario; var Condicion: TDAWhereExpression; begin ShowHourglassCursor; try Result := Self.GetItems; with Result.DataTable.DynamicWhere do begin // (ID_ALMACEN = :ID_ALMACEN) Condicion := NewBinaryExpression(NewField('', fld_INVENTARIOID_ALMACEN), NewConstant(ID_ALMACEN, datInteger), dboEqual); if IsEmpty then Expression := Condicion else Expression := NewBinaryExpression(Expression, Condicion, dboAnd); end; finally HideHourglassCursor; end; end; function TDataModuleInventario._GetDetalleColores: IBizMovimientosDetalleColor; var ADetalleColores : TDAMemDataTable; begin ShowHourglassCursor; try ADetalleColores := CloneDataTable(tbl_Movimientos_Detalle_Color); with ADetalleColores do begin BusinessRulesID := BIZ_CLIENT_MOVIMIENTOS_DETALLE_COLOR; DetailOptions := DetailOptions - [dtDisableLogOfCascadeDeletes, dtDisableLogOfCascadeUpdates]; end; Result := (ADetalleColores as IBizMovimientosDetalleColor); finally HideHourglassCursor; end; end; function TDataModuleInventario.GetItems: IBizInventario; var AInventario : TDAMemDataTable; begin ShowHourglassCursor; try AInventario := CloneDataTable(tbl_Inventario); AInventario.BusinessRulesID := BIZ_CLIENT_INVENTARIO; with TBizInventario(AInventario.BusinessEventsObj) do begin DetalleColores := _GetDetalleColores; end; Result := (AInventario as IBizInventario); finally HideHourglassCursor; end; end; end.