Ejemplo n.º 1
0
        /// <summary>
        /// Obtiene el listado de alamacenes en los que se encuentra el producto
        /// con inventario y estan asignados a la organizacion del usuario
        /// </summary>
        /// <param name="usuarioId">Usuario del producto</param>
        /// <returns>List<AlmacenInfo>Regresa una lista de almacenes con existencias del producto indicado</returns>
        public List <AlmacenInfo> ObtenerAlmacenesProducto(FiltroAlmacenProductoEnvio filtroEnvio)
        {
            List <AlmacenInfo> lstAlamcenes = new List <AlmacenInfo>();

            try
            {
                return(new AlmacenBL().ObtenerAlamcenPorProducto(filtroEnvio));
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 ///      Obtiene un Almacen por su Id
 /// </summary>
 /// <returns> </returns>
 internal List <AlmacenInfo> ObtenerAlamcenPorProducto(FiltroAlmacenProductoEnvio filtroEnvio)
 {
     try
     {
         Logger.Info();
         return(new AlmacenDAL().ObtenerAlamcenPorProducto(filtroEnvio));
     }
     catch (ExcepcionGenerica)
     {
         throw;
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Ejemplo n.º 3
0
 internal static Dictionary <string, object> ObtenerParmetrosPorProducto(FiltroAlmacenProductoEnvio filtroEnvio)
 {
     try
     {
         Logger.Info();
         var parametros =
             new Dictionary <string, object>
         {
             { "@UsuarioID", filtroEnvio.UsaurioID },
             { "@ProductoID", filtroEnvio.ProductoID },
             { "@Cantidad", filtroEnvio.Cantidad },
             { "@Activo", filtroEnvio.Activo }
         };
         return(parametros);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Guarda el envio de alimento
        /// </summary>
        /// <param name="sender">Objeto que invoco el evento</param>
        /// <param name="e">Parametros del evento</param>
        private void btnGuardar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (this.ValidarCamposVacios())
                {
                    if (EnvioAlimento.Destino != null && skAyudaDestino.Clave != EnvioAlimento.Destino.OrganizacionID.ToString())
                    {
                        EnvioAlimento.Destino = (OrganizacionInfo)skAyudaDestino.DataContext;
                        EnvioAlimento.Destino.ListaTiposOrganizacion = _tiposOrganizacionDestino;
                    }
                    if (EnvioAlimento.Producto != null && skAyudaProducto.Clave != EnvioAlimento.Producto.ProductoId.ToString())
                    {
                        EnvioAlimento.Producto.ProductoId = ((ProductoInfo)skAyudaDestino.DataContext).ProductoId;
                        if (EnvioAlimento.Producto != null)
                        {
                            EnvioAlimento.Producto.SubfamiliaId = int.Parse(cmbSubFamilia.SelectedValue.ToString());
                        }
                    }

                    if (this.ValidarCuentasContables())
                    {
                        int productoId = this.EnvioAlimento.Producto.ProductoId;
                        FiltroAlmacenProductoEnvio filtro = new FiltroAlmacenProductoEnvio
                        {
                            ProductoID = this.EnvioAlimento.Producto.ProductoId,
                            UsaurioID  = Extensor.ValorEntero(Application.Current.Properties["UsuarioID"].ToString()),
                            Cantidad   = false,
                            Activo     = true
                        };
                        List <AlmacenInfo> lstAlmacenes = this._envioAlimentoPL.ObtenerAlmacenesProducto(filtro);

                        if (lstAlmacenes == null)
                        {
                            SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.EnvioDeAlimento_MsgProductoSinAlmacen, MessageBoxButton.OK, MessageImage.Stop);
                            this.EnvioAlimento.Producto = new ProductoInfo {
                                ProductoId = 0, SubfamiliaId = (int)this.cmbSubFamilia.SelectedValue
                            };


                            lstAlmacenes           = new List <AlmacenInfo>();
                            cmbAlmacen.ItemsSource = lstAlmacenes;
                            this.skAyudaProducto.LimpiarCampos();
                            cmbAlmacen.IsEnabled = false;
                            return;
                        }

                        string error;
                        if (ValidarSalidaExcede(out error))
                        {
                            SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], error, MessageBoxButton.OK, MessageImage.Stop);

                            cmbAlmacen.SelectedIndex    = 0;
                            this.EnvioAlimento.Cantidad = 0;
                            this.EnvioAlimento.Importe  = 0;
                            this.EnvioAlimento.Piezas   = 0;
                            this.txtCantidadEnvio.Text  = string.Empty;
                            this.txtImporte.Text        = string.Empty;
                            this.txtPiezas.Text         = string.Empty;
                            return;
                        }
                        this.EnvioAlimento.Producto.ProductoId = productoId;
                        EnvioAlimentoInfo confirmacionEnvio = this._envioAlimentoPL.RegistrarEnvioAlimento(this.EnvioAlimento);
                        if (confirmacionEnvio.Folio != 0 && confirmacionEnvio.Poliza != null)
                        {
                            if (confirmacionEnvio.Poliza != null)
                            {
                                new ExportarPoliza().ImprimirPoliza(confirmacionEnvio.Poliza, string.Format("{0} {1}", "Poliza", TipoPoliza.SalidaTraspaso));
                            }

                            SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], string.Format(Properties.Resources.EnvioAlimento_MsgDatosGaurdados, confirmacionEnvio.Folio), MessageBoxButton.OK, MessageImage.Correct);
                            this.LimparPantalla();
                            this.InicializaContexto();
                            cmbSubFamilia.SelectedValue = 0;
                            this.EnvioAlimento.Destino.ListaTiposOrganizacion = _tiposOrganizacionDestino;
                            this.skAyudaDestino.txtClave.Focus();
                        }
                        else
                        {
                            SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.EnvioAlimento_MsgErrorGuardar, MessageBoxButton.OK, MessageImage.Error);
                        }
                    }
                }
            }
            catch (Exception excepcion)
            {
                Logger.Error(excepcion);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.EnvioAlimento_MsgErrorGuardar, MessageBoxButton.OK, MessageImage.Error);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Metodo que se invoca cuando la ayuda de seleccion de producto se des-selecciona
        /// </summary>
        /// <param name="sender">Objeto que invoco el evento</param>
        /// <param name="e">Parametros del evento</param>
        private void skAyudaProducto_LostFocus(object sender, RoutedEventArgs e)
        {
            this.EnvioAlimento.Producto = (ProductoInfo)this.skAyudaProducto.Contexto;
            this.EnvioAlimento.Producto.UsuarioModificacionID = int.Parse(Application.Current.Properties["UsuarioID"].ToString());
            if (this.EnvioAlimento.Producto.ProductoId > 0)
            {
                if (this.EnvioAlimento.Producto.SubFamilia != null)
                {
                    this.EnvioAlimento.Producto.SubfamiliaId = this.EnvioAlimento.Producto.SubFamilia.SubFamiliaID;
                }

                if (this.EnvioAlimento.Producto.SubfamiliaId != int.Parse(this.cmbSubFamilia.SelectedValue.ToString()))
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.EnvioDeAlimento_MsgProductoSubFamilia, MessageBoxButton.OK, MessageImage.Warning);
                    this.EnvioAlimento.Producto = new ProductoInfo {
                        ProductoId = 0, UsuarioModificacionID = int.Parse(Application.Current.Properties["UsuarioID"].ToString())
                    };
                    skAyudaProducto.Contexto = new ProductoInfo {
                        SubfamiliaId = (int)cmbSubFamilia.SelectedValue, UsuarioModificacionID = int.Parse(Application.Current.Properties["UsuarioID"].ToString())
                    };
                    this.skAyudaProducto.LimpiarCampos();

                    return;
                }

                if (this.EnvioAlimento.Producto.ManejaLote)
                {
                    this.OcultarLote(System.Windows.Visibility.Visible);
                }

                FiltroAlmacenProductoEnvio filtro = new FiltroAlmacenProductoEnvio
                {
                    ProductoID = this.EnvioAlimento.Producto.ProductoId,
                    UsaurioID  = Extensor.ValorEntero(Application.Current.Properties["UsuarioID"].ToString()),
                    Cantidad   = false,
                    Activo     = true
                };

                List <AlmacenInfo> lstAlmacenes = this._envioAlimentoPL.ObtenerAlmacenesProducto(filtro);
                if (lstAlmacenes == null)
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.EnvioDeAlimento_MsgProductoSinAlmacen, MessageBoxButton.OK, MessageImage.Stop);
                    this.EnvioAlimento.Producto = new ProductoInfo {
                        ProductoId = 0, SubfamiliaId = (int)this.cmbSubFamilia.SelectedValue
                    };
                    lstAlmacenes           = new List <AlmacenInfo>();
                    cmbAlmacen.ItemsSource = lstAlmacenes;
                    this.skAyudaProducto.LimpiarCampos();
                    cmbAlmacen.IsEnabled = false;
                    return;
                }

                filtro.Cantidad = true;
                lstAlmacenes    = this._envioAlimentoPL.ObtenerAlmacenesProducto(filtro);
                if (lstAlmacenes == null)
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.EnvioDeAlimento_MsgProductoSinInventario, MessageBoxButton.OK, MessageImage.Stop);
                    this.EnvioAlimento.Producto = new ProductoInfo {
                        ProductoId = 0, SubfamiliaId = (int)this.cmbSubFamilia.SelectedValue
                    };
                    lstAlmacenes           = new List <AlmacenInfo>();
                    cmbAlmacen.ItemsSource = lstAlmacenes;
                    this.skAyudaProducto.LimpiarCampos();
                    cmbAlmacen.IsEnabled = false;
                    return;
                }

                if (lstAlmacenes != null && lstAlmacenes.Count > 0)
                {
                    if (lstAlmacenes.Count > 1)
                    {
                        lstAlmacenes.Insert(0, new AlmacenInfo
                        {
                            AlmacenID   = 0,
                            Descripcion = Properties.Resources.cbo_Seleccione
                        });
                    }
                    else
                    {
                        this.CargarInformacionProducto(lstAlmacenes.FirstOrDefault().AlmacenID, lstAlmacenes.FirstOrDefault().Descripcion);
                    }
                    this.cmbAlmacen.IsEnabled    = true;
                    this.cmbAlmacen.ItemsSource  = lstAlmacenes;
                    this.cmbAlmacen.SelectedItem = lstAlmacenes.FirstOrDefault();
                    if (lstAlmacenes.Count == 1)
                    {
                        this.txtCantidadEnvio.Focus();
                    }
                    else
                    {
                        this.cmbAlmacen.Focus();
                    }
                }
                else
                {
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.EnvioAlimento_MsgProductoSinInventario, MessageBoxButton.OK, MessageImage.Stop);
                    this.EnvioAlimento.Producto = new ProductoInfo {
                        ProductoId = 0, SubfamiliaId = (int)this.cmbSubFamilia.SelectedValue
                    };

                    lstAlmacenes           = new List <AlmacenInfo>();
                    cmbAlmacen.ItemsSource = lstAlmacenes;
                    this.skAyudaProducto.LimpiarCampos();
                    cmbAlmacen.IsEnabled = false;
                    this.skAyudaProducto.LimpiarCampos();
                    this.skAyudaProducto.txtClave.Focus();
                }
            }
            else
            {
                cmbAlmacen.ItemsSource = new List <AlmacenInfo>();
                cmbAlmacen.IsEnabled   = false;
                skAyudaProducto.LimpiarCampos();
            }
        }