public JsonResult Create([Bind(Include = "Name,code, remark")] ResignType resignType) { ResultMessage msg = new ResultMessage(); try { msg = DoValidation(resignType); if (!msg.Success) { return(Json(msg, JsonRequestBehavior.AllowGet)); } else { IResignTypeService cs = new ResignTypeService(Settings.Default.db); bool isSucceed = cs.Create(resignType); 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)); } }
// GET: ResignType/Delete/5 public ActionResult Delete(int id) { IResignTypeService cs = new ResignTypeService(Settings.Default.db); ResignType cp = cs.FindById(id); //SetDropDownList(cp); return(View(cp)); }
// GET: ResignType/Edit/5 public ActionResult Edit(int id) { IResignTypeService cs = new ResignTypeService(Settings.Default.db); ResignType jt = cs.FindById(id); //SetDropDownList(jt); return(View(jt)); }
//4.5 保险类别管理 //(列表(分页)、新建、编辑、删除(存在员工时不可删除) //):名称(不可空),备注(可空) public ResultMessage DoValidation(ResignType model) { ResultMessage msg = new ResultMessage(); if (string.IsNullOrEmpty(model.code)) { msg.Success = false; msg.Content = "编码不能为空"; return(msg); } if (string.IsNullOrEmpty(model.name)) { msg.Success = false; msg.Content = "名称不能为空"; return(msg); } IResignTypeService cs = new ResignTypeService(Settings.Default.db); List <ResignType> shift = cs.GetAll(); if (model.id <= 0) { bool isRecordExists = shift.Where(p => p.name == model.name || p.code == model.code).ToList().Count() > 0; if (isRecordExists) { msg.Success = false; msg.Content = "数据已经存在!"; return(msg); } } else { bool isRecordExists = shift.Where(p => (p.name == model.name || p.code == model.code) && p.id != model.id).ToList().Count() > 0; if (isRecordExists) { msg.Success = false; msg.Content = "数据已经存在!"; return(msg); } } return(new ResultMessage() { Success = true, Content = "" }); }
public bool Update(ResignType resignType) { return(resignTypeRep.Update(resignType)); }
public bool Create(ResignType resignType) { return(resignTypeRep.Create(resignType)); }