Example #1
0
        //idProducto
        public ActionResult AñadirIngredientes(string ID)
        {
            ProductoBean producto = Ventafacade.BuscarProducto(ID);

            List<IngredienteBean> Ingredientes = Almacenfacade.ListarIngrediente("");
            ProductoxIngredienteBean ProdIngre = new ProductoxIngredienteBean();
            ProdIngre.nombreProducto = producto.nombre;
            ProdIngre.idProducto = producto.id;
            ProdIngre.tipo = Ventafacade.get_tipo(producto.idTipo);
            ProdIngre.listaIngredientes = new List<ProductoxIngrediente>();
            ProductoxIngredienteBean aux = Ventafacade.obtenerlistadeingredientesdeProducto(ID);

            for (int j = 0; j < Ingredientes.Count; j++)
            {
                ProductoxIngrediente product = new ProductoxIngrediente();
                product.id = Ingredientes[j].id;
                product.nombre = Ingredientes[j].nombre;
                for (int i = 0; i < aux.listaIngredientes.Count; i++)
                {
                    if (aux.listaIngredientes[i].id == Ingredientes[j].id) product.estadod_disponible = true;
                }
                ProdIngre.listaIngredientes.Add(product);
            }

            return View(ProdIngre);
        }
Example #2
0
        public void AñadirIngredientes(ProductoxIngredienteBean Producxingre)
        {
            SqlConnection objDB = null;
            try
            {
                objDB = new SqlConnection(cadenaDB);
                objDB.Open();
                for (int i = 0; i < Producxingre.listaIngredientes.Count; i++)
                {
                    if (Producxingre.listaIngredientes[i].cantidad > 0)
                    {
                        String strQuery = "Insert into Producto_x_Ingrediente (idProducto,idIngrediente,cantidad, unidaddemedida) values " +
                                            "(@idproducto,@idingrediente,@cantidad,@unidad)";

                        SqlCommand objQuery = new SqlCommand(strQuery, objDB);
                        Utils.agregarParametro(objQuery, "@idproducto", Producxingre.idProducto);
                        Utils.agregarParametro(objQuery, "@idingrediente", Producxingre.listaIngredientes[i].id);
                        Utils.agregarParametro(objQuery, "@cantidad", Producxingre.listaIngredientes[i].cantidad);
                        Utils.agregarParametro(objQuery, "@unidad", Producxingre.listaIngredientes[i].medida);
                        objQuery.ExecuteNonQuery();
                    }
                }

            }
            catch (Exception ex)
            {
                log.Error("Añadir IngredientesxProducto(EXCEPTION): ", ex);
                throw ex;
            }
            finally
            {
                if (objDB != null)
                {
                    objDB.Close();
                }
            }
        }
Example #3
0
        public void ModificarIngredientes(ProductoxIngredienteBean Producxingre)
        {
            SqlConnection objDB = null;
            try
            {
                objDB = new SqlConnection(cadenaDB);
                objDB.Open();
                for (int i = 0; i < Producxingre.listaIngredientes.Count; i++)
                {
                    String strQuery = "Update Producto_x_Ingrediente SET cantidad = @cantidad, unidaddemedida=@unidad  where idProducto=@idproducto and idIngrediente=@idingrediente ";

                    SqlCommand objQuery = new SqlCommand(strQuery, objDB);
                    Utils.agregarParametro(objQuery, "@idproducto", Producxingre.idProducto);
                    Utils.agregarParametro(objQuery, "@idingrediente", Producxingre.listaIngredientes[i].id);
                    Utils.agregarParametro(objQuery, "@cantidad", Producxingre.listaIngredientes[i].cantidad);
                    Utils.agregarParametro(objQuery, "@unidad", Producxingre.listaIngredientes[i].medida);
                    objQuery.ExecuteNonQuery();

                }

            }
            catch (Exception ex)
            {
                log.Error("Modificar IngredientesxProducto(EXCEPTION): ", ex);
                throw ex;
            }
            finally
            {
                if (objDB != null)
                {
                    objDB.Close();
                }
            }
        }
