示例#1
0
        public int Update(GetGoodsStorageDetailDto getGoodsStorageDetailDto)
        {
            Goods goods = new Goods()
            {
                Id            = getGoodsStorageDetailDto.GoodsId,
                Weight        = getGoodsStorageDetailDto.Weight,
                TypeId        = getGoodsStorageDetailDto.TypeId,
                UserId        = getGoodsStorageDetailDto.UserId,
                Name          = getGoodsStorageDetailDto.GoodsName,
                Remarks       = getGoodsStorageDetailDto.GoodsRemarks,
                IsWarehousing = 1
            };

            if (!_goodsService.Update(goods))
            {
                throw new BusinessException("修改货物信息失败");
            }

            StorageRegion storageRegion = new StorageRegion()
            {
                StorageId = getGoodsStorageDetailDto.StorageId,
                RegionId  = getGoodsStorageDetailDto.RegionId
            };

            if (_goodsStorageService.GetCountByStorageRegion(storageRegion) >= _storageRegionService.Find(c => c.StorageId == getGoodsStorageDetailDto.StorageId && c.RegionId == getGoodsStorageDetailDto.RegionId).Capacity)
            {
                return(2);
            }
            GoodsStorage goodsStorage = _goodsStorageService.Find(getGoodsStorageDetailDto.GoodsStorageId);

            goodsStorage.GoodsId   = getGoodsStorageDetailDto.GoodsId;
            goodsStorage.StorageId = getGoodsStorageDetailDto.StorageId;
            goodsStorage.RegionId  = getGoodsStorageDetailDto.RegionId;
            return(_goodsStorageService.Update(goodsStorage) ? 0 : 1);
        }
示例#2
0
 public bool Add(StorageRegion storageRegion)
 {
     if (_repository.Select(c => c.RegionId == storageRegion.RegionId && c.StorageId == storageRegion.StorageId).Count > 0)
     {
         return(false);
     }
     _repository.Add(storageRegion);
     return(_unitOfWork.Commit() > 0);
 }
示例#3
0
 public IAjaxResult AddStorageRegion(StorageRegion storageRegion)
 {
     if (_storageRegionService.Add(storageRegion))
     {
         return(Success("添加成功"));
     }
     else
     {
         return(Error("添加失败"));
     }
 }
示例#4
0
        public StorageRegionModel FindStorageRegionModel(int id)
        {
            StorageRegion      storageRegion      = _repository.Find(id);
            StorageRegionModel storageRegionModel = new StorageRegionModel()
            {
                RegionId   = storageRegion.RegionId,
                RegionName = _regionRepository.Find(storageRegion.RegionId).Name,
                Capacity   = storageRegion.Capacity
            };

            return(storageRegionModel);
        }
示例#5
0
        public bool Delete(int id)
        {
            if (id <= 0)
            {
                return(false);
            }

            StorageRegion storageRegion = Find(id);

            if (storageRegion == null)
            {
                return(false);
            }
            _repository.Delete(storageRegion);
            return(_unitOfWork.Commit() > 0);
        }
示例#6
0
        public int Join(GetJoinDto getJoinDto)
        {
            Goods goods = new Goods()
            {
                Weight        = getJoinDto.Weight,
                TypeId        = getJoinDto.TypeId,
                UserId        = getJoinDto.UserId,
                Name          = getJoinDto.Name,
                Remarks       = getJoinDto.Remarks,
                IsWarehousing = 1
            };

            _goodsService.Add(goods);
            int goodsId = _goodsService.GetId(goods);

            if (_goodsStorageService.Find(c => c.GoodsId == goodsId && c.RegionId == getJoinDto.RegionId && c.StorageId == getJoinDto.StorageId && c.State == 0) != null)
            {
                return(3);
            }

            StorageRegion storageRegion = new StorageRegion()
            {
                StorageId = getJoinDto.StorageId,
                RegionId  = getJoinDto.RegionId
            };

            //判断仓库中的货物数量是否超出最大容量
            if (_goodsStorageService.GetCountByStorageRegion(storageRegion) >= _storageRegionService.Find(c => c.StorageId == getJoinDto.StorageId && c.RegionId == getJoinDto.RegionId).Capacity)
            {
                return(2);
            }

            GoodsStorage goodsStorage = new GoodsStorage()
            {
                GoodsId   = goodsId,
                StorageId = getJoinDto.StorageId,
                RegionId  = getJoinDto.RegionId,
                State     = 0
            };

            return(_goodsStorageService.Add(goodsStorage) ? 0 : 1);
        }
示例#7
0
        public bool AddNewRegion(GetRegionDto getRegionDto)
        {
            if (_regionService.Find(c => c.Name == getRegionDto.RegionName) == null)
            {
                if (_regionService.Add(getRegionDto.RegionName) != 0)
                {
                    return(false);
                }
            }

            Region        region        = _regionService.Find(c => c.Name == getRegionDto.RegionName);
            StorageRegion storageRegion = new StorageRegion()
            {
                RegionId  = region.Id,
                StorageId = getRegionDto.StorageId,
                Capacity  = getRegionDto.RegionCapacity
            };

            return(_storageRegionService.Add(storageRegion));
        }
示例#8
0
        public bool Update(GetStorageRegionDto getStorageRegionDto)
        {
            if (getStorageRegionDto.Id <= 0)
            {
                return(false);
            }

            Region tempRegion = _regionRepository.Find(getStorageRegionDto.RegionId);

            if (!tempRegion.Name.Equals(getStorageRegionDto.RegionName))
            {
                tempRegion.Name = getStorageRegionDto.RegionName;
                _regionRepository.Update(tempRegion);
                _unitOfWork.Commit();
            }

            StorageRegion tempStorageRegion = Find(getStorageRegionDto.Id);

            tempStorageRegion.Capacity = getStorageRegionDto.Capacity;

            _repository.Update(tempStorageRegion);
            return(_unitOfWork.Commit() > 0);
        }
示例#9
0
 public int GetCountByStorageRegion(StorageRegion storageRegion)
 {
     return(_repository.Select(c => c.StorageId == storageRegion.StorageId && c.RegionId == storageRegion.RegionId && c.State == 0).Count);
 }
示例#10
0
 public bool Delete(StorageRegion storageRegion)
 {
     _repository.Delete(storageRegion);
     return(_unitOfWork.Commit() > 0);
 }