public ActionResult Create(string name, decimal sale) { try { if (string.IsNullOrWhiteSpace(name)) { return(Json(new ResultMsg() { Code = -1, CodeText = "请输入名称" })); } var model = new Grades(); model.name = name; model.sale = sale; if (IGradesService.Insert(model) > 0) { return(Json(new ResultMsg() { Code = 0 })); } return(Json(new ResultMsg() { Code = -1, CodeText = "添加失败" })); } catch (Exception ex) { return(Json(new ResultMsg() { Code = -1, CodeText = "系统错误,联系管理员" })); } }