//删除功能 public JsonResult DeleteEmp(List <int> IdList) { using (G3TextEntities db = new G3TextEntities()) { //包含集合 //先查询 var lst = db.T_Emp.Where(c => IdList.Contains(c.EmpId)).ToList(); foreach (var item in lst) { //移除 db.T_Emp.Remove(item); } int rs = db.SaveChanges(); if (rs > 0) { var obj = new { status = "success", msg = "删除成功..." }; return(Json(obj, JsonRequestBehavior.AllowGet)); } else { var obj = new { status = "error", msg = "删除失败..." }; return(Json(obj, JsonRequestBehavior.AllowGet)); } } }
public JsonResult CreateEmp(T_Emp emp) { using (G3TextEntities db = new G3TextEntities()) { db.T_Emp.Add(emp); int rs = db.SaveChanges(); if (rs > 0) { var obj = new { msg = "新增成功..." }; return(Json(obj)); } else { var obj = new { msg = "新增失败..." }; return(Json(obj)); } } }