// GET: Repair/Details/5 public ActionResult Details(int?id) { if (Session["OnlineUser"] != null) { if (Session["UserRole"].Equals("SUPERADMIN") || Session["UserRole"].Equals("SUBADMIN")) { ViewBag.OnlineUser = Session["UserName"].ToString(); ViewBag.OnlineUserRole = Session["UserRole"].ToString(); if (id == null) { return(RedirectToAction("Err", "Home", new { code = "E-1133", text = "هیچ شناسه ای وارد نشده", url = string.Format("{0}/", RouteData.Values["controller"].ToString()) })); } tbl_Repair tbl_Repair = db.tbl_Repair.Find(id); if (tbl_Repair == null) { return(RedirectToAction("Err", "Home", new { code = "E-1133", text = "هیچ عملیاتی ای با شناسه وارد شده ثبت نشده است", url = string.Format("{0}/", RouteData.Values["controller"].ToString()) })); } return(View(tbl_Repair)); } else { return(RedirectToAction("Accessdenied", "Home")); } } else { return(RedirectToAction("Login", "Account")); } }
public ActionResult Create([Bind(Include = "RepairId,RepairDescription,RepairPrice,RepairTitel,MaterialId,StateId")] tbl_Repair tbl_Repair) { Random rand = new Random(); int ra; if (ModelState.IsValid) { if (Session["OnlineUser"] != null) { if (Session["UserRole"].Equals("SUPERADMIN")) { ra = rand.Next(1000000, 2000000); while (db.tbl_Repair.FirstOrDefault(f => f.RepairId == ra) != null) { ra = rand.Next(1000000, 2000000); } tbl_Repair.RepairId = ra; db.tbl_Repair.Add(tbl_Repair); db.SaveChanges(); return(RedirectToAction("Index")); } else { return(RedirectToAction("Accessdenied", "Home")); } } else { return(RedirectToAction("Login", "Account")); } } ViewBag.MaterialId = new SelectList(db.tbl_Material, "MaterialId", "MaterialCode", tbl_Repair.MaterialId); return(View(tbl_Repair)); }
// GET: Repair/Delete/5 public ActionResult Delete(int?id) { if (Session["OnlineUser"] != null) { if (Session["UserRole"].Equals("SUPERADMIN") || Session["UserRole"].Equals("SUBADMIN")) { ViewBag.OnlineUser = Session["UserName"].ToString(); ViewBag.OnlineUserRole = Session["UserRole"].ToString(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tbl_Repair tbl_Repair = db.tbl_Repair.Find(id); if (tbl_Repair == null) { return(HttpNotFound()); } return(View(tbl_Repair)); } else { return(RedirectToAction("Accessdenied", "Home")); } } else { return(RedirectToAction("Login", "Account")); } }
public ActionResult Edit([Bind(Include = "RepairId,RepairDescription,RepairPrice,RepairTitel,MaterialId,StateId")] tbl_Repair tbl_Repair) { if (ModelState.IsValid) { if (Session["OnlineUser"] != null) { if (Session["UserRole"].Equals("SUPERADMIN") || Session["UserRole"].Equals("SUBADMIN")) { ViewBag.OnlineUser = Session["UserName"].ToString(); ViewBag.OnlineUserRole = Session["UserRole"].ToString(); ViewBag.StationName = db.tbl_State.ToList(); db.Entry(tbl_Repair).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } else { return(RedirectToAction("Accessdenied", "Home")); } } else { return(RedirectToAction("Login", "Account")); } } ViewBag.MaterialId = new SelectList(db.tbl_Material, "MaterialId", "MaterialCode", tbl_Repair.MaterialId); return(View(tbl_Repair)); }
public ActionResult DeleteConfirmed(int id) { try { tbl_Repair tbl_Repair = db.tbl_Repair.Find(id); db.tbl_Repair.Remove(tbl_Repair); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError(ex.Message, ex.InnerException.ToString()); return(View()); } }
public ActionResult DeleteConfirmed(int id) { try { tbl_Repair tbl_Repair = db.tbl_Repair.Find(id); db.tbl_Repair.Remove(tbl_Repair); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception) { return(RedirectToAction("Err", "Home", new { code = "E-1133", text = "ارور بررسی نشده", url = string.Format("{0}/", RouteData.Values["controller"].ToString()) })); throw; } }
// GET: Repair/Edit/5 public ActionResult Edit(int?id) { try { if (Session["OnlineUser"] != null) { if (Session["UserRole"].Equals("SUPERADMIN") || Session["UserRole"].Equals("SUBADMIN")) { ViewBag.OnlineUser = Session["UserName"].ToString(); ViewBag.OnlineUserRole = Session["UserRole"].ToString(); ViewBag.StationName = db.tbl_State.ToList(); if (id == null) { return(RedirectToAction("Err", "Home", new { code = "E-1133", text = "هیچ شناسه ای وارد نشده", url = string.Format("{0}/", RouteData.Values["controller"].ToString()) })); } tbl_Repair tbl_Repair = db.tbl_Repair.Find(id); if (tbl_Repair == null) { return(RedirectToAction("Err", "Home", new { code = "E-1133", text = "هیچ عملیاتی ای با شناسه وارد شده ثبت نشده است", url = string.Format("{0}/", RouteData.Values["controller"].ToString()) })); } ViewBag.MaterialId = new SelectList(db.tbl_Material, "MaterialId", "MaterialCode", tbl_Repair.MaterialId); return(View(tbl_Repair)); } else { return(RedirectToAction("Accessdenied", "Home")); } } else { return(RedirectToAction("Login", "Account")); } } catch (Exception ex) { ModelState.AddModelError(ex.Message, ex.InnerException.ToString()); return(View()); } }