public ActionResult Save(string dict)
        {
            sys_dictionary _dict = new sys_dictionary();

            //_dict.group;
            //_dict.name;
            //_dict.value;

            _dict = JsonConvert.DeserializeObject <sys_dictionary>(dict);
            if (dict != null && _dict.id > 0)
            {
                Uof.Isys_dictionaryService.UpdateEntity(_dict);
                AddLog("修改配置信息ID:" + _dict.id.ToString(), " 修改配置信息", "成功");

                return(Json(new {
                    result = true,
                    id = _dict.id
                }));
            }
            else
            {
                AddLog("添加配置信息ID:" + _dict.id.ToString(), " 添加配置信息", "成功");
                _dict = Uof.Isys_dictionaryService.AddEntity(_dict);
                return(Json(new
                {
                    result = true,
                    id = _dict.id
                }));
            }
            return(Json(new { result = false }));
        }
Example #2
0
        /// <summary>
        /// 更新字典
        /// </summary>
        /// <param name="dto"></param>
        public void UpdateDicData(sys_dictionary dto)
        {
            if (dto.parent_id != 0)
            {
                var dicCode =
                    Sqldb.Queryable <sys_dictionary>().Where(s => s.id == dto.parent_id).Select(s => s.dic_code).First();

                dto.dic_code = dicCode;
            }
            Sqldb.Update <sys_dictionary>().SetSource(dto).IgnoreColumns(s => new { s.create_person, s.create_time }).ExecuteAffrows();
        }
Example #3
0
 public void InsertDicData(sys_dictionary dto)
 {
     dto.id            = IdWorkerHelper.NewId();
     dto.create_person = UserCookie.AccountName;
     dto.create_time   = DateTime.Now;
     if (dto.parent_id != 0)
     {
         var dicCode = _sysdicRepository.Queryable <sys_dictionary>().Where(s => s.id == dto.parent_id).Select(s => s.dic_code).First();
         dto.dic_code = dicCode;
     }
     _sysdicRepository.Insert(dto);
 }
Example #4
0
        public void UpdateDicData(sys_dictionary dto)
        {
            sys_dictionary sys_dictionary = _sysdicRepository.GetById(dto.id);

            if (dto.parent_id != 0)
            {
                var dicCode = _sysdicRepository.Queryable <sys_dictionary>().Where(s => s.id == dto.parent_id).Select(s => s.dic_code).First();
                dto.dic_code = dicCode;
            }
            dto.create_person = sys_dictionary.create_person ?? string.Empty;
            dto.create_time   = sys_dictionary.create_time;
            _sysdicRepository.Update(dto);
        }
Example #5
0
        //新增修改
        public IActionResult Create(string KeyId, string PId, string PName)
        {
            sys_dictionary model = null;

            if (!string.IsNullOrEmpty(KeyId))
            {
                model = bll.GetModelById <sys_dictionary>(KeyId);
            }
            model         = model ?? new sys_dictionary();
            ViewBag.PId   = PId;
            ViewBag.PName = PName;
            return(View(model));
        }
Example #6
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="dto"></param>
        public void InsertDicData(sys_dictionary dto, LoginUserDto UserCookie)
        {
            dto.id            = IdHelper.NextId();
            dto.create_person = UserCookie.LoginName;
            dto.create_time   = DateTime.Now;

            if (dto.parent_id != 0)
            {
                var dicCode =
                    Sqldb.Select <sys_dictionary>().Where(s => s.id == dto.parent_id).First(s => s.dic_code);

                dto.dic_code = dicCode;
            }
            Sqldb.Insert(dto).ExecuteAffrows();
        }
Example #7
0
        public JsonResult Create(sys_dictionary model)
        {
            ExecuteResult er   = new ExecuteResult();
            string        pids = "";

            GetPIds(ref pids, model.ParentId);
            if (string.IsNullOrEmpty(model.KeyId))
            {
                int count = bll.GetList <sys_dictionary>(item => item.ParentId == model.ParentId && item.FullName == model.FullName && item.IsDeleted == false).Count;
                if (count > 0)
                {
                    er.Result  = false;
                    er.Message = "同级别已存在相同项";
                }
                else
                {
                    #region 新增
                    model.KeyId      = Guid.NewGuid().ToString();
                    model.CreateDate = DateTime.Now;
                    model.IsDeleted  = false;
                    model.PIds       = pids;
                    er.Result        = bll.Insert <sys_dictionary>(model) > 0;
                    er.Message       = er.Result ? "新增成功" : "新增失败";
                    #endregion
                }
            }
            else
            {
                int count = bll.GetList <sys_dictionary>(item => item.ParentId == model.ParentId && item.FullName == model.FullName && item.KeyId != model.KeyId && item.IsDeleted == false).Count;
                if (count > 0)
                {
                    er.Result  = false;
                    er.Message = "同级别已存在相同项";
                }
                else
                {
                    #region 修改
                    var old = bll.GetModelById <sys_dictionary>(model.KeyId);
                    model.IsDeleted  = old.IsDeleted;
                    model.CreateDate = old.CreateDate;
                    model.PIds       = pids;
                    er.Result        = bll.Update <sys_dictionary>(model) > 0;
                    er.Message       = er.Result ? "编辑成功" : "编辑失败";
                    #endregion
                }
            }
            return(Json(er));
        }
Example #8
0
        public ActionResult SaveData(sys_dictionary dto)
        {
            dto.dic_code  = dto.dic_code ?? "";
            dto.dic_name  = dto.dic_name.Trim();
            dto.dic_value = dto.dic_name;
            if (dto.id == 0)
            {
                _dicApp.InsertDicData(dto, RequestHelper.AdminInfo());
            }
            else
            {
                _dicApp.UpdateDicData(dto);
            }

            return(Success());
        }
Example #9
0
 public ActionResult SaveData(sys_dictionary dto)
 {
     dto.dic_code  = dto.dic_code.Trim();
     dto.dic_name  = dto.dic_name.Trim();
     dto.dic_value = dto.dic_name;
     if (dto.id == 0)
     {
         _dicService.InsertDicData(dto);
         _logService.WriteLog(LogType.ADD, $"添加字典(" + dto.dic_name + ")", LogState.NORMAL);//写入日志
     }
     else
     {
         _dicService.UpdateDicData(dto);
         _logService.WriteLog(LogType.EDIT, $"修改字典(" + dto.dic_name + ")", LogState.NORMAL);//写入日志
     }
     return(Success("保存成功"));
 }