Example #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (Session["ID"] == null || !roles.tienePermiso(8, int.Parse(Session["ID"].ToString())))
            {
                return(RedirectToAction("Index", "Home"));
            }
            OrdenDePedido ordenDePedido = db.OrdenesPedido.Find(id);

            ordenDePedido.eliminarDetalle();
            db.OrdenesPedido.Remove(ordenDePedido);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #2
0
        // GET: OrdenDePedido/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OrdenDePedido ordenDePedido = db.OrdenesPedido.Find(id);

            if (ordenDePedido == null)
            {
                return(HttpNotFound());
            }
            return(View(ordenDePedido));
        }
Example #3
0
        // GET: OrdenDePedido/Delete/5
        public ActionResult Delete(int?id)
        {
            if (Session["ID"] == null || !roles.tienePermiso(8, int.Parse(Session["ID"].ToString())))
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OrdenDePedido ordenDePedido = db.OrdenesPedido.Find(id);

            if (ordenDePedido == null)
            {
                return(HttpNotFound());
            }
            return(View(ordenDePedido));
        }
Example #4
0
        public ActionResult Create([Bind(Include = "OrdenDePedidoID,numeroOrden,año,señores,fecha,encabezado,trabajoARealizar,personaResponsable,nombreSolicitante,fechaSolicitud")] OrdenDePedido ordenDePedido,
                                   FormCollection post)
        {
            if (Session["ID"] == null || !roles.tienePermiso(8, int.Parse(Session["ID"].ToString())))
            {
                return(RedirectToAction("Index", "Home"));
            }
            ordenDePedido.numeroOrden = ordenDePedido.obtenerNuevoNumero();
            ordenDePedido.año         = DateTime.Now.Year;

            string Fecha = post["fecha"].ToString();

            ordenDePedido.fecha = new DateTime(int.Parse(Fecha.Split('/')[2]),
                                               int.Parse(Fecha.Split('/')[1]), int.Parse(Fecha.Split('/')[0]));

            Fecha = post["fechaSolicitud"].ToString();

            ordenDePedido.fechaSolicitud = new DateTime(int.Parse(Fecha.Split('/')[2]),
                                                        int.Parse(Fecha.Split('/')[1]), int.Parse(Fecha.Split('/')[0]));

            ordenDePedido.quitarNulos();

            db.OrdenesPedido.Add(ordenDePedido);

            db.SaveChanges();

            //Se guarda el detalle:
            string[] detalleDetalle  = Request.Form.GetValues("detalleDetalle");
            string[] cantidadDetalle = Request.Form.GetValues("cantidadDetalle");

            for (int i = 0; i < detalleDetalle.Length; i++)
            {
                detalleOrdenPedido nuevo = new detalleOrdenPedido();

                nuevo.detalle         = detalleDetalle[i];
                nuevo.cantidad        = int.Parse(cantidadDetalle[i]);
                nuevo.OrdenDePedidoID = ordenDePedido.OrdenDePedidoID;

                db.DetalleOrdenesPedido.Add(nuevo);
            }

            db.SaveChanges();
            return(RedirectToAction("Index"));
        }