public static AlmacenInventarioLoteInfo ObtenerCantidadPiezas(int idInventarioLote) { AlmacenInventarioLoteInfo lote = null; try { SeguridadInfo seguridad = HttpContext.Current.Session["Seguridad"] as SeguridadInfo; if (seguridad != null) { var almacenPl = new AlmacenInventarioLotePL(); lote = almacenPl.ObtenerAlmacenInventarioLotePorId(idInventarioLote); } 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(lote); }
public static AlmacenInventarioLoteInfo ObtenerExistenciaInventario(int almacenInventarioLoteId) { var seguridad = HttpContext.Current.Session["Seguridad"] as SeguridadInfo; AlmacenInventarioLoteInfo almacenInventarioLoteInfo = null; var almaceninventariolotepl = new AlmacenInventarioLotePL(); if (seguridad != null) { almacenInventarioLoteInfo = almaceninventariolotepl.ObtenerAlmacenInventarioLotePorId(almacenInventarioLoteId); } return(almacenInventarioLoteInfo); }
/// <summary> /// Valida si el stock actual no cubre el envio que se intenta registrar /// </summary> /// <returns>Regresa True si la canidad de envio excede el inventario actual</returns> private bool ValidarSalidaExcede(out string error) { AlmacenInventarioPL almacenInventarioPL = new AlmacenInventarioPL(); AlmacenInventarioInfo inventarioActualizado = almacenInventarioPL.ObtenerPorAlmacenIdProductoId(EnvioAlimento.AlmacenInventario); if (EnvioAlimento.Producto.ManejaLote) { AlmacenInventarioLotePL inventarioLotePL = new AlmacenInventarioLotePL(); AlmacenInventarioLoteInfo loteActual = inventarioLotePL.ObtenerAlmacenInventarioLotePorId(EnvioAlimento.AlmacenInventario.ListaAlmacenInventarioLote.FirstOrDefault().AlmacenInventarioLoteId); if (loteActual.Cantidad == 0) { error = Properties.Resources.EnvioAlimento_MsgProductoSinInventario; LimpiarProducto(); this.EnvioAlimento.Producto = new ProductoInfo { ProductoId = 0, SubfamiliaId = (int)this.cmbSubFamilia.SelectedValue }; cmbAlmacen.ItemsSource = new List <AlmacenInfo>(); this.skAyudaProducto.LimpiarCampos(); cmbAlmacen.IsEnabled = false; this.skAyudaProducto.LimpiarCampos(); this.skAyudaProducto.txtClave.Focus(); txtCantidadEnvio.Text = string.Empty; txtPrecioPromedio.Text = string.Empty; txtCantidadInventario.Text = string.Empty; return(true); } if ((loteActual.Cantidad - decimal.Parse(txtCantidadEnvio.Text)) < 0) { error = Properties.Resources.EnvioAlimento_MsgCantidadInventarioNegativo; LimpiarProducto(); txtCantidadEnvio.Text = string.Empty; txtPrecioPromedio.Text = string.Empty; txtCantidadInventario.Text = string.Empty; return(true); } error = string.Empty; return(false); } else { if (inventarioActualizado.Cantidad == 0) { error = Properties.Resources.EnvioAlimento_MsgProductoSinInventario; LimpiarProducto(); this.skAyudaProducto.LimpiarCampos(); this.skAyudaProducto.txtClave.Focus(); txtCantidadEnvio.Text = string.Empty; txtPrecioPromedio.Text = string.Empty; txtCantidadInventario.Text = string.Empty; return(true); } if (((inventarioActualizado.Cantidad - decimal.Parse(txtCantidadEnvio.Text.Trim())) < 0)) { error = Properties.Resources.EnvioAlimento_MsgCantidadInventarioNegativo; LimpiarProducto(); txtCantidadEnvio.Text = string.Empty; txtPrecioPromedio.Text = string.Empty; txtCantidadInventario.Text = string.Empty; return(true); } else { error = string.Empty; return(false); } } }
/// <summary> /// Crear un nuevo lote en AlamcenInventarioLote /// </summary> private void CrearNuevoLote() { try { AlmacenInventarioLoteInfo almacenInventarioLote = null; int usuarioId = AuxConfiguracion.ObtenerUsuarioLogueado(); var almacenInventarioLotePl = new AlmacenInventarioLotePL(); var almacenInventarioPl = new AlmacenInventarioPL(); var almacenInventario = new AlmacenInventarioInfo { AlmacenID = Contexto.AlmacenDestino.AlmacenID, ProductoID = Contexto.ProductoDestino.ProductoId }; almacenInventario = almacenInventarioPl.ObtenerPorAlmacenIdProductoId(almacenInventario); // Si el producto no se encuentra en el almacen inventario, lo insertamos if (almacenInventario == null) { almacenInventario = new AlmacenInventarioInfo { AlmacenInventarioID = almacenInventarioPl.Crear(new AlmacenInventarioInfo { AlmacenID = Contexto.AlmacenDestino.AlmacenID, ProductoID = Contexto.ProductoDestino.ProductoId, UsuarioCreacionID = usuarioId }), AlmacenID = Contexto.AlmacenDestino.AlmacenID }; } int loteIdCreado = almacenInventarioLotePl.Crear(new AlmacenInventarioLoteInfo { AlmacenInventarioLoteId = 0, AlmacenInventario = new AlmacenInventarioInfo { AlmacenInventarioID = almacenInventario.AlmacenInventarioID }, Cantidad = 0, PrecioPromedio = 0, Piezas = 0, Importe = 0, Activo = EstatusEnum.Activo, UsuarioCreacionId = usuarioId, }, new AlmacenInventarioInfo { AlmacenID = almacenInventario.AlmacenID, ProductoID = Contexto.ProductoDestino.ProductoId }); almacenInventarioLote = almacenInventarioLotePl.ObtenerAlmacenInventarioLotePorId(loteIdCreado); Contexto.LoteMpDestino = almacenInventarioLote; skAyudaLoteMPDestino.IsEnabled = false; } catch (Exception ex) { Logger.Error(ex); SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.TraspasoMPPAMED_ErrorCrearLote, MessageBoxButton.OK, MessageImage.Error); } }
public static AlmacenInventarioLoteInfo ObtenerNuevoLoteMateriaPrima(int productoId, string tipoalmacen) { try { var seguridad = HttpContext.Current.Session["Seguridad"] as SeguridadInfo; int organizacionId = 0, usuarioId = 0, tipoAlmacen = 0; AlmacenInventarioLoteInfo almacenInventarioLote = null; if (seguridad != null) { organizacionId = seguridad.Usuario.Organizacion.OrganizacionID; usuarioId = seguridad.Usuario.UsuarioID; } switch (tipoalmacen) { case "rbLoteAlmacen": tipoAlmacen = (int)TipoAlmacenEnum.MateriasPrimas; break; case "rbLoteProceso": tipoAlmacen = (int)TipoAlmacenEnum.PlantaDeAlimentos; break; case "rbBodegaExterna": tipoAlmacen = (int)TipoAlmacenEnum.BodegaExterna; break; } var almacenInventarioLotePl = new AlmacenInventarioLotePL(); var almacenPl = new AlmacenPL(); var almacenInventarioPl = new AlmacenInventarioPL(); var almacenInventario = almacenPl.ObtenerAlmacenInventarioPorOrganizacionTipoAlmacen(new ParametrosOrganizacionTipoAlmacenProductoActivo { OrganizacionId = organizacionId, TipoAlmacenId = tipoAlmacen, Activo = (int)EstatusEnum.Activo, ProductoId = productoId }); // Si el producto no se encuentra en el almacen inventario, lo insertamos if (almacenInventario == null) { var listaAlmacenOrganizacion = almacenPl.ObtenerAlmacenPorOrganizacion(organizacionId); if (listaAlmacenOrganizacion != null) { // Obtenemos el almacen y validamos que sea del mismo tipo Almacen foreach (AlmacenInfo almacenInfo in listaAlmacenOrganizacion) { // Aqui se valida que el almacen sea del tipo seleccionado en pantalla if (almacenInfo.TipoAlmacen.TipoAlmacenID == tipoAlmacen) { almacenInventario = new AlmacenInventarioInfo { AlmacenInventarioID = almacenInventarioPl.Crear(new AlmacenInventarioInfo { AlmacenID = almacenInfo.AlmacenID, ProductoID = productoId, UsuarioCreacionID = usuarioId }), AlmacenID = almacenInfo.AlmacenID }; break; } } } } if (almacenInventario != null) { int loteIdCreado = almacenInventarioLotePl.Crear(new AlmacenInventarioLoteInfo { AlmacenInventarioLoteId = 0, AlmacenInventario = new AlmacenInventarioInfo { AlmacenInventarioID = almacenInventario.AlmacenInventarioID }, Cantidad = 0, PrecioPromedio = 0, Piezas = 0, Importe = 0, Activo = EstatusEnum.Activo, UsuarioCreacionId = usuarioId, }, new AlmacenInventarioInfo { AlmacenID = almacenInventario.AlmacenID, ProductoID = productoId }); almacenInventarioLote = almacenInventarioLotePl.ObtenerAlmacenInventarioLotePorId(loteIdCreado); } return(almacenInventarioLote); } catch (Exception ex) { Logger.Error(ex); throw new SystemException(ex.Message); } }