コード例 #1
0
ファイル: ProductoController.cs プロジェクト: giancar70/Tesis
        //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);
        }
コード例 #2
0
ファイル: ProductoDao.cs プロジェクト: giancar70/Tesis
        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();
                }
            }
        }