示例#1
0
        public bool Update(Producto_Ingrediente t)
        {
            bool rpta = false;

            try
            {
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["BD_Pizza"].ToString()))
                {
                    con.Open();
                    var cmd = new SqlCommand("update Producto_Ingrediente set CIngrediente=@cingrediente, QUsadaIngrediente=@qusada, NUnidadMedidaUsada=@nusada where CProducto_Ingrediente=@id", con);
                    cmd.Parameters.AddWithValue("@id", t.CProducto_Ingrediente);
                    cmd.Parameters.AddWithValue("@cingrediente", t.CIngrediente.CIngrediente);
                    cmd.Parameters.AddWithValue("@qusada", t.QUsadaIngrediente);
                    cmd.Parameters.AddWithValue("@nusada", t.NUnidadMedidaUsada);
                    cmd.ExecuteNonQuery();
                    con.Close();
                    rpta = true;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(rpta);
        }
示例#2
0
        public bool Insert(Producto_Ingrediente t)
        {
            bool rpta = false;

            try
            {
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["BD_Pizza"].ToString()))
                {
                    con.Open();
                    var cmd = new SqlCommand("insert into Producto_Ingrediente values (@idprodct, @idingrdnt, @qusada, @nusada)", con);
                    cmd.Parameters.AddWithValue("@idprodct", t.CProducto.CProducto);
                    cmd.Parameters.AddWithValue("@idingrdnt", t.CIngrediente.CIngrediente);
                    cmd.Parameters.AddWithValue("@qusada", t.QUsadaIngrediente);
                    cmd.Parameters.AddWithValue("@nusada", t.NUnidadMedidaUsada);
                    cmd.ExecuteNonQuery();
                    con.Close();
                    rpta = true;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(rpta);
        }
示例#3
0
        public bool Update(Producto_Ingrediente t)
        {
            Producto    producto    = prodctRepository.FindById(t.CProducto.CProducto);
            Ingrediente ingrediente = ingrdntRepository.FindById(t.CIngrediente.CIngrediente);

            t.CProducto    = producto;
            t.CIngrediente = ingrediente;
            return(prodctingrdntRepository.Update(t));
        }
示例#4
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            Producto_Ingrediente prodct_ingrdnt = prodct_ingrdntService.FindById(id);

            return(View(prodct_ingrdnt));
        }
示例#5
0
        public ActionResult Edit(int?id)
        {
            ViewBag.producto    = prodctService.FindAll();
            ViewBag.ingrediente = ingrdntService.FindAll();
            if (id == null)
            {
                return(HttpNotFound());
            }
            Producto_Ingrediente prodct_ingrdnt = prodct_ingrdntService.FindById(id);

            return(View(prodct_ingrdnt));
        }
示例#6
0
        public ActionResult Create(Producto_Ingrediente prodct_ingrdnt)
        {
            ViewBag.producto    = prodctService.FindAll();
            ViewBag.ingrediente = ingrdntService.FindAll();
            bool rpta = prodct_ingrdntService.Insert(prodct_ingrdnt);

            if (rpta)
            {
                return(RedirectToAction("Index"));
            }
            return(View());
        }
示例#7
0
        public ActionResult Edit(Producto_Ingrediente prodct_ingrdnt)
        {
            ViewBag.producto    = prodctService.FindAll();
            ViewBag.ingrediente = ingrdntService.FindAll();
            if (!ModelState.IsValid)
            {
                return(View());
            }
            bool rpta = prodct_ingrdntService.Update(prodct_ingrdnt);

            if (rpta)
            {
                return(RedirectToAction("Index"));
            }
            return(View());
        }
示例#8
0
        public List <Producto_Ingrediente> FindAll()
        {
            var arr_prodctingrednt = new List <Producto_Ingrediente>();

            try
            {
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["BD_Pizza"].ToString()))
                {
                    con.Open();
                    var cmd = new SqlCommand("select pi.CProducto_Ingrediente, p.NProducto, i.NIngrediente, pi.QUsadaIngrediente, pi.NUnidadMedidaUsada from Producto_Ingrediente pi, Producto p, Ingrediente i where pi.CProducto=p.CProducto and pi.CIngrediente=i.CIngrediente", con);
                    using (var dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            var productoingrediente = new Producto_Ingrediente();
                            var producto            = new Producto();
                            var ingrediente         = new Ingrediente();

                            productoingrediente.CProducto_Ingrediente = Convert.ToInt32(dr["CProducto_Ingrediente"]);
                            producto.NProducto                     = dr["NProducto"].ToString();
                            productoingrediente.CProducto          = producto;
                            ingrediente.NIngrediente               = dr["NIngrediente"].ToString();
                            productoingrediente.CIngrediente       = ingrediente;
                            productoingrediente.QUsadaIngrediente  = Convert.ToInt32(dr["QUsadaIngrediente"]);
                            productoingrediente.NUnidadMedidaUsada = dr["NUnidadMedidaUsada"].ToString();
                            arr_prodctingrednt.Add(productoingrediente);
                        }
                    }
                    con.Close();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(arr_prodctingrednt);
        }
示例#9
0
        public Producto_Ingrediente FindById(int?id)
        {
            Producto_Ingrediente productoingrediente = null;

            try
            {
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["BD_Pizza"].ToString()))
                {
                    con.Open();
                    var cmd = new SqlCommand("select pi.CProducto_Ingrediente, p.NProducto, i.NIngrediente, pi.QUsadaIngrediente, pi.NUnidadMedidaUsada from Producto_Ingrediente pi, Producto p, Ingrediente i where pi.CProducto=p.CProducto and pi.CIngrediente=i.CIngrediente and pi.CProducto_Ingrediente='" + id + "'", con);
                    using (var dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            productoingrediente = new Producto_Ingrediente();
                            var producto    = new Producto();
                            var ingrediente = new Ingrediente();

                            productoingrediente.CProducto_Ingrediente = Convert.ToInt32(dr["CProducto_Ingrediente"]);
                            producto.NProducto                     = dr["NProducto"].ToString();
                            productoingrediente.CProducto          = producto;
                            ingrediente.NIngrediente               = dr["NIngrediente"].ToString();
                            productoingrediente.CIngrediente       = ingrediente;
                            productoingrediente.QUsadaIngrediente  = Convert.ToInt32(dr["QUsadaIngrediente"]);
                            productoingrediente.NUnidadMedidaUsada = dr["NUnidadMedidaUsada"].ToString();
                        }
                    }
                    con.Close();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(productoingrediente);
        }