/// <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); } }