public JsonResult Delete(int id, FormCollection collection) { ResultMessage msg = new ResultMessage(); try { //存在员工时不可删除 IStaffService shfSi = new StaffService(Settings.Default.db); List <Staff> shf = shfSi.FindByJobTitleId(id); if (null != shf && shf.Count() > 0) { msg.Success = false; msg.Content = "职位信息正在使用,不能删除!"; return(Json(msg, JsonRequestBehavior.AllowGet)); } else { IJobTitleService cs = new JobTitleService(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)); } }