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