Beispiel #1
0
        // GET: StudentKrsV2/Create
        public ActionResult Create(long Student_Id, short Term_Year_Id, short Class_Prog_Id, int?Course_Id, short?Class_Id, string UrlReferrer)
        {
            var Student = db.Acd_Student.Where(k => k.Student_Id == Student_Id).Single();

            ViewBag.Course_Id = new SelectList(db.usp_GetOfferredCourseForKRSByStudent(Term_Year_Id, Student.Department_Id, Class_Prog_Id, Student.Entry_Year_Id, Student_Id), "Course_Id", "Course_Name", Course_Id);
            ViewBag.Class_Id  = new SelectList(new[] { new { ID = "0", Name = "" } }, "ID", "Name");
            //ViewBag.Term_Year_Id = Term_Year_Id;
            //ViewBag.Student_Id = Student_Id;
            //ViewBag.Class_Prog_Id = Class_Prog_Id;
            ViewBag.UrlReferrer = UrlReferrer ?? System.Web.HttpContext.Current.Request.UrlReferrer.ToString();

            Acd_Student_Krs acd_Student_Krs = new Acd_Student_Krs();

            acd_Student_Krs.Term_Year_Id  = Term_Year_Id;
            acd_Student_Krs.Student_Id    = Student_Id;
            acd_Student_Krs.Class_Prog_Id = Class_Prog_Id;
            if (Course_Id != null)
            {
                var CourseCostForKRS = db.usp_GetCourseCostForKRS(Term_Year_Id, Student.Department_Id, Class_Prog_Id, Student.Entry_Year_Id, Course_Id).Single();
                acd_Student_Krs.Sks    = Convert.ToDecimal(CourseCostForKRS.applied_sks);
                acd_Student_Krs.Amount = Convert.ToInt32(CourseCostForKRS.amount);
                ViewBag.Class_Id       = new SelectList(db.Acd_Offered_Course.Where(z => z.Course_Id == Course_Id && z.Term_Year_Id == Term_Year_Id), "Class_Id", "Mstr_Class.Class_Name");
            }
            if (Class_Id != null)
            {
                var ClassInfo = db.usp_GetClassInfoForKRS(Term_Year_Id, Student.Department_Id, Class_Prog_Id, Course_Id, Class_Id).Single();
                ViewBag.Dosen     = "";
                ViewBag.Kapasitas = ClassInfo.Capacity;
                ViewBag.Terdaftar = ClassInfo.Used;
                ViewBag.SisaKuota = ClassInfo.Free;
            }
            return(View(acd_Student_Krs));
        }
Beispiel #2
0
        // GET: StudentKrsV2/Edit/5
        public ActionResult Edit(long?id, short?Class_Id, string UrlReferrer)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Acd_Student_Krs acd_Student_Krs = db.Acd_Student_Krs.Find(id);

            if (acd_Student_Krs == null)
            {
                return(HttpNotFound());
            }
            var Student = db.Acd_Student.Where(k => k.Student_Id == acd_Student_Krs.Student_Id).Single();

            ViewBag.CourseName  = db.Acd_Course.Where(c => c.Course_Id == acd_Student_Krs.Course_Id).Select(c => c.Course_Name).First();
            ViewBag.Class_Id    = new SelectList(db.Acd_Offered_Course.Where(z => z.Course_Id == acd_Student_Krs.Course_Id && z.Term_Year_Id == acd_Student_Krs.Term_Year_Id), "Class_Id", "Mstr_Class.Class_Name", acd_Student_Krs.Class_Id);
            ViewBag.UrlReferrer = UrlReferrer ?? System.Web.HttpContext.Current.Request.UrlReferrer.ToString();

            var ClassInfo = db.usp_GetClassInfoForKRS(acd_Student_Krs.Term_Year_Id, Student.Department_Id, acd_Student_Krs.Class_Prog_Id, acd_Student_Krs.Course_Id, Class_Id ?? acd_Student_Krs.Class_Id).Single();

            if (ClassInfo.Free <= 0)
            {
                ViewBag.Notif = "Kelas Sudah Penuh.";
            }
            ViewBag.Dosen     = "";
            ViewBag.Kapasitas = ClassInfo.Capacity;
            ViewBag.Terdaftar = ClassInfo.Used;
            ViewBag.SisaKuota = ClassInfo.Free;

            return(View(acd_Student_Krs));
        }
