public static IList <AlmacenInventarioInfo> ObtenerProductosPorAlmacen(int idAlmacen)
        {
            IList <AlmacenInventarioInfo> listaAlmacenInventario = null;

            try
            {
                SeguridadInfo seguridad = HttpContext.Current.Session["Seguridad"] as SeguridadInfo;

                if (seguridad != null)
                {
                    var almacenInventarioPl = new AlmacenInventarioPL();
                    var almacenPl           = new AlmacenPL();

                    AlmacenInfo almacen = almacenPl.ObtenerPorID(idAlmacen);

                    OrganizacionInfo organizacion = seguridad.Usuario.Organizacion;

                    listaAlmacenInventario = almacenInventarioPl.ObtienePorAlmacenIdLlenaProductoInfo(almacen);

                    if (listaAlmacenInventario != null && listaAlmacenInventario.Count > 0)
                    {
                        listaAlmacenInventario = (from productos in listaAlmacenInventario
                                                  where productos.Producto != null
                                                  orderby productos.Producto.Descripcion
                                                  select productos).ToList();

                        if (almacen.TipoAlmacen.TipoAlmacenID == (int)TipoAlmacenEnum.PlantaDeAlimentos)
                        {
                            listaAlmacenInventario = (from productos in listaAlmacenInventario
                                                      where productos.Producto.SubFamilia.SubFamiliaID != (int)SubFamiliasEnum.AlimentoFormulado
                                                      orderby productos.Producto.Descripcion
                                                      select productos).ToList();
                        }
                    }
                }
                else
                {
                    throw new ExcepcionServicio("SesionExpirada");
                }
            }
            catch (ExcepcionServicio ex)
            {
                Logger.Error(ex);
                throw new ExcepcionServicio(ex.Message);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new Exception(ex.Message);
            }

            return(listaAlmacenInventario);
        }
Esempio n. 2
0
        public void AlmacenListas()
        {
            var         pl = new AlmacenPL();
            AlmacenInfo info;

            try
            {
                info = pl.ObtenerPorID(1);
            }
            catch (Exception)
            {
                info = null;
            }
            Assert.AreNotEqual(info, null);
        }
        public static RespuestaInventarioLoteInfo ObtenerLotePorTipoAlmacen(ParametroRecepcionMateriaPrimaLote parametroLoteMateriaPrima)
        {
            try
            {
                RespuestaInventarioLoteInfo listadoLotes = null;
                var almacenInventarioLotePl = new AlmacenInventarioLotePL();
                var seguridad = HttpContext.Current.Session["Seguridad"] as SeguridadInfo;
                int organizacionId = 0, tipoAlmacen = 0;

                if (seguridad != null)
                {
                    organizacionId = seguridad.Usuario.Organizacion.OrganizacionID;
                }

                switch (parametroLoteMateriaPrima.TipoAlmacen)
                {
                case "rbLoteAlmacen":
                    tipoAlmacen = (int)TipoAlmacenEnum.MateriasPrimas;
                    break;

                case "rbLoteProceso":
                    tipoAlmacen = (int)TipoAlmacenEnum.PlantaDeAlimentos;
                    break;

                case "rbBodegaExterna":
                    tipoAlmacen = (int)TipoAlmacenEnum.BodegaExterna;
                    break;
                }

                var almacenInventarioLote = almacenInventarioLotePl
                                            .ObtenerListadoLotesPorOrganizacionTipoAlmacenProducto(
                    new ParametrosOrganizacionTipoAlmacenProductoActivo
                {
                    OrganizacionId = organizacionId,
                    ProductoId     = parametroLoteMateriaPrima.ProductoId,
                    TipoAlmacenId  = tipoAlmacen
                });

                if (almacenInventarioLote != null)
                {
                    foreach (var almacenInventario in almacenInventarioLote.Where(almacen => almacen.Lote == parametroLoteMateriaPrima.Lote))
                    {
                        var almacenPl = new AlmacenPL();
                        var almacen   = almacenPl.ObtenerPorID(almacenInventario.AlmacenInventario.AlmacenID);

                        listadoLotes = new RespuestaInventarioLoteInfo
                        {
                            AlmacenInventarioLoteId = almacenInventario.AlmacenInventarioLoteId,
                            AlmacenId     = almacenInventario.AlmacenInventario.AlmacenID,
                            CodigoAlmacen = almacen.CodigoAlmacen,
                            Lote          = almacenInventario.Lote,
                            Cantidad      = almacenInventario.Cantidad
                        };
                    }
                }
                return(listadoLotes);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new SystemException(ex.Message);
            }
        }