/// <summary> /// 编辑 /// </summary> /// <returns></returns> public static int Edit(VModel.SyClass.Form m) { using (var db = new fz_basicEntities()) { if (!m.IsEnabled) { if (db.sy_student.Where(w => w.Class == m.Id && w.sy_user.IsEnabled).Count() > 0) { return(-1); } } sy_class dbm; dbm = db.sy_class.Where(w => w.GradeId == m.GradeId && w.Name == m.Name && w.IsEnabled).FirstOrDefault(); if (dbm != null) { if (dbm.Name != m.Name) { return(100); } } dbm = db.sy_class.Find(m.Id); dbm.Name = m.Name; dbm.GradeId = (int)m.GradeId; dbm.Sort = m.Sort; dbm.IsEnabled = m.IsEnabled; dbm.sy_teacher_and_class_and_subject.Clear(); if (m.TsGrid != null && m.TsGrid.Count > 0) { foreach (var item in m.TsGrid) { if (item.TeacherId != null) { dbm.sy_teacher_and_class_and_subject.Add(new sy_teacher_and_class_and_subject { dict_subject = db.dict_subject.Find(item.SubjectId), sy_teacher = db.sy_teacher.Find(item.TeacherId) }); } } } db.SaveChanges(); } Common.Caches.RemoveCache("sy_class"); return(200); }
public ActionResult Add(VModel.SyClass.Form m) { if (ModelState.IsValid) { int r = Bll.SyClassBll.Add(m); switch (r) { case 200: return(Json(new { success = true })); case -1: ModelState.AddModelError("Name", "当前年级下班级名重复"); break; } } return(View(m)); }
public ActionResult Edit(VModel.SyClass.Form m) { if (ModelState.IsValid) { int r = Bll.SyClassBll.Edit(m); switch (r) { case 200: return(Json(new { success = true })); case 100: ModelState.AddModelError("Name", "当前年级下的班级名重复"); break; case -1: ModelState.AddModelError("IsEnabled", "该班级还有学生不能被停用。"); break; } } return(View(m)); }
public ActionResult Edit(int id) { VModel.SyClass.Form m = Bll.SyClassBll.GetEdit(id); return(View(m)); }