Beispiel #3
0
        public ActionResult Edit([Bind(Include = "Krs_Id,Student_Id,Term_Year_Id,Course_Id,Class_Prog_Id,Class_Id,Sks,Amount,Nb_Taking,Krs_Date,Due_Date,Cost_Item_Id,Is_Approved,Is_Locked,Modified_By,Modified_Date,Created_Date,Order_Id,Created_By")] Acd_Student_Krs acd_Student_Krs, string UrlReferrer)
        {
            if (ModelState.IsValid)
            {
                var Student   = db.Acd_Student.Find(acd_Student_Krs.Student_Id);
                var ClassInfo = db.usp_GetClassInfoForKRS(acd_Student_Krs.Term_Year_Id, Student.Department_Id, acd_Student_Krs.Class_Prog_Id, acd_Student_Krs.Course_Id, acd_Student_Krs.Class_Id).Single();

                if (ClassInfo.Free <= 0)
                {
                    ViewBag.NotifMessage = "Kelas Sudah Penuh.";

                    ViewBag.CourseName = db.Acd_Course.Where(c => c.Course_Id == acd_Student_Krs.Course_Id).Select(c => c.Course_Name).First();
                    ViewBag.Class_Id   = new SelectList(db.Acd_Offered_Course.Where(z => z.Course_Id == acd_Student_Krs.Course_Id && z.Term_Year_Id == acd_Student_Krs.Term_Year_Id), "Class_Id", "Mstr_Class.Class_Name", acd_Student_Krs.Class_Id);

                    ViewBag.Dosen       = "";
                    ViewBag.Kapasitas   = ClassInfo.Capacity;
                    ViewBag.Terdaftar   = ClassInfo.Used;
                    ViewBag.SisaKuota   = ClassInfo.Free;
                    ViewBag.UrlReferrer = UrlReferrer;

                    return(View(acd_Student_Krs));
                }
                acd_Student_Krs.Modified_Date = DateTime.Now;

                db.Entry(acd_Student_Krs).State = EntityState.Modified;
                db.SaveChanges();
                return(Redirect(UrlReferrer));
            }

            return(View(acd_Student_Krs));
        }
