public JsonResult EditDictItem(T_Sys_DictItem dictItem) { //T_Sys_DictItem dictItem = JsonHelper.ConvertJsonString2Object<T_Sys_DictItem>(data); MsgEntity me = dictService.EditDictItem(dictItem); return(this.Json(me, JsonRequestBehavior.DenyGet)); }
public JsonResult AddDictItem(string data) { T_Sys_DictItem dictItem = JsonHelper.ConvertJsonString2Object <T_Sys_DictItem>(data); dictItem.ID = RandomHelper.GetUUID(); MsgEntity me = dictService.AddDictItem(dictItem); return(this.Json(me, JsonRequestBehavior.DenyGet)); }
/// <summary> /// 修改字典 /// </summary> /// <param name="dict"></param> /// <returns></returns> public MsgEntity EditDictItem(T_Sys_DictItem dictItem) { MsgEntity me = new MsgEntity(); if (dictItem == null || string.IsNullOrEmpty(dictItem.DI_CODE)) { me.MsgCode = MsgEntity.MsgCodeEnum.Failure; me.MsgDes = "字典项编码不能为空"; return(me); } //查找关键字是否有相同值(不同id的dict_code不能相同) PredicateGroup pg = new PredicateGroup { Operator = GroupOperator.And, Predicates = new List <IPredicate>() }; pg.Predicates.Add(Predicates.Field <T_Sys_DictItem>(f => f.DI_CODE, Operator.Eq, dictItem.DI_CODE)); pg.Predicates.Add(Predicates.Field <T_Sys_DictItem>(f => f.ID, Operator.Eq, dictItem.ID, true)); int count = dao.Count <T_Sys_DictItem>(pg); if (count > 0) { me.MsgCode = MsgEntity.MsgCodeEnum.Failure; me.MsgDes = "字典项编码重复"; return(me); } bool result = false; try { result = dao.Update <T_Sys_DictItem>(dictItem); me.MsgCode = MsgEntity.MsgCodeEnum.Success; me.MsgDes = "字典项编辑成功"; } catch (Exception ex) { me.MsgCode = MsgEntity.MsgCodeEnum.Failure; me.MsgDes = ex.Message; } return(me); }
/// <summary> /// 添加字典 /// </summary> /// <param name="dict"></param> /// <returns></returns> public MsgEntity AddDictItem(T_Sys_DictItem dictItem) { MsgEntity me = new MsgEntity(); if (dictItem == null || string.IsNullOrEmpty(dictItem.DI_CODE)) { me.MsgCode = MsgEntity.MsgCodeEnum.Failure; me.MsgDes = "字典项编码不能为空"; return(me); } //查找关键字是否有相同值 int count = dao.Count <T_Sys_DictItem>(Predicates.Field <T_Sys_DictItem>(f => f.DI_CODE, Operator.Eq, dictItem.DI_CODE)); if (count > 0) { me.MsgCode = MsgEntity.MsgCodeEnum.Failure; me.MsgDes = "字典项编码重复"; return(me); } dynamic result = null; try { result = dao.Insert <T_Sys_DictItem>(dictItem); } catch (Exception ex) { throw ex; } if (result != null) { me.MsgCode = MsgEntity.MsgCodeEnum.Success; me.MsgDes = MsgEntity.MsgCodeEnum.Success.GetDescription(); } return(me); }