Beispiel #1
0
        public bool Insert(Orden_Producto t)
        {
            bool rpta = false;

            try
            {
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["BD_Pizza"].ToString()))
                {
                    con.Open();
                    var cmd = new SqlCommand("insert into Orden_Producto values (@COrden,@CProducto,@CEmpleado,@QOrdenProducto)", con);
                    cmd.Parameters.AddWithValue("@COrden", t.COrden.COrden);
                    cmd.Parameters.AddWithValue("@CProducto", t.CProducto.CProducto);
                    cmd.Parameters.AddWithValue("@CEmpleado", t.CEmpleado.CEmpleado);
                    cmd.Parameters.AddWithValue("@QOrdenProducto", t.QOrdenProducto);

                    cmd.ExecuteNonQuery();
                    rpta = true;
                    con.Close();
                }
            }
            catch (Exception)
            { throw; }

            return(rpta);
        }
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            Orden_Producto ordenprod = orden_ProductoService.FindById(id);

            return(View(ordenprod));
        }
        public bool Update(Orden_Producto t)
        {
            Producto producto = prodctRepository.FindById(t.CProducto.CProducto);
            Orden    orden    = ordenRepository.FindById(t.COrden.COrden);
            Empleado empleado = empleadoRepository.FindById(t.CEmpleado.CEmpleado);

            t.CProducto = producto;
            t.COrden    = orden;
            t.CEmpleado = empleado;

            return(orden_pro.Update(t));
        }
        public ActionResult Edit(int?id)
        {
            ViewBag.orden    = ordenService.FindAll();
            ViewBag.producto = productoService.FindAll();
            ViewBag.empleado = empleadoService.FindAll();
            if (id == null)
            {
                return(HttpNotFound());
            }
            Orden_Producto ordenprod = orden_ProductoService.FindById(id);

            return(View(ordenprod));
        }
        public ActionResult Create(Orden_Producto orden_Producto)
        {
            ViewBag.orden    = ordenService.FindAll();
            ViewBag.producto = productoService.FindAll();
            ViewBag.empleado = empleadoService.FindAll();

            bool rpta = orden_ProductoService.Insert(orden_Producto);

            if (rpta)
            {
                return(RedirectToAction("Index"));
            }

            return(View());
        }
        public ActionResult Edit(Orden_Producto ordenprod)
        {
            ViewBag.orden    = ordenService.FindAll();
            ViewBag.producto = productoService.FindAll();
            ViewBag.empleado = empleadoService.FindAll();
            if (!ModelState.IsValid)
            {
                return(View());
            }
            bool rpta = orden_ProductoService.Update(ordenprod);

            if (rpta)
            {
                return(RedirectToAction("Index"));
            }
            return(View());
        }
Beispiel #7
0
        public List <Orden_Producto> FindAll()
        {
            var ordenes = new List <Orden_Producto>();

            try
            {
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["BD_Pizza"].ToString()))
                {
                    con.Open();
                    var cmd = new SqlCommand("select op.COrden_Producto, op.COrden, o.CVenta, p.NProducto, ep.NEmpleado, op.QOrdenProducto from Orden_Producto op, Producto p, Empleado ep, Orden o where op.CProducto=p.CProducto and op.CEmpleado=ep.CEmpleado and op.COrden=o.COrden", con);

                    using (var dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            var orden_producto = new Orden_Producto();
                            var orden          = new Orden();
                            var venta          = new Venta();
                            var producto       = new Producto();
                            var empleado       = new Empleado();

                            orden_producto.COrden_Producto = Convert.ToInt32(dr["COrden_Producto"]);
                            orden.COrden                  = Convert.ToInt32(dr["COrden"]);
                            venta.CVenta                  = Convert.ToInt32(dr["CVenta"]);
                            orden.CVenta                  = venta;
                            orden_producto.COrden         = orden;
                            producto.NProducto            = dr["NProducto"].ToString();
                            orden_producto.CProducto      = producto;
                            empleado.NEmpleado            = dr["NEmpleado"].ToString();
                            orden_producto.CEmpleado      = empleado;
                            orden_producto.QOrdenProducto = Convert.ToInt32(dr["QOrdenProducto"]);
                            ordenes.Add(orden_producto);
                        }
                    }
                    con.Close();
                }
            }
            catch (Exception)
            { throw; }

            return(ordenes);
        }
Beispiel #8
0
        public bool Update(Orden_Producto t)
        {
            bool rpta = false;

            try
            {
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["BD_Pizza"].ToString()))
                {
                    con.Open();

                    var cmd = new SqlCommand("update Orden_Producto set COrden=@COrden,CProducto=@CProducto,CEmpleado=@CEmpleado, QOrdenProducto = @QOrdenProducto where COrden_Producto=@id", con);
                    cmd.Parameters.AddWithValue("@id", t.COrden_Producto);
                    cmd.Parameters.AddWithValue("@COrden", t.COrden.COrden);
                    cmd.Parameters.AddWithValue("@CProducto", t.CProducto.CProducto);
                    cmd.Parameters.AddWithValue("@CEmpleado", t.CEmpleado.CEmpleado);
                    cmd.Parameters.AddWithValue("@QOrdenProducto", t.QOrdenProducto);
                    cmd.ExecuteNonQuery();
                    rpta = true;
                }
            }
            catch (Exception)
            { throw; }
            return(rpta);
        }