public JsonResult Delete(int id, FormCollection collection) { ResultMessage msg = new ResultMessage(); try { //存在员工时不可删除 IStaffService shfSi = new StaffService(Settings.Default.db); List <Staff> shf = shfSi.FindByStaffType(id); if (null != shf && shf.Count() > 0) { msg.Success = false; msg.Content = "人员类型信息正在使用,不能删除!"; return(Json(msg, JsonRequestBehavior.AllowGet)); } else { IStaffTypeService cs = new StaffTypeService(Settings.Default.db); bool isSucceed = cs.DeleteById(id); msg.Success = isSucceed; msg.Content = isSucceed ? "" : "删除失败"; return(Json(msg, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new ResultMessage() { Success = false, Content = ex.Message }, JsonRequestBehavior.AllowGet)); } }