Ejemplo n.º 1
0
        public ActionResult AddProduct([ModelBinder(typeof(JsonBinder <List <LocalProductEntity> >))] List <LocalProductEntity> list)
        {
            List <OutStoDetailEntity> ListCache = Session[CacheKey.TEMPDATA_CACHE_OUTSTORDETAIL] as List <OutStoDetailEntity>;

            ListCache = ListCache.IsNull() ? new List <OutStoDetailEntity>() : ListCache;
            if (!list.IsNullOrEmpty())
            {
                List <ProductEntity> ListSource = new ProductProvider().GetListByCache();
                foreach (LocalProductEntity item in list)
                {
                    ProductEntity product = ListSource.FirstOrDefault(a => a.SnNum == item.ProductNum);
                    if (product.IsNotNull())
                    {
                        if (!ListCache.Exists(a => a.ProductNum == item.ProductNum && a.BatchNum == item.BatchNum && a.LocalNum == item.LocalNum))
                        {
                            OutStoDetailEntity entity = new OutStoDetailEntity();
                            entity.SnNum       = SequenceProvider.GetSequence(typeof(OutStoDetailEntity));
                            entity.ProductName = product.ProductName;
                            entity.BarCode     = product.BarCode;
                            entity.BatchNum    = item.BatchNum;
                            entity.ProductNum  = product.SnNum;
                            entity.LocalNum    = item.LocalNum;
                            entity.LocalName   = item.LocalName;
                            entity.Color       = item.Color;
                            entity.Count       = item.Count;
                            entity.StorageNum  = this.DefaultStore;
                            entity.Num         = item.Num;
                            entity.IsPick      = (int)EBool.No;
                            entity.Size        = item.Size;
                            entity.RealNum     = 0;
                            entity.OutPrice    = product.InPrice;
                            entity.Amount      = product.InPrice * entity.Num;
                            entity.CreateTime  = DateTime.Now;
                            ListCache.Add(entity);
                        }
                        else
                        {
                            OutStoDetailEntity entity = ListCache.First(a => a.ProductNum == item.ProductNum && a.BatchNum == item.BatchNum && a.LocalNum == item.LocalNum);
                            entity.Num       += item.Num;
                            entity.OutPrice   = product.InPrice;
                            entity.Amount     = product.InPrice * entity.Num;
                            entity.CreateTime = DateTime.Now;
                        }
                    }
                }
            }
            if (!ListCache.IsNullOrEmpty())
            {
                Session[CacheKey.TEMPDATA_CACHE_OUTSTORDETAIL] = ListCache;
            }
            return(Content(string.Empty));
        }
Ejemplo n.º 2
0
        public ActionResult Detail()
        {
            string orderNum = WebUtil.GetQueryStringValue <string>("orderNum", string.Empty);
            string flag     = WebUtil.GetQueryStringValue <string>("flag", string.Empty);
            Bill <OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder();
            OutStorageEntity entity = new OutStorageEntity();

            entity.OrderNum = orderNum;
            entity          = bill.GetOrder(entity);
            entity          = entity.IsNull() ? new OutStorageEntity() : entity;
            ViewBag.Entity  = entity;
            ViewBag.OutType = EnumHelper.GetEnumDesc <EOutType>(entity.OutType);
            ViewBag.Status  = EnumHelper.GetEnumDesc <EAudite>(entity.Status);


            OutStoDetailEntity detail = new OutStoDetailEntity();

            detail.OrderNum = orderNum;
            List <OutStoDetailEntity> listResult = bill.GetOrderDetail(detail);

            listResult = listResult.IsNull() ? new List <OutStoDetailEntity>() : listResult;

            ProductProvider      provider = new ProductProvider();
            List <ProductEntity> list     = provider.GetListByCache();

            list = list.IsNull() ? new List <ProductEntity>() : list;
            listResult.ForEach(a =>
            {
                ProductEntity product = null;
                if (a.BarCode.IsEmpty())
                {
                    product = list.SingleOrDefault(b => b.SnNum == a.ProductNum);
                }
                else
                {
                    product = list.SingleOrDefault(b => b.SnNum == a.ProductNum && b.BarCode == a.BarCode);
                }
                if (product.IsNotNull())
                {
                    a.Size = product.Size.IsEmpty() ? "" : product.Size;
                }
                else
                {
                    a.Size = "";
                }
            });
            ViewBag.Detail = listResult;
            ViewBag.Flag   = flag;
            return(View());
        }