public ActionResult AgregarProducto(HttpPostedFileBase img, string refe, string nombre, string precio, string precioCompra, string tipo, string proveedor)
        {
            string ruta = "";

            if (img != null && refe != "" && nombre != "" && precio != "" && precioCompra != "" && tipo != "" && proveedor != "")
            {
                int  valor         = 0;
                bool comprobacion  = int.TryParse(precio, out valor);
                bool comprobacion1 = int.TryParse(precioCompra, out valor);
                if (comprobacion == true && comprobacion1 == true)
                {
                    ProductoVO proVo = new ProductoVO(nombre, refe, precio, null, tipo, null, proveedor, precioCompra);
                    if (productoDAO.AgregarProducto(proVo))
                    {
                        ruta  = Server.MapPath("~/Imagenes/");
                        ruta += img.FileName;
                        img.SaveAs(ruta);
                        productoDAO.SubirImagen("/Imagenes/" + img.FileName, refe);
                        return(Json("true", JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    return(Json("Los campos precio y precio de compra no pueden contener letras", JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json("false", JsonRequestBehavior.AllowGet));
            }

            return(Json("llegue aqui pero no hice nada", JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
 public Result AgregarProducto(Producto producto)
 {
     try
     {
         return(productoDAO.AgregarProducto(producto));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void Agregar()
        {
            ProductoBO oProd = InterfaceToData();

            if (oProd.Id == 0)
            {
                oProductoDAO.AgregarProducto(oProd);
            }

            FacadeMth("Limpia");
        }
        protected void btnAceptar_Click(object sender, EventArgs e)
        {
            Producto producto = new Producto(Int32.Parse(idTextBox.Text), nombreTextBox.Text, categoriaDDList.SelectedValue, origenDDList.SelectedValue, Double.Parse(precioTextBox.Text), Int32.Parse(cantidadTextBox.Text));

            this.dao = new ProductoDAO();
            if (dao.AgregarProducto(producto))
            {
                lblResultado.Text = "Producto agregado con éxito";
            }
            else
            {
                lblResultado.Text = "El ID ingresado ya está en uso";
            }
        }