Beispiel #1
0
        /// <summary>
        /// 更新存储类型
        /// </summary>
        /// <param name="inputDto">存储类型信息</param>
        /// <returns></returns>
        public ReturnInfo UpdateWhStorageType(WHStorageTypeInputDto inputDto)
        {
            ReturnInfo    RInfo        = new ReturnInfo();
            StringBuilder sb           = new StringBuilder();
            string        ValidateInfo = Helper.BasicValidate(inputDto).ToString();

            sb.Append(ValidateInfo);
            if (sb.Length == 0)
            {
                try
                {
                    WHStorageType whStorageType = _wHStorageTypeReposity.GetById(inputDto.WAREID, inputDto.STID).FirstOrDefault();
                    if (whStorageType != null)
                    {
                        whStorageType.NAME       = inputDto.NAME;
                        whStorageType.ISENABLE   = inputDto.ISENABLE;
                        whStorageType.MODIFYUSER = inputDto.MODIFYUSER;
                        whStorageType.MODIFYDATE = DateTime.Now;
                        _unitOfWork.RegisterDirty(whStorageType);
                    }

                    bool result = _unitOfWork.Commit();
                    RInfo.IsSuccess = result;
                    RInfo.ErrorInfo = sb.ToString();
                    return(RInfo);
                }
                catch (Exception ex)
                {
                    _unitOfWork.Rollback();
                    sb.Append(ex.Message);
                    RInfo.IsSuccess = false;
                    RInfo.ErrorInfo = sb.ToString();
                    return(RInfo);
                }
            }
            else
            {
                RInfo.IsSuccess = false;
                RInfo.ErrorInfo = sb.ToString();
                return(RInfo);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 启用/禁用:仓库/存储类型/库位
        /// </summary>
        /// <param name="wareId"></param>
        /// <param name="stId"></param>
        /// <returns></returns>
        public ReturnInfo ChangeEnable(string wareId, string stId, string SlId, IsEnable isEnable)
        {
            ReturnInfo RInfo = new ReturnInfo();

            // 启用/禁用库位
            if (!String.IsNullOrEmpty(wareId) && !String.IsNullOrEmpty(stId) && !String.IsNullOrEmpty(SlId))
            {
                WHStorageLocation wHStorageLocation = _wHStorageLocationRepository.GetById(wareId, stId, SlId).FirstOrDefault();
                if (wHStorageLocation != null)
                {
                    if (wHStorageLocation.ISENABLE == (int)isEnable && isEnable == IsEnable.启用)
                    {
                        throw new Exception("该库位已启用,不可重复启用");
                    }
                    else if (wHStorageLocation.ISENABLE == (int)isEnable && isEnable == IsEnable.禁用)
                    {
                        throw new Exception("该库位已禁用,不可重复禁用");
                    }
                    wHStorageLocation.ISENABLE = (int)isEnable;
                }
                else
                {
                    throw new Exception("当前库位不存在");
                }
            }
            // 启用/禁用存储类型
            else if (!String.IsNullOrEmpty(wareId) && !String.IsNullOrEmpty(stId))
            {
                WHStorageType wHStorageType = _wHStorageTypeReposity.GetById(wareId, stId).FirstOrDefault();
                if (wHStorageType != null)
                {
                    if (wHStorageType.ISENABLE == (int)isEnable && isEnable == IsEnable.启用)
                    {
                        throw new Exception("该存储类型已启用,不可重复启用");
                    }
                    else if (wHStorageType.ISENABLE == (int)isEnable && isEnable == IsEnable.禁用)
                    {
                        throw new Exception("该存储类型已禁用,不可重复禁用");
                    }
                    wHStorageType.ISENABLE = (int)isEnable;
                }
                else
                {
                    throw new Exception("当前存储类型不存在");
                }
            }
            else      // 启用/禁用仓库
            {
                WareHouse wareHouse = _warehouseRepository.GetById(wareId).FirstOrDefault();
                if (wareHouse != null)
                {
                    if (wareHouse.ISENABLE == (int)isEnable && isEnable == IsEnable.启用)
                    {
                        throw new Exception("该仓库已启用,不可重复启用");
                    }
                    else if (wareHouse.ISENABLE == (int)isEnable && isEnable == IsEnable.禁用)
                    {
                        throw new Exception("该仓库已禁用,不可重复禁用");
                    }
                    wareHouse.ISENABLE = (int)isEnable;
                }
                else
                {
                    throw new Exception("当前仓库不穿在");
                }
            }
            try
            {
                _unitOfWork.Commit();
                RInfo.IsSuccess = true;
                return(RInfo);
            }
            catch (Exception ex)
            {
                _unitOfWork.Rollback();
                RInfo.IsSuccess = false;
                RInfo.ErrorInfo = ex.Message;
                return(RInfo);
            }
        }