public ActionResult Edit(Guid ID) { var ob = new CoursesStudentDetailtBCL().GetByScsId(ID); ob.CoursesJournalJoin = new CoursesJournalBCL().GetByCJId((Guid)ob.CJId); ob.CoursesJournalJoin.CoursesJoin = new CoursesBCL().GetByCoId((Guid)ob.CoursesJournalJoin.CoId); var dropStuden = new List <SelectListItem>(); var old = new CoursesStudentDetailtBCL().GetAll().Where(q => q.CJId == ob.CJId).ToList(); var all = new StudentDetailtBCL().GetJoin().Where(q => q.CoId == ob.CoursesJournalJoin.CoId && (!old.Any(x => x.StudetId == q.StudetId) || q.StudetId == ob.StudetId)).ToList(); foreach (var item in all) { dropStuden.Add(new SelectListItem() { Text = item.StudentJoin.FullName, Value = item.StudetId.ToString(), Selected = item.StudetId == ob.StudetId }); } ViewBag.CJ = ob; ViewBag.dropStuden = dropStuden; return(View(ob)); }
public ActionResult GetListStudentByCourseId(Guid coursesId) { var data = new CoursesStudentDetailtBCL().GetByCJId(coursesId); ViewBag.CJId = new SelectList(data, "CJId", "CoursesJoin.CourseName"); return(PartialView(data)); }
public ActionResult getHvv(Guid CJId) { var nk = new CoursesJournalBCL().GetByCJId(CJId); var hv_vang = new CoursesStudentDetailtBCL().GetByCJId(CJId); var lst = new List <CoursesStudentDetailtObject>(); var hv_trong_lop = new StudentDetailtBCL().GetJoin().Where(q => q.CoId.Equals(nk.CoId)); foreach (var item in hv_trong_lop) { var hv = hv_vang.FirstOrDefault(q => q.StudetId.Equals(item.StudetId)); lst.Add(new CoursesStudentDetailtObject() { ScsId = hv != null ? hv.ScsId : Guid.NewGuid(), Selected = hv != null, StudetId = item.StudetId, CJId = CJId, StudentJoin = item.StudentJoin, Description = hv != null ? hv.Description : "" }); } return(PartialView("pv_dsvang", lst)); }
public void addhvv(List <CoursesStudentDetailtObject> lst) { if (lst == null && lst.Count <= 0) { return; } var dathem = new CoursesStudentDetailtBCL().GetAll().Where(q => q.CJId.Equals(lst[0].CJId)); var bcl = new CoursesStudentDetailtBCL(); foreach (var item in lst) { var hv = dathem.FirstOrDefault(m => m.StudetId.Equals(item.StudetId)); var ob = new CoursesStudentDetailtObject() { CJId = lst[0].CJId, Description = item.Description, StudetId = item.StudetId }; if (hv == null && item.Selected) { ob.ScsId = Guid.NewGuid(); bcl.Insert(ob); } else if (hv != null) { hv.Description = ob.Description; if (item.Selected) { bcl.Update(hv); } else { bcl.Delete(hv.ScsId); } } } }
public ActionResult Create(Guid?ID) { if (!ID.HasValue) { ModelState.AddModelError("", "Chọn một Nhật kí để thêm"); return(RedirectToAction("Index")); } Guid id = (Guid)ID; var ob = new CoursesJournalBCL().GetByCJId(id); ob.CoursesJoin = new CoursesBCL().GetByCoId((Guid)ob.CoId); var dropStuden = new List <SelectListItem>(); var old = new CoursesStudentDetailtBCL().GetAll().Where(q => q.CJId == ob.CJId).ToList(); var all = new StudentDetailtBCL().GetJoin().Where(q => q.CoId == ob.CoId && !old.Any(x => x.StudetId == q.StudetId)).ToList(); foreach (var item in all) { dropStuden.Add(new SelectListItem() { Text = item.StudentJoin.FullName, Value = item.StudetId.ToString() }); } ViewBag.CJ = ob; ViewBag.dropStuden = dropStuden; if (dropStuden.Count <= 0) { ModelState.AddModelError("StudetId", "Không có học viên nào trong lớp học để thêm!"); } return(View(new CoursesStudentDetailtObject() { CJId = ob.CJId })); }
public ActionResult Delete(Guid ID) { var result = new CoursesStudentDetailtBCL().Delete(ID); return(Json(result ? new { rs = true } : new { rs = false })); }