public ActionResult DeleteConfirmed(int id) { Fnc_Course_Cost_Package fnc_Course_Cost_Package = db.Fnc_Course_Cost_Package.Find(id); Fnc_Course_Cost_Type fnc_Course_Cost_Type = db.Fnc_Course_Cost_Type.Where(cct => cct.Course_Cost_Type_Id == fnc_Course_Cost_Package.Course_Cost_Type_Id).First(); db.Fnc_Course_Cost_Package.Remove(fnc_Course_Cost_Package); db.SaveChanges(); return(RedirectToAction("Index", new { Class_Prog_Id = fnc_Course_Cost_Type.Class_Prog_Id, Term_Year_Id = fnc_Course_Cost_Type.Term_Year_Id, Department_Id = fnc_Course_Cost_Type.Department_Id })); }
public ActionResult Create([Bind(Include = "Course_Cost_Type_Id,Term_Year_Id,Department_Id,Class_Prog_Id,Course_Id,Is_Sks,Created_By,Created_Date,Modified_By,Modified_Date")] Fnc_Course_Cost_Type fnc_Course_Cost_Type, IEnumerable <int> CourseId, IEnumerable <int> delSKS, IEnumerable <int> delPaket, bool Is_Delete) { if (Is_Delete == true) { if (fnc_Course_Cost_Type.Is_Sks == true) { try { db.Fnc_Course_Cost_Type.Where(cct => delSKS.Contains(cct.Course_Cost_Type_Id)).Delete(); } catch (Exception) { TempData["shortMessage"] = "Data tidak bisa dihapus, dikarenakan Harganya telah disetting.."; } } else { try { db.Fnc_Course_Cost_Type.Where(cct => delPaket.Contains(cct.Course_Cost_Type_Id)).Delete(); } catch (Exception) { TempData["shortMessage"] = "Data tidak bisa dihapus, dikarenakan Harganya telah disetting.."; } } } else { if (CourseId != null) { if (ModelState.IsValid) { foreach (var course in CourseId) { fnc_Course_Cost_Type.Course_Id = course; db.Fnc_Course_Cost_Type.Add(fnc_Course_Cost_Type); db.SaveChanges(); } } } } return(RedirectToAction("Index", new { Class_Prog_Id = fnc_Course_Cost_Type.Class_Prog_Id, Term_Year_Id = fnc_Course_Cost_Type.Term_Year_Id, Department_Id = fnc_Course_Cost_Type.Department_Id })); }
public ActionResult Edit([Bind(Include = "Course_Cost_Package_Id,Course_Cost_Type_Id,Entry_Year_Id,Amount_Per_Mk,Created_By,Created_Date,Modified_By,Modified_Date")] Fnc_Course_Cost_Package fnc_Course_Cost_Package, string SAmount) { fnc_Course_Cost_Package.Amount_Per_Mk = (int)decimal.Parse(Regex.Replace(SAmount, @"[^\d.]", "")); Fnc_Course_Cost_Type fnc_Course_Cost_Type = db.Fnc_Course_Cost_Type.Where(cct => cct.Course_Cost_Type_Id == fnc_Course_Cost_Package.Course_Cost_Type_Id).First(); if (ModelState.IsValid) { db.Entry(fnc_Course_Cost_Package).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { Class_Prog_Id = fnc_Course_Cost_Type.Class_Prog_Id, Term_Year_Id = fnc_Course_Cost_Type.Term_Year_Id, Department_Id = fnc_Course_Cost_Type.Department_Id })); } ViewBag.Departments = db.Mstr_Department.Where(d => d.Department_Id == fnc_Course_Cost_Type.Department_Id).First(); ViewBag.Class_Prog = db.Mstr_Class_Program.Where(cp => cp.Class_Prog_Id == fnc_Course_Cost_Type.Class_Prog_Id).First(); ViewBag.Term_Year = db.Mstr_Term_Year.Where(ty => ty.Term_Year_Id == fnc_Course_Cost_Type.Term_Year_Id).First(); ViewBag.CourseCostTypes = db.Fnc_Course_Cost_Type.Where(cct => cct.Course_Cost_Type_Id == fnc_Course_Cost_Package.Course_Cost_Type_Id).First(); ViewBag.Entry_Years = db.Mstr_Entry_Year.Where(ey => ey.Entry_Year_Id == fnc_Course_Cost_Package.Entry_Year_Id).First(); return(View(fnc_Course_Cost_Package)); }
// GET: CourseCostPackage/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Fnc_Course_Cost_Package fnc_Course_Cost_Package = db.Fnc_Course_Cost_Package.Find(id); Fnc_Course_Cost_Type fnc_Course_Cost_Type = db.Fnc_Course_Cost_Type.Find(fnc_Course_Cost_Package.Course_Cost_Type_Id); if (fnc_Course_Cost_Package == null) { return(HttpNotFound()); } ViewBag.Departments = db.Mstr_Department.Where(d => d.Department_Id == fnc_Course_Cost_Type.Department_Id).First(); ViewBag.Class_Prog = db.Mstr_Class_Program.Where(cp => cp.Class_Prog_Id == fnc_Course_Cost_Type.Class_Prog_Id).First(); ViewBag.Term_Year = db.Mstr_Term_Year.Where(ty => ty.Term_Year_Id == fnc_Course_Cost_Type.Term_Year_Id).First(); ViewBag.CourseCostTypes = db.Fnc_Course_Cost_Type.Where(cct => cct.Course_Cost_Type_Id == fnc_Course_Cost_Package.Course_Cost_Type_Id).First(); ViewBag.Entry_Years = db.Mstr_Entry_Year.Where(ey => ey.Entry_Year_Id == fnc_Course_Cost_Package.Entry_Year_Id).First(); return(View(fnc_Course_Cost_Package)); }