Esempio n. 1
0
        public ActionResult Add()
        {
            string         StorageNum = WebUtil.GetQueryStringValue <string>("StorageNum");
            string         LocalNum   = WebUtil.GetQueryStringValue <string>("SnNum", string.Empty);
            LocationEntity entity     = null;
            ITopClient     client     = new TopClientDefault();

            if (!LocalNum.IsEmpty())
            {
                Dictionary <string, string> dic = new Dictionary <string, string>();
                dic.Add("CompanyID", CompanyID);
                dic.Add("LocalNum", LocalNum);

                string result = client.Execute(LocationApiName.LocationApiName_Single, dic);
                DataResult <LocationEntity> dataResult = JsonConvert.DeserializeObject <DataResult <LocationEntity> >(result);
                entity = dataResult.Result;
            }

            entity            = entity.IsNull() ? new LocationEntity() : entity;
            ViewBag.Entity    = entity;
            entity.StorageNum = entity.StorageNum.IsEmpty() ? StorageNum : entity.StorageNum;
            ViewBag.LocalType = EnumHelper.GetOptions <ELocalType>(entity.LocalType);
            ViewBag.Storage   = DropDownHelper.GetStorage(entity.StorageNum, this.CompanyID);
            return(View());
        }
Esempio n. 2
0
        /// <summary>
        /// 获得产品的缓存数据
        /// </summary>
        /// <returns></returns>
        public List <ProductEntity> GetList()
        {
            string Key = string.Format(CacheKey.JOOSHOW_PRODUCT_CACHE, this.CompanyID);
            List <ProductEntity> list = CacheHelper.Get(Key) as List <ProductEntity>;

            if (!list.IsNullOrEmpty())
            {
                return(list);
            }
            ProductEntity entity = new ProductEntity();

            entity.IncludeAll();
            entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete)
            .And(a => a.CompanyID == this.CompanyID);
            entity.OrderBy(a => a.ID, EOrderBy.DESC);
            list = this.Product.GetList(entity);

            if (!list.IsNullOrEmpty())
            {
                StorageProvider      storageProvider = new StorageProvider(this.CompanyID);
                List <StorageEntity> listStorage     = storageProvider.GetList();
                listStorage = listStorage.IsNull() ? new List <StorageEntity>() : listStorage;

                LocationProvider      locationProvider = new LocationProvider(this.CompanyID);
                List <LocationEntity> listLocation     = locationProvider.GetList();
                listLocation = listLocation.IsNull() ? new List <LocationEntity>() : listLocation;

                foreach (ProductEntity item in list)
                {
                    if (!item.StorageNum.IsEmpty())
                    {
                        StorageEntity storage = listStorage.FirstOrDefault(a => a.SnNum == item.StorageNum);
                        item.StorageName = storage.IsNull() ? string.Empty : storage.StorageName;
                    }

                    if (!item.DefaultLocal.IsEmpty())
                    {
                        LocationEntity location = listLocation.FirstOrDefault(a => a.LocalNum == item.DefaultLocal);
                        item.LocalName = location.IsNull() ? string.Empty : location.LocalName;
                    }
                }
            }
            if (!list.IsNullOrEmpty())
            {
                CacheHelper.Insert(Key, list);
            }
            return(list);
        }
Esempio n. 3
0
        /// <summary>
        /// 创建单据
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        public override string Create(AllocateOrderEntity entity, List <AllocateDetailEntity> list)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                int line = 0;
                entity.SnNum      = ConvertHelper.NewGuid();
                entity.OrderNum   = entity.OrderNum.IsEmpty() ? new SequenceProvider(this.CompanyID).GetSequence(typeof(AllocateOrderEntity)) : entity.OrderNum;
                entity.CreateTime = DateTime.Now;
                entity.IncludeAll();

                if (!list.IsNullOrEmpty())
                {
                    string                StorageNum       = list[0].ToStorageNum;
                    LocationProvider      locationProvider = new LocationProvider(this.CompanyID);
                    List <LocationEntity> listLocation     = locationProvider.GetList(StorageNum);
                    if (listLocation.IsNullOrEmpty())
                    {
                        return("1001");
                    }
                    LocationEntity location = listLocation.FirstOrDefault(a => a.LocalType == (int)ELocalType.WaitIn);
                    if (location.IsNull())
                    {
                        return("1002");
                    }

                    list.ForEach(a =>
                    {
                        a.OrderNum   = entity.OrderNum;
                        a.OrderSnNum = entity.SnNum;
                        a.CompanyID  = this.CompanyID;
                        a.CreateTime = DateTime.Now;
                        a.ToLocalNum = location.LocalNum;
                        a.IncludeAll();
                    });

                    entity.Num    = list.Sum(q => q.Num);
                    entity.Amount = list.Sum(a => a.Amount);

                    line  = this.AllocateOrder.Add(entity);
                    line += this.AllocateDetail.Add(list);
                }
                ts.Complete();
                return(line > 0 ? EnumHelper.GetEnumDesc <EReturnStatus>(EReturnStatus.Success) : string.Empty);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 编辑报损单
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        public override string EditOrder(AllocateOrderEntity entity, List <AllocateDetailEntity> list)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                int line = 0;
                entity.Include(a => new
                {
                    a.AllocateType,
                    a.ProductType,
                    a.StorageNum,
                    a.ContractOrder,
                    a.Remark,
                    a.Num,
                    a.Amount,
                    a.Weight
                });
                entity.Where(a => a.SnNum == entity.SnNum)
                .And(a => a.CompanyID == this.CompanyID)
                ;

                AllocateDetailEntity detail = new AllocateDetailEntity();
                detail.Where(a => a.OrderSnNum == entity.SnNum)
                .And(a => a.CompanyID == this.CompanyID)
                ;
                this.AllocateDetail.Delete(detail);

                if (!list.IsNullOrEmpty())
                {
                    string                StorageNum       = list[0].ToStorageNum;
                    LocationProvider      locationProvider = new LocationProvider(this.CompanyID);
                    List <LocationEntity> listLocation     = locationProvider.GetList(StorageNum);
                    if (listLocation.IsNullOrEmpty())
                    {
                        return("1001");
                    }
                    LocationEntity location = listLocation.FirstOrDefault(a => a.LocalType == (int)ELocalType.WaitIn);
                    if (location.IsNull())
                    {
                        return("1002");
                    }

                    foreach (AllocateDetailEntity item in list)
                    {
                        item.OrderNum   = entity.OrderNum;
                        item.OrderSnNum = entity.SnNum;
                        item.CompanyID  = this.CompanyID;
                        item.ToLocalNum = location.LocalNum;
                        item.CreateTime = DateTime.Now;
                        item.IncludeAll();
                    }
                }

                entity.Num    = list.Sum(a => a.Num);
                entity.Amount = list.Sum(a => a.Amount);

                line = this.AllocateOrder.Update(entity);
                this.AllocateDetail.Add(list);

                ts.Complete();
                return(line > 0 ? EnumHelper.GetEnumDesc <EReturnStatus>(EReturnStatus.Success) : string.Empty);
            }
        }