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")); }
// 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)); }
// 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)); }
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")); }