Example #4
0
        public ProductoxIngredienteBean listaIngredientes(string ID)
        {
            SqlConnection objDB = null;
            try
            {
                objDB = new SqlConnection(cadenaDB);
                ProductoxIngredienteBean produc = null;

                objDB.Open();
                String strQuery = "SELECT * FROM Producto_x_Ingrediente WHERE idProducto = @ID";
                SqlCommand objquery = new SqlCommand(strQuery, objDB);
                BaseDatos.agregarParametro(objquery, "@ID", ID);

                SqlDataReader objDataReader = objquery.ExecuteReader();
                produc = new ProductoxIngredienteBean();
                produc.listaIngredientes = new List<ProductoxIngrediente>();
                if (objDataReader.HasRows)
                {
                    while (objDataReader.Read())
                    {
                        ProductoxIngrediente aux = new ProductoxIngrediente();
                        aux.id = Convert.ToString(objDataReader["idIngrediente"]);
                        aux.cantidad = (int)objDataReader["cantidad"];
                        aux.medida = (string)objDataReader["unidaddemedida"];
                        produc.listaIngredientes.Add(aux);
                    }
                }
                return produc;
            }
            catch (Exception ex)
            {
                log.Error("Get_ListadeIngredientesxProducto(EXCEPTION): ", ex);
                throw ex;
            }
            finally
            {
                if (objDB != null)
                {
                    objDB.Close();
                }
            }
        }
Example #5
0
 public ActionResult AñadirIngredientes( ProductoxIngredienteBean prodIngre)
 {
     Ventafacade.AñadirIngredientesdeproducto(prodIngre);
     return RedirectToAction("ListarIngredientes/" + prodIngre.idProducto, "Producto");
 }
Example #6
0
 public ActionResult ModificarIngredientes(ProductoxIngredienteBean prodxingre)
 {
     return View(prodxingre);
 }
Example #7
0
 public ActionResult ModificarIngredientes2(ProductoxIngredienteBean prodxingre)
 {
     Ventafacade.Modificaringredientesdeproducto(prodxingre);
     return RedirectToAction("ListarIngredientes/" + prodxingre.idProducto, "Producto");
 }
Example #8
0
        public ViewResult ListarIngredientes(string ID)
        {
            ProductoBean producto = Ventafacade.BuscarProducto(ID);
            ProductoxIngredienteBean prodIngr = new ProductoxIngredienteBean();
            prodIngr = Ventafacade.obtenerlistadeingredientesdeProducto(ID);
            prodIngr.nombreProducto = producto.nombre;
            prodIngr.idProducto = producto.id;
            prodIngr.tipo = Ventafacade.get_tipo(producto.idTipo);
            if (prodIngr.listaIngredientes.Count > 0) ViewBag.estado = 0;
            else ViewBag.estado = 1;
            for (int i = 0; i < prodIngr.listaIngredientes.Count; i++)
            {
                IngredienteBean Ingre = Almacenfacade.buscaringrediente(prodIngr.listaIngredientes[i].id);
                prodIngr.listaIngredientes[i].nombre = Ingre.nombre;

            }
            return View(prodIngr);
        }
Example #9
0
 public void Modificaringredientesdeproducto(ProductoxIngredienteBean ProdxIngred)
 {
     ProductoService.ModificarIngredientesdeproducto(ProdxIngred);
 }
Example #10
0
 public void AñadirIngredientesdeproducto(ProductoxIngredienteBean ProdxIngred)
 {
     ProductoService.AñadirIngredientesdeproducto(ProdxIngred);
 }
Example #11
0
 public void ModificarIngredientesdeproducto(ProductoxIngredienteBean ProdxIngre)
 {
     ProductoDAo.ModificarIngredientes(ProdxIngre);
 }
Example #12
0
 public void AñadirIngredientesdeproducto(ProductoxIngredienteBean ProdxIngre)
 {
     ProductoDAo.AñadirIngredientes(ProdxIngre);
 }