public ActionResult editthcs(DM_LopHocTHCS thcs) { if (String.IsNullOrEmpty(thcs.NamHoc)) { return(Json(new ResultInfo() { error = 1, msg = "Missing info" }, JsonRequestBehavior.AllowGet)); } var check = db.DM_LopHocTHCS.Where(p => p.MaTruong == MaTruong && p.NamHoc == thcs.NamHoc).FirstOrDefault(); if (check == null) { return(Json(new ResultInfo() { error = 1, msg = "Không tìm thấy thông tin" }, JsonRequestBehavior.AllowGet)); } check.Lop6 = thcs.Lop6; check.Lop7 = thcs.Lop7; check.Lop8 = thcs.Lop8; check.Lop9 = thcs.Lop9; db.Entry(check).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(Json(new ResultInfo() { error = 0, msg = "", data = thcs }, JsonRequestBehavior.AllowGet)); }
public ActionResult createthcs(DM_LopHocTHCS thcs) { if (String.IsNullOrEmpty(thcs.NamHoc)) { return(Json(new ResultInfo() { error = 1, msg = "Missing info" }, JsonRequestBehavior.AllowGet)); } var check = db.DM_LopHocTHCS.Where(p => p.MaTruong == MaTruong && p.NamHoc == thcs.NamHoc).FirstOrDefault(); if (check != null) { return(Json(new ResultInfo() { error = 1, msg = "Đã tồn tại" }, JsonRequestBehavior.AllowGet)); } thcs.MaTruong = MaTruong; db.DM_LopHocTHCS.Add(thcs); db.SaveChanges(); return(Json(new ResultInfo() { error = 0, msg = "", data = thcs }, JsonRequestBehavior.AllowGet)); }