Esempio n. 1
0
 public ActionResult Edit([Bind(Include = "Department_Class_Prog_Id,Department_Id,Class_Prog_Id,Department_Class_Prog_Name,Acronym,Acreditation_Status,Acreditation_Number,Acreditation_date,Created_By,Created_Date,Modified_By,Modified_Date")] Mstr_Department_Class_Program mstr_Department_Class_Program)
 {
     if (ModelState.IsValid)
     {
         db.Entry(mstr_Department_Class_Program).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Class_Prog_Id = new SelectList(db.Mstr_Class_Program, "Class_Prog_Id", "Class_Prog_Code", mstr_Department_Class_Program.Class_Prog_Id);
     ViewBag.Department_Id = new SelectList(db.Mstr_Department, "Department_Id", "Department_Code", mstr_Department_Class_Program.Department_Id);
     return(View(mstr_Department_Class_Program));
 }
Esempio n. 2
0
        // GET: DepartmentClassProg/Details/5
        public ActionResult Details(short?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Mstr_Department_Class_Program mstr_Department_Class_Program = db.Mstr_Department_Class_Program.Find(id);

            if (mstr_Department_Class_Program == null)
            {
                return(HttpNotFound());
            }
            return(View(mstr_Department_Class_Program));
        }
Esempio n. 3
0
        // GET: DepartmentClassProg/Edit/5
        public ActionResult Edit(short?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Mstr_Department_Class_Program mstr_Department_Class_Program = db.Mstr_Department_Class_Program.Find(id);

            if (mstr_Department_Class_Program == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Class_Prog_Id = new SelectList(db.Mstr_Class_Program, "Class_Prog_Id", "Class_Prog_Code", mstr_Department_Class_Program.Class_Prog_Id);
            ViewBag.Department_Id = new SelectList(db.Mstr_Department, "Department_Id", "Department_Code", mstr_Department_Class_Program.Department_Id);
            return(View(mstr_Department_Class_Program));
        }
Esempio n. 4
0
        // GET: DepartmentClassProg/Delete/5
        //public ActionResult Delete(short? id)
        //{
        //    if (id == null)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }
        //    Mstr_Department_Class_Program mstr_Department_Class_Program = db.Mstr_Department_Class_Program.Find(id);
        //    if (mstr_Department_Class_Program == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    return View(mstr_Department_Class_Program);
        //}

        // POST: DepartmentClassProg/Delete/5
        //[HttpPost, ActionName("Delete")]
        //[ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(short id, string UrlReferrer)
        {
            Mstr_Department_Class_Program mstr_Department_Class_Program = db.Mstr_Department_Class_Program.Find(id);
            short x = db.Mstr_Department.Where(d => d.Department_Id == mstr_Department_Class_Program.Department_Id).Select(d => d.Department_Id).Single();

            db.Mstr_Department_Class_Program.Remove(mstr_Department_Class_Program);
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                TempData["gagalHapus"] = "Gagal Hapus, Data sudah digunakan";
                return(RedirectToAction("Create", new { id = x, UrlReferrer = UrlReferrer }));
            }
            TempData["berhasilHapus"] = "Berhasil Hapus Data.";
            return(RedirectToAction("Create", new { id = x, UrlReferrer = UrlReferrer }));
        }
Esempio n. 5
0
        public ActionResult Create([Bind(Include = "Department_Class_Prog_Id,Department_Id,Class_Prog_Id,Class_Progs,Department_Class_Prog_Name,Acronym,Acreditation_Status,Acreditation_Number,Acreditation_date,Created_By,Created_Date,Modified_By,Modified_Date")] Mstr_Department_Class_Program mstr_Department_Class_Program, string UrlReferrer)
        {
            if (ModelState.IsValid)
            {
                for (short i = 0; i < mstr_Department_Class_Program.Class_Progs.Length; i++)
                {
                    mstr_Department_Class_Program.Class_Prog_Id = mstr_Department_Class_Program.Class_Progs[i];
                    db.Mstr_Department_Class_Program.Add(mstr_Department_Class_Program);
                    db.SaveChanges();
                }
                return(RedirectToAction("Create", new { id = mstr_Department_Class_Program.Department_Id, UrlReferrer = UrlReferrer }));
            }

            ViewBag.Department   = db.Mstr_Department.Where(d => d.Department_Id == mstr_Department_Class_Program.Department_Id).Single();
            ViewBag.DeptClasProg = db.Mstr_Department_Class_Program.Where(dcp => dcp.Department_Id == mstr_Department_Class_Program.Department_Id);
            ViewBag.UrlReferrer  = UrlReferrer;

            var exceptionList = db.Mstr_Department_Class_Program.Where(dcp => dcp.Department_Id == mstr_Department_Class_Program.Department_Id).Select(dcp => dcp.Class_Prog_Id).ToList();

            ViewBag.Class_Prog_Id = new SelectList(db.Mstr_Class_Program.Where(cp => !exceptionList.Contains(cp.Class_Prog_Id)), "Class_Prog_Id", "Class_Program_Name");
            return(View(mstr_Department_Class_Program));
        }