Beispiel #4
0
        // GET: Student_Khsv2/Edit/5
        public ActionResult Edit(long?Krs_Id)
        {
            if (Krs_Id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Acd_Student_Krs acd_Student_Krs = db.Acd_Student_Krs.Find(Krs_Id);

            if (acd_Student_Krs == null)
            {
                return(HttpNotFound());
            }

            short?department_Id   = acd_Student_Krs.Acd_Student.Department_Id;
            var   listGradeLetter = db.Acd_Grade_Department.Where(x => x.Department_Id == department_Id)
                                    .Select(x => new
            {
                Grade_Letter_Id = x.Acd_Grade_Letter.Grade_Letter_Id,
                Grade_Letter    = x.Acd_Grade_Letter.Grade_Letter
            }).ToList();

            short?grade_Letter_Id = null;

            if (acd_Student_Krs.Acd_Student_Khs.FirstOrDefault() != null)
            {
                grade_Letter_Id = acd_Student_Krs.Acd_Student_Khs.FirstOrDefault().Grade_Letter_Id;
            }

            ViewBag.Grade_Letter_Id = new SelectList(listGradeLetter, "Grade_Letter_Id", "Grade_Letter", grade_Letter_Id);

            return(View(acd_Student_Krs));
        }
Beispiel #5
0
        public ActionResult Create([Bind(Include = "Krs_Id,Student_Id,Term_Year_Id,Course_Id,Class_Prog_Id,Class_Id,Sks,Amount,Nb_Taking,Krs_Date,Due_Date,Cost_Item_Id,Is_Approved,Is_Locked,Modified_By,Modified_Date,Created_Date,Order_Id,Created_By")] Acd_Student_Krs acd_Student_Krs, string UrlReferrer)
        {
            if (ModelState.IsValid)
            {
                var     Student          = db.Acd_Student.Find(acd_Student_Krs.Student_Id);
                var     ClassInfo        = db.usp_GetClassInfoForKRS(acd_Student_Krs.Term_Year_Id, Student.Department_Id, acd_Student_Krs.Class_Prog_Id, acd_Student_Krs.Course_Id, acd_Student_Krs.Class_Id).Single();
                var     Saldo            = db.usp_Saldo(acd_Student_Krs.Student_Id, acd_Student_Krs.Term_Year_Id).Single();
                decimal UsedSKS          = db.Acd_Student_Krs.Where(k => k.Student_Id == acd_Student_Krs.Student_Id && k.Term_Year_Id == acd_Student_Krs.Term_Year_Id).Select(p => p.Sks).DefaultIfEmpty().Sum();
                decimal AllowedSKS       = db.usp_GetAllowedSKSForKRS(acd_Student_Krs.Term_Year_Id, acd_Student_Krs.Student_Id).Single().Value;
                var     CourseCostForKRS = db.usp_GetCourseCostForKRS(acd_Student_Krs.Term_Year_Id, Student.Department_Id, acd_Student_Krs.Class_Prog_Id, Student.Entry_Year_Id, acd_Student_Krs.Course_Id).Single();

                if (ClassInfo.Free <= 0 || (AllowedSKS - UsedSKS) < CourseCostForKRS.applied_sks || Saldo.SisaSaldoSaatIni < CourseCostForKRS.amount)
                {
                    if (ClassInfo.Free <= 0)
                    {
                        ViewBag.NotifMessage = "Kelas Sudah Penuh.";
                    }
                    if ((AllowedSKS - UsedSKS) < CourseCostForKRS.applied_sks)
                    {
                        ViewBag.NotifMessage = "Sisa SKS tidak mencukupi.";
                    }
                    if (Saldo.SisaSaldoSaatIni < CourseCostForKRS.amount)
                    {
                        ViewBag.NotifMessage = "Sisa Saldo tidak mencukupi.";
                    }

                    ViewBag.Term_Year_Id  = acd_Student_Krs.Term_Year_Id;
                    ViewBag.Student_Id    = acd_Student_Krs.Student_Id;
                    ViewBag.Class_Prog_Id = acd_Student_Krs.Class_Prog_Id;
                    ViewBag.Course_Id     = new SelectList(db.usp_GetOfferredCourseForKRSByStudent(acd_Student_Krs.Term_Year_Id, Student.Department_Id, acd_Student_Krs.Class_Prog_Id, Student.Entry_Year_Id, Student.Student_Id), "course_id", "course_name", acd_Student_Krs.Course_Id);
                    ViewBag.Class_Id      = new SelectList(db.Acd_Offered_Course.Where(z => z.Course_Id == acd_Student_Krs.Course_Id && z.Term_Year_Id == acd_Student_Krs.Term_Year_Id), "Class_Id", "Mstr_Class.Class_Name", acd_Student_Krs.Class_Id);
                    ViewBag.Dosen         = "";
                    ViewBag.Kapasitas     = ClassInfo.Capacity;
                    ViewBag.Terdaftar     = ClassInfo.Used;
                    ViewBag.SisaKuota     = ClassInfo.Free;
                    ViewBag.UrlReferrer   = UrlReferrer;

                    return(View(acd_Student_Krs));
                }
                acd_Student_Krs.Created_Date  = DateTime.Now;
                acd_Student_Krs.Krs_Date      = DateTime.Now;
                acd_Student_Krs.Modified_Date = DateTime.Now;

                acd_Student_Krs.Cost_Item_Id = 3; //deposit KRS, nanti dikembangkan bisa 9(KKN)

                db.Acd_Student_Krs.Add(acd_Student_Krs);
                db.SaveChanges();
                return(Redirect(UrlReferrer));
            }

            return(View(acd_Student_Krs));
        }
Beispiel #6
0
        // GET: StudentKrsV2/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Acd_Student_Krs acd_Student_Krs = db.Acd_Student_Krs.Find(id);

            if (acd_Student_Krs == null)
            {
                return(HttpNotFound());
            }
            return(View(acd_Student_Krs));
        }
Beispiel #7
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Acd_Student_Krs acd_Student_Krs = db.Acd_Student_Krs.Find(id);

            if (acd_Student_Krs == null)
            {
                return(HttpNotFound());
            }
            //for url
            return(View(acd_Student_Krs));
        }
