Exemple #1
0
        /// <summary>
        /// 保存部门信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public ReturnMsg SaveMdmDeptInfo(MdmDeptMstrDto dto)
        {
            var rm     = new ReturnMsg();
            var entity = new MdmDeptMstr();
            var isOk   = CheckMdmDeptInfo(dto, rm);

            if (!isOk.IsSuccess)
            {
                return(rm);
            }
            if (dto.Id == 0)
            {
                dto.ORG_NO = AbpSession.ORG_NO;
                _initHelper.InitAdd(dto, AbpSession.USR_ID, AbpSession.ORG_NO, AbpSession.BG_NO);
                entity = dto.ToEntity();
                _mdmDeptMstrRepository.Insert(entity);
            }
            else
            {
                _initHelper.InitUpdate(dto, AbpSession.USR_ID);
                entity = dto.ToEntity();
                _mdmDeptMstrRepository.Update(entity);
            }
            rm.IsSuccess = true;

            return(rm);
        }
Exemple #2
0
 public ActionResult SaveMdmDeptfo([FromBody] MdmDeptMstrDto dto)
 {
     try
     {
         var result = _mdmDeptMstrService.SaveMdmDeptInfo(dto);
         if (!result.IsSuccess)
         {
             return(Fail(result.msg));
         }
         return(Success("保存成功"));
     }
     catch (Exception ex)
     {
         return(Fail(ex.Message));
     }
 }
Exemple #3
0
        /// <summary>
        /// 校验部门信息
        /// </summary>
        /// <param name="dto"></param>
        /// <param name="rm"></param>
        /// <returns></returns>
        public ReturnMsg CheckMdmDeptInfo(MdmDeptMstrDto dto, ReturnMsg rm)
        {
            if (string.IsNullOrEmpty(dto.DEPT_NO))
            {
                rm.IsSuccess = false;
                rm.msg       = "请输入部门编号";
                return(rm);
            }
            if (string.IsNullOrEmpty(dto.DEPT_NAME))
            {
                rm.IsSuccess = false;
                rm.msg       = "请输入部门名称";
                return(rm);
            }
            var result = new List <MdmDeptMstr>();

            result = dto.Id == 0 ? _mdmDeptMstrRepository.GetAllList(c => c.DEPT_NO == dto.DEPT_NO && c.DEL_FLAG == 1 && c.BG_NO == AbpSession.BG_NO)
                : _mdmDeptMstrRepository.GetAllList(c => c.DEPT_NO == dto.DEPT_NO && c.Id != dto.Id & c.DEL_FLAG == 1 && c.BG_NO == AbpSession.BG_NO);
            if (result.Count > 0)
            {
                rm.IsSuccess = false;
                rm.msg       = "部门编号已存在,请重新输入";
                return(rm);
            }
            result = dto.Id == 0 ? _mdmDeptMstrRepository.GetAllList(c => c.DEPT_NAME == dto.DEPT_NAME && c.DEL_FLAG == 1 && c.BG_NO == AbpSession.BG_NO)
                : _mdmDeptMstrRepository.GetAllList(c => c.DEPT_NAME == dto.DEPT_NAME && c.Id != dto.Id & c.DEL_FLAG == 1 && c.BG_NO == AbpSession.BG_NO);
            if (result.Count > 0)
            {
                rm.IsSuccess = false;
                rm.msg       = "部门名称已存在,请重新输入";
                return(rm);
            }
            rm.IsSuccess = true;

            return(rm);
        }