Esempio n. 1
0
        public void Save(WMS_C104_OutStore outstore, List <WMS_C105_OutStoreDetail> outstoreDetailList)
        {
            tb_Sys_User tempUser    = appCacheService.GetItem("user") as tb_Sys_User;
            var         existslotTx = this.GetById(outstore.Id);

            if (existslotTx == null)
            {
                outstore.CompCode   = tempUser.CompCode;
                outstore.CreateDt   = DateTime.Now;
                outstore.CreateUser = tempUser.UserName;
                outstore.Validate();
                this.WMS_C104_OutStoreRepository.Add(outstore);
            }
            else
            {
                outstore.ModifyDt   = DateTime.Now;
                outstore.ModifyUser = tempUser.UserName;
                outstore.Validate();
                this.WMS_C104_OutStoreRepository.SetValues(outstore, existslotTx);
            }
            if (outstoreDetailList != null)
            {
                foreach (var detail in outstoreDetailList)
                {
                    var existstoutStoreDetail = this.outStoreDetailRepository.GetByID(detail.Id);
                    if (existstoutStoreDetail == null)
                    {
                        //var stock = this.stockRepostiroy.GetMany(i => i.Id == detail.StockId).FirstOrDefault();
                        var stock = this.stockRepostiroy.GetMany(i => i.ARCode == detail.ARCode && i.PartSpec == detail.PartSpec && i.MatClass2 == detail.MatClass2).FirstOrDefault();
                        if (stock == null)
                        {
                            throw new AppException(string.Format("出库单'{0}'在位置'{1}'没有库存,请检查", detail.OutSotreNo, detail.ARCode));
                        }
                        if (detail.Amount > stock.StoreAmount)
                        {
                            throw new AppException(string.Format("出库单'{0}'在位置'{1}'的库存小于出库数量,请检查", detail.OutSotreNo, detail.ARCode));
                        }
                        detail.CompCode   = tempUser.CompCode;
                        detail.CreateDt   = DateTime.Now;
                        detail.CreateUser = tempUser.UserName;
                        detail.Validate();
                        this.outStoreDetailRepository.Add(detail);
                        //更新库存
                        stock.StoreAmount = stock.StoreAmount - detail.Amount;
                    }
                    else
                    {
                        if (existstoutStoreDetail.Amount != detail.Amount)
                        {
                            throw new AppException(string.Format("出库单'{0}'在位置'{1}'的已经出库,无法修改", detail.OutSotreNo, detail.ARCode));
                        }
                        detail.Validate();
                        this.outStoreDetailRepository.SetValues(detail, existstoutStoreDetail);
                    }
                }
            }
            this.runtimeService.Commit();
        }
Esempio n. 2
0
        public void Create(WMS_C104_OutStore WMS_C104_OutStore)
        {
            WMS_C104_OutStore.CreateDt = DateTime.Now;
            tb_Sys_User tempUser = appCacheService.GetItem("user") as tb_Sys_User;

            WMS_C104_OutStore.CreateUser = tempUser.UserName;
            WMS_C104_OutStore.CompCode   = tempUser.CompCode;
            WMS_C104_OutStore.Validate();
            this.WMS_C104_OutStoreRepository.Add(WMS_C104_OutStore);
            this.runtimeService.Commit();
        }
Esempio n. 3
0
        public void Update(WMS_C104_OutStore WMS_C104_OutStore)
        {
            WMS_C104_OutStore.ModifyDt = DateTime.Now;
            tb_Sys_User tempUser = appCacheService.GetItem("user") as tb_Sys_User;

            WMS_C104_OutStore.ModifyUser = tempUser.UserName;
            WMS_C104_OutStore.Validate();
            var existstb_Sys_Menu = this.GetById(WMS_C104_OutStore.Id);

            this.WMS_C104_OutStoreRepository.SetValues(WMS_C104_OutStore, existstb_Sys_Menu);
            this.runtimeService.Commit();
        }