Beispiel #8
0
        // GET: StudentKrsV2/Delete/5
        //public ActionResult Delete(long? id)
        //{
        //    if (id == null)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }
        //    Acd_Student_Krs acd_Student_Krs = db.Acd_Student_Krs.Find(id);
        //    if (acd_Student_Krs == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    return View(acd_Student_Krs);
        //}

        // POST: StudentKrsV2/Delete/5
        //[HttpPost, ActionName("Delete")]
        //[ValidateAntiForgeryToken]
        public ActionResult Delete(long id)
        {
            string          UrlReferrer     = System.Web.HttpContext.Current.Request.UrlReferrer.ToString();
            Acd_Student_Krs acd_Student_Krs = db.Acd_Student_Krs.Find(id);
            var             khscount        = db.Acd_Student_Khs.Where(p => p.Krs_Id == acd_Student_Krs.Krs_Id).Count();

            if (khscount > 0)
            {
                TempData["gagalHapus"] = "Data KRS sudah terpakai di KHS.";
                return(Redirect(UrlReferrer));
            }
            TempData["berhasilHapus"] = "Berhasil Hapus Data.";
            db.Acd_Student_Krs.Remove(acd_Student_Krs);
            db.SaveChanges();
            return(Redirect(UrlReferrer));
        }
 public ActionResult Edit([Bind(Include = "Krs_Id,Student_Id,Term_Year_Id,Course_Id,Class_Prog_Id,Class_Id,Sks,Amount,Nb_Taking,Krs_Date,Due_Date,Cost_Item_Id,Is_Approved,Is_Locked,Modified_By,Modified_Date,Created_Date,Order_Id,Created_By")] Acd_Student_Krs acd_Student_Krs)
 {
     if (ModelState.IsValid)
     {
         db.Entry(acd_Student_Krs).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Course_Id     = new SelectList(db.Acd_Course, "Course_Id", "Course_Code", acd_Student_Krs.Course_Id);
     ViewBag.Student_Id    = new SelectList(db.Acd_Student, "Student_Id", "Nim", acd_Student_Krs.Student_Id);
     ViewBag.Cost_Item_Id  = new SelectList(db.Fnc_Cost_Item, "Cost_Item_Id", "Cost_Item_Code", acd_Student_Krs.Cost_Item_Id);
     ViewBag.Class_Id      = new SelectList(db.Mstr_Class, "Class_Id", "Class_Name", acd_Student_Krs.Class_Id);
     ViewBag.Class_Prog_Id = new SelectList(db.Mstr_Class_Program, "Class_Prog_Id", "Class_Prog_Code", acd_Student_Krs.Class_Prog_Id);
     ViewBag.Term_Year_Id  = new SelectList(db.Mstr_Term_Year.OrderByDescending(ty => ty.Term_Year_Id), "Term_Year_Id", "Term_Year_Name", acd_Student_Krs.Term_Year_Id);
     return(View(acd_Student_Krs));
 }
        public ActionResult DeleteConfirmed(long id, int Offered_Course_id)
        {
            Acd_Student_Krs acd_Student_Krs = db.Acd_Student_Krs.Find(id);
            short?          Department_Id   = acd_Student_Krs.Acd_Student.Department_Id;

            db.Acd_Student_Krs.Remove(acd_Student_Krs);
            db.SaveChanges();
            //return RedirectToAction("Index");
            return(RedirectToAction("List", new
            {
                Term_Year_Id = acd_Student_Krs.Term_Year_Id,
                Class_Prog_Id = acd_Student_Krs.Class_Prog_Id,
                Course_Id = acd_Student_Krs.Course_Id,
                Class_Id = acd_Student_Krs.Class_Id,
                Department_Id = Department_Id,
                Offered_Course_id = Offered_Course_id
            }));
        }
        // GET: StudentKrsV1/Delete/5
        public ActionResult Delete(long?id, int Offered_Course_id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Acd_Student_Krs acd_Student_Krs = db.Acd_Student_Krs.Find(id);

            if (acd_Student_Krs == null)
            {
                return(HttpNotFound());
            }

            //for url
            ViewBag.Offered_Course = Offered_Course_id;

            return(View(acd_Student_Krs));
        }
Beispiel #12
0
        public ActionResult Insert(short Term_Year_Id, Int64 Student_Id)
        {
            var student      = db.Acd_Student.Where(k => k.Student_Id == Student_Id).Single();
            var curEntryYear = db.Acd_Curriculum_Entry_Year.Where(k => k.Term_Year_Id == Term_Year_Id && k.Department_Id == student.Department_Id && k.Entry_Year_Id == student.Entry_Year_Id).Single();

            ViewBag.Course_Id     = new SelectList(db.usp_GetOfferredCourseForKRSByStudent(Term_Year_Id, student.Department_Id, curEntryYear.Class_Prog_Id, student.Entry_Year_Id, Student_Id), "course_id", "course_name");
            ViewBag.Class_Id      = new SelectList(new[] { new { ID = "0", Name = "-- Pilih Kelas --" } }, "ID", "Name");
            ViewBag.Term_Year_Id  = Term_Year_Id;
            ViewBag.Student_Id    = Student_Id;
            ViewBag.Class_Prog_Id = curEntryYear.Class_Prog_Id;
            //ViewBag.Curriculum_Id = db.Acd_Curriculum_Entry_Year.Where(p => p.Department_Id == student.Department_Id && p.Entry_Year_Id == student.Entry_Year_Id && p.Term_Year_Id == Term_Year_Id).SingleOrDefault().Curriculum_Id;
            Acd_Student_Krs acd_Student_Krs = new Acd_Student_Krs();

            acd_Student_Krs.Term_Year_Id  = Term_Year_Id;
            acd_Student_Krs.Student_Id    = Student_Id;
            acd_Student_Krs.Class_Prog_Id = curEntryYear.Class_Prog_Id;
            return(View());
        }
Beispiel #13
0
        public ActionResult Delete(int id)
        {
            Acd_Student_Krs acd_Student_Krs = db.Acd_Student_Krs.Find(id);
            Acd_Student     student         = db.Acd_Student.Find(acd_Student_Krs.Student_Id);
            var             khscount        = db.Acd_Student_Khs.Where(p => p.Krs_Id == acd_Student_Krs.Krs_Id).Count();

            if (khscount > 0)
            {
                ViewBag.NotifMessage = "Data KRS sudah terpakai di KHS.";
                return(View(acd_Student_Krs));
            }
            db.Acd_Student_Krs.Remove(acd_Student_Krs);
            db.SaveChanges();
            return(RedirectToAction("Index", "KRSv2", new
            {
                Student_NIM = student.Nim,
                Term_Year_Id = acd_Student_Krs.Term_Year_Id
            }));
        }
        // GET: StudentKrsV1/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Acd_Student_Krs acd_Student_Krs = db.Acd_Student_Krs.Find(id);

            if (acd_Student_Krs == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Course_Id     = new SelectList(db.Acd_Course, "Course_Id", "Course_Code", acd_Student_Krs.Course_Id);
            ViewBag.Student_Id    = new SelectList(db.Acd_Student, "Student_Id", "Nim", acd_Student_Krs.Student_Id);
            ViewBag.Cost_Item_Id  = new SelectList(db.Fnc_Cost_Item, "Cost_Item_Id", "Cost_Item_Code", acd_Student_Krs.Cost_Item_Id);
            ViewBag.Class_Id      = new SelectList(db.Mstr_Class, "Class_Id", "Class_Name", acd_Student_Krs.Class_Id);
            ViewBag.Class_Prog_Id = new SelectList(db.Mstr_Class_Program, "Class_Prog_Id", "Class_Prog_Code", acd_Student_Krs.Class_Prog_Id);
            ViewBag.Term_Year_Id  = new SelectList(db.Mstr_Term_Year.OrderByDescending(ty => ty.Term_Year_Id), "Term_Year_Id", "Term_Year_Name", acd_Student_Krs.Term_Year_Id);
            return(View(acd_Student_Krs));
        }
Beispiel #15
0
        public ActionResult Edit(Acd_Student_Krs acd_Student_Krs)
        {
            if (ModelState.IsValid)
            {
                var student   = db.Acd_Student.Find(acd_Student_Krs.Student_Id);
                var classInfo = db.usp_GetClassInfoForKRS(acd_Student_Krs.Term_Year_Id, student.Department_Id, acd_Student_Krs.Class_Prog_Id, acd_Student_Krs.Course_Id, acd_Student_Krs.Class_Id).Single();
                //var saldo = db.usp_Saldo(acd_Student_Krs.Student_Id, acd_Student_Krs.Term_Year_Id).Single();
                //decimal usedSKS = db.Acd_Student_Krs.Where(k => k.Student_Id == acd_Student_Krs.Student_Id && k.Term_Year_Id == acd_Student_Krs.Term_Year_Id).Sum(p => p.Sks);
                //decimal AllowedSKS = db.usp_GetAllowedSKSForKRS(acd_Student_Krs.Term_Year_Id, acd_Student_Krs.Student_Id).Single().Value;
                //var CourseCostForKRS = db.usp_GetCourseCostForKRS(acd_Student_Krs.Term_Year_Id, student.Department_Id, acd_Student_Krs.Class_Prog_Id, student.Entry_Year_Id, acd_Student_Krs.Course_Id).Single();

                if (classInfo.Free <= 0)
                {
                    ViewBag.Course_Id    = new SelectList(db.usp_GetOfferredCourseForKRSByStudent(acd_Student_Krs.Term_Year_Id, student.Department_Id, acd_Student_Krs.Class_Prog_Id, student.Entry_Year_Id, student.Student_Id), "course_id", "course_name", acd_Student_Krs.Course_Id);
                    ViewBag.Class_Id     = new SelectList(db.Acd_Offered_Course.Where(z => z.Course_Id == acd_Student_Krs.Course_Id && z.Term_Year_Id == acd_Student_Krs.Term_Year_Id), "Class_Id", "Mstr_Class.Class_Name", acd_Student_Krs.Class_Id);
                    ViewBag.NotifMessage = "Kelas Sudah Penuh.";
                    return(View(acd_Student_Krs));
                }
                //if ((AllowedSKS - usedSKS) < CourseCostForKRS.applied_sks)
                //{
                //    ViewBag.Course_Id = new SelectList(db.usp_GetOfferredCourseForKRSByStudent(acd_Student_Krs.Term_Year_Id, student.Department_Id, acd_Student_Krs.Class_Prog_Id, student.Entry_Year_Id, student.Student_Id), "course_id", "course_name", acd_Student_Krs.Course_Id);
                //    ViewBag.Class_Id = new SelectList(db.Acd_Offered_Course.Where(z => z.Course_Id == acd_Student_Krs.Course_Id && z.Term_Year_Id == acd_Student_Krs.Term_Year_Id), "Class_Id", "Mstr_Class.Class_Name", acd_Student_Krs.Class_Id);
                //    ViewBag.NotifMessage = "Sisa SKS tidak mencukupi.";
                //    return View(acd_Student_Krs);
                //}
                //if (saldo.SisaSaldoSaatIni < CourseCostForKRS.amount)
                //{
                //    ViewBag.Course_Id = new SelectList(db.usp_GetOfferredCourseForKRSByStudent(acd_Student_Krs.Term_Year_Id, student.Department_Id, acd_Student_Krs.Class_Prog_Id, student.Entry_Year_Id, student.Student_Id), "course_id", "course_name", acd_Student_Krs.Course_Id);
                //    ViewBag.Class_Id = new SelectList(db.Acd_Offered_Course.Where(z => z.Course_Id == acd_Student_Krs.Course_Id && z.Term_Year_Id == acd_Student_Krs.Term_Year_Id), "Class_Id", "Mstr_Class.Class_Name", acd_Student_Krs.Class_Id);
                //    ViewBag.NotifMessage = "Sisa Saldo tidak mencukupi.";
                //    return View(acd_Student_Krs);
                //}

                db.Acd_Student_Krs.Attach(acd_Student_Krs); // attach in the Unchanged state
                db.Entry(acd_Student_Krs).Property(r => r.Class_Id).IsModified = true;
                db.SaveChanges();
                return(RedirectToAction("Index", new { Student_NIM = student.Nim, Term_Year_Id = acd_Student_Krs.Term_Year_Id }));
            }
            return(View());
        }
        public ActionResult ListAdd(IEnumerable <long> checkStudent_IdToAdd, short Department_Id, int Offered_Course_id, short Entry_Year_Id, Acd_Student_Krs acd_Student_Krs)
        {
            bool errorSave = false;

            if (ModelState.IsValid)
            {
                if (checkStudent_IdToAdd == null)
                {
                    TempData["massage"] = "Pilih data terlebih dahulu!";
                    return(Redirect(Request.UrlReferrer.ToString()));
                }
                if (validKouta(Offered_Course_id, acd_Student_Krs.Term_Year_Id, acd_Student_Krs.Class_Prog_Id, acd_Student_Krs.Course_Id, acd_Student_Krs.Class_Id, checkStudent_IdToAdd) == false)
                {
                    TempData["massage"] = "Kuota kelas tidak cukup!";
                    return(Redirect(Request.UrlReferrer.ToString()));
                }

                var getCourseCostForKRS = db.usp_GetCourseCostForKRS(acd_Student_Krs.Term_Year_Id, Department_Id, acd_Student_Krs.Class_Prog_Id, Entry_Year_Id, acd_Student_Krs.Course_Id)
                                          .Select(x => new
                {
                    x.amount,
                    x.applied_sks
                }).First();

                try
                {
                    int jmlSkipLoop = 0;
                    List <Vm_notif_error> listIdError = new List <Vm_notif_error>();
                    foreach (var i in checkStudent_IdToAdd)
                    {
                        bool    errorSks          = false;
                        bool    errorSaldo        = false;
                        int     OsksAllowed       = 0;
                        decimal OsksAmbil         = 0;
                        long    OSisaSaldoSaatIni = 0;
                        if (validSks(out OsksAllowed, out OsksAmbil, i, acd_Student_Krs.Term_Year_Id, getCourseCostForKRS.applied_sks) == false)
                        {
                            errorSks = true;
                        }
                        if (validSaldo(out OSisaSaldoSaatIni, i, acd_Student_Krs.Term_Year_Id, getCourseCostForKRS.amount) == false)
                        {
                            errorSaldo = true;
                        }
                        if (errorSks || errorSaldo)
                        {
                            listIdError.Add(new Vm_notif_error
                            {
                                Student_Id       = i,
                                errorSks         = errorSks,
                                errorSaldo       = errorSaldo,
                                sksAllowed       = OsksAllowed,
                                sksAmbil         = OsksAmbil,
                                SisaSaldoSaatIni = OSisaSaldoSaatIni
                            });
                            jmlSkipLoop = jmlSkipLoop + 1;
                            continue;
                        }

                        acd_Student_Krs.Student_Id    = i;
                        acd_Student_Krs.Sks           = Convert.ToDecimal(getCourseCostForKRS.applied_sks);
                        acd_Student_Krs.Amount        = Convert.ToInt32(getCourseCostForKRS.amount);
                        acd_Student_Krs.Created_Date  = DateTime.Now;
                        acd_Student_Krs.Krs_Date      = DateTime.Now;
                        acd_Student_Krs.Modified_Date = DateTime.Now;

                        acd_Student_Krs.Cost_Item_Id = 3; //deposit KRS, nanti dikembangkan bisa 9(KKN)

                        db.Acd_Student_Krs.Add(acd_Student_Krs);
                        db.SaveChanges();
                    }

                    if (jmlSkipLoop > 0)
                    {
                        errorSave = true;
                        if (jmlSkipLoop <= 10)
                        {
                            TempData["detailMassage"] = listIdError;
                            //string html = string.Empty;
                            //foreach (var item in listIdError)
                            //{
                            //    html = "<tr><td>" + item.NimNama.Nim + "</td><td>" + item.NimNama.Full_Name + "</td><td>" + item.Keterangan + "</td></tr>";
                            //}
                            //TempData["detailMassage"] = "<table>" + html + "</table>";
                        }
                        else
                        {
                            TempData["detailMassage1"] = jmlSkipLoop + " Mahasisawa gagal diinput";
                        }


                        //TempData["detailMassage"] = listIdError;
                        //TempData["massage"] = jmlSkipLoop + " Mahasisawa gagal diinput";
                        //string[] arrayIdError;
                        //arrayIdError = listIdError.ConvertAll<String>(p => p.Student_Id.ToString()).ToArray<String>();
                    }
                }
                catch (Exception)
                {
                    TempData["massage"] = "Proses gagal. Terjadi kesalahan database!";
                    errorSave           = true;
                }
            }

            if (errorSave)
            {
                return(RedirectToAction("ListAdd", new
                {
                    Term_Year_Id = acd_Student_Krs.Term_Year_Id,
                    Class_Prog_Id = acd_Student_Krs.Class_Prog_Id,
                    Department_Id = Department_Id,
                    Course_Id = acd_Student_Krs.Course_Id,
                    Class_Id = acd_Student_Krs.Class_Id,
                    Offered_Course_id = Offered_Course_id,
                    Entry_Year_Id = Entry_Year_Id
                }));
            }
            else
            {
                TempData["massage_success"] = "Sukses, data berhasil ditambahkan";
                return(RedirectToAction("List", new {
                    Term_Year_Id = acd_Student_Krs.Term_Year_Id,
                    Class_Prog_Id = acd_Student_Krs.Class_Prog_Id,
                    Course_Id = acd_Student_Krs.Course_Id,
                    Department_Id = Department_Id,
                    Class_Id = acd_Student_Krs.Class_Id,
                    Offered_Course_id = Offered_Course_id
                }));
            }
        }