Ejemplo n.º 1
0
        public ActionResult Actualizar(string refe, string nombre, string precio, string tipo, string proveedor, HttpPostedFileBase img)
        {
            int precioCompra = int.Parse(productoDAO.MostrarDatos(refe).Rows[0][6].ToString());

            if (int.Parse(precio) < precioCompra)
            {
                return(Json("falseP", JsonRequestBehavior.AllowGet));
            }
            if (refe == "" || nombre == "" || precio == "" || tipo == "" || proveedor == "")
            {
                return(Json("false", JsonRequestBehavior.AllowGet));
            }
            else
            {
                string ruta = "";
                if (img != null)
                {
                    ruta  = Server.MapPath("~/Imagenes/");
                    ruta += img.FileName;
                    img.SaveAs(ruta);
                    productoDAO.SubirImagen("/Imagenes/" + img.FileName, refe);
                }
                ProductoVO proVo = new ProductoVO(nombre, refe, precio, null, tipo, null, proveedor, null);
                productoDAO.ActualizarProducto(proVo, int.Parse(Session["id"].ToString()));
                return(Json("true", JsonRequestBehavior.AllowGet));
            }


            //return Json("true", JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 2
0
        private void ActualizarProducto()
        {
            if (ImagenFueModificada)
            {
                Producto.Imagen = ServiciosDeIO.CargarBytesDeArchivo(DireccionDeArchivo);
            }
            Producto.Nombre         = TextBoxNombre.Text;
            Producto.Codigo         = TextBoxCodigo.Text;
            Producto.CodigoDeBarras = TextBoxCodigoDeBarras.Text;
            Producto.Creador        = Gerente.Nombre;

            ProductoDAO productoDAO = new ProductoDAO();

            try
            {
                productoDAO.ActualizarProducto(Producto);
            }
            catch (Exception e)
            {
                MessageBox.Show("Hubo un problema conectandose a la base de datos. Contacte a su administrador.", "Error", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            MessageBox.Show("¡El producto fue actualizado exitosamente!", "¡Exito!", MessageBoxButton.OK, MessageBoxImage.Information);
            Controlador.Regresar();
        }
Ejemplo n.º 3
0
        public void Modificar()
        {
            ProductoBO oprod = InterfaceToData();

            if (oprod.Id > 0)
            {
                oProductoDAO.ActualizarProducto(oprod);
            }

            FacadeMth("Limpia");
        }
Ejemplo n.º 4
0
 public void AumentarIngredienteInventario(int cantidad)
 {
     if (Activo)
     {
         ProductoDAO productoDAO = new ProductoDAO();
         this.CantidadEnInventario += cantidad;
         productoDAO.ActualizarProducto(this);
     }
     else
     {
         throw new ArgumentException("No se ha podido realizar el aumento");
     }
 }
Ejemplo n.º 5
0
 internal void DescontarIngredientesDeInventario(int cantidad)
 {
     if (this.ValidarCantidadAlimento(cantidad))
     {
         ProductoDAO productoDAO = new ProductoDAO();
         this.CantidadEnInventario -= cantidad;
         productoDAO.ActualizarProducto(this);
     }
     else
     {
         throw new ArgumentException("No hay suficientes existencias para realizar el descuento");
     }
 }
Ejemplo n.º 6
0
        public IHttpActionResult Actualizar(Producto producto)
        {
            var respuestaActualizar = ProductoDAO.ActualizarProducto(producto);

            if (respuestaActualizar)
            {
                return(Ok(202));
            }
            else
            {
                return(Content(HttpStatusCode.InternalServerError, producto));
            }
        }
Ejemplo n.º 7
0
        private void GuardarCambiosButton_Click(object sender, RoutedEventArgs e)
        {
            IngredienteDAO ingredienteDAO = new IngredienteDAO();
            ProductoDAO    productoDAO    = new ProductoDAO();

            foreach (Discrepancia discrepancia in Discrepancias)
            {
                if (discrepancia.TipoDeProducto == TipoDeProducto.Ingrediente)
                {
                    Ingrediente ingrediente = ingredienteDAO.CargarIngredientePorId(discrepancia.Id);
                    ingrediente.CantidadEnInventario = discrepancia.CantidadRegistrada;
                    ingredienteDAO.ActualizarIngrediente(ingrediente);
                }
                else if (discrepancia.TipoDeProducto == TipoDeProducto.Producto)
                {
                    Producto producto = productoDAO.CargarProductoPorID(discrepancia.Id);
                    producto.CantidadEnInventario = (int)discrepancia.CantidadRegistrada;
                    productoDAO.ActualizarProducto(producto);
                }
            }

            MessageBox.Show("Los cambios fueron realizados con exito", "¡Exito¡");
        }
Ejemplo n.º 8
0
 public ActionResult EditarProducto(ProductoBEAN oProd)
 {
     oProdDAO.ActualizarProducto(oProd);
     return(RedirectToAction("ListaProducto"));
 }