Exemplo n.º 1
0
 // 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"));
     }
 }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
 // 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"));
     }
 }
Exemplo n.º 4
0
 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));
 }
Exemplo n.º 5
0
 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());
     }
 }
Exemplo n.º 6
0
        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;
            }
        }
Exemplo n.º 7
0
 // 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());
     }
 }