public ActionResult DeleteConfirmed(int id)
        {
            if (Session["ID"] != null)
            {
                var typeName = (string)Session["Type"]; var type = db.EmployeeTypes.Where(x => x.Type == typeName).FirstOrDefault();
                if (type.AddSchoolManagingTools == true)
                {
                    Study_subject study_subject = db.Study_subject.Find(id);
                    db.Study_subject.Remove(study_subject);
                    try
                    {
                        db.SaveChanges();
                    }
                    catch
                    {
                        ViewBag.TitleSideBar = "Study_subject";

                        ViewBag.error = "يوجد مدخلات اخرى متعلقة بهذا المادة يرجى تغييرها قبل الحذف";
                        return(View(study_subject));
                    }
                    return(RedirectToAction("Index"));
                }
                return(RedirectToAction("Default", "Home"));
            }
            return(RedirectToAction("Index", "Home"));
        }
Example #2
0
 public ActionResult Edit([Bind(Include = "id,Name,Desc,FullMark,LeastMark,State")] Study_subject study_subject)
 {
     if (ModelState.IsValid)
     {
         db.Entry(study_subject).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(study_subject));
 }
        public ActionResult Edit([Bind(Include = "id,Name,Desc,FullMark,LeastMark,State")] Study_subject study_subject)
        {
            if (ModelState.IsValid)
            {
                db.Entry(study_subject).State = EntityState.Modified;
                db.SaveChanges();
                TempData["Message"] = "تم التعديل بنجاح";
                return(RedirectToAction("Index"));
            }
            ViewBag.TitleSideBar = "Study_subject";

            return(View(study_subject));
        }
Example #4
0
 public ActionResult DeleteConfirmed(int id)
 {
     if (Session["ID"] != null)
     {
         var typeName = (string)Session["Type"]; var type = db.EmployeeTypes.Where(x => x.Type == typeName).FirstOrDefault();
         if (type.Managment == true)
         {
             Study_subject study_subject = db.Study_subject.Find(id);
             db.Study_subject.Remove(study_subject);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(RedirectToAction("Default", "Home"));
     }
     return(RedirectToAction("Index", "Home"));
 }
Example #5
0
        public ActionResult Create([Bind(Include = "Name,Desc,FullMark,LeastMark,State")] Study_subject study_subject)
        {
            try
            {
                study_subject.id = db.Study_subject.OrderByDescending(x => x.id).FirstOrDefault().id + 1;
            }
            catch (Exception)
            {
                study_subject.id = 1;
            }
            if (ModelState.IsValid)
            {
                db.Study_subject.Add(study_subject);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(study_subject));
        }
        public ActionResult Create([Bind(Include = "Name,Desc,FullMark,LeastMark,State")] Study_subject study_subject)
        {
            try
            {
                study_subject.id = db.Study_subject.OrderByDescending(x => x.id).FirstOrDefault().id + 1;
            }
            catch (Exception)
            {
                study_subject.id = 1;
            }
            if (ModelState.IsValid)
            {
                db.Study_subject.Add(study_subject);
                db.SaveChanges();
                TempData["Message"] = "تم الادخال بنجاح";
                return(RedirectToAction("Index"));
            }
            ViewBag.TitleSideBar = "Study_subject";

            return(View(study_subject));
        }
Example #7
0
 // GET: Study_subject/Edit/5
 public ActionResult Edit(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     if (Session["ID"] != null)
     {
         var typeName = (string)Session["Type"]; var type = db.EmployeeTypes.Where(x => x.Type == typeName).FirstOrDefault();
         if (type.Managment == true)
         {
             Study_subject study_subject = db.Study_subject.Find(id);
             if (study_subject == null)
             {
                 return(HttpNotFound());
             }
             return(View(study_subject));
         }
         return(RedirectToAction("Default", "Home"));
     }
     return(RedirectToAction("Index", "Home"));
 }
        // GET: Study_subject/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Default", "Home"));
            }
            if (Session["ID"] != null)
            {
                var typeName = (string)Session["Type"]; var type = db.EmployeeTypes.Where(x => x.Type == typeName).FirstOrDefault();
                if (type.SeeAccToCenter == true || type.SeeAccToCity == true || type.SeeAll == true || type.SeeAllButFinance == true || type.SeeTeachers == true)
                {
                    Study_subject study_subject = db.Study_subject.Find(id);
                    if (study_subject == null)
                    {
                        return(HttpNotFound());
                    }
                    ViewBag.TitleSideBar = "Study_subject";

                    return(View(study_subject));
                }
                return(RedirectToAction("Default", "Home"));
            }
            return(RedirectToAction("Index", "Home"));
        }
        // GET: Study_subject/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Default", "Home"));
            }
            if (Session["ID"] != null)
            {
                var typeName = (string)Session["Type"]; var type = db.EmployeeTypes.Where(x => x.Type == typeName).FirstOrDefault();
                if (type.AddSchoolManagingTools == true)
                {
                    Study_subject study_subject = db.Study_subject.Find(id);
                    if (study_subject == null)
                    {
                        return(HttpNotFound());
                    }
                    ViewBag.TitleSideBar = "Study_subject";

                    return(View(study_subject));
                }
                return(RedirectToAction("Default", "Home"));
            }
            return(RedirectToAction("Index", "Home"));
        }