Esempio n. 1
0
        /// <summary>
        /// 生产出入库
        /// </summary>
        /// <returns></returns>
        public virtual StockEntity CreateStocks()
        {
            if (PurchaseItems == null || PurchaseItems.Count(it => it.Product != null && it.Product.Id != 0) == 0)
            {
                return(null);
            }
            var info = new StockEntity {
                Purchase = this, StockItems = new List <StockItemEntity>(), SaveType = SaveType.Add
            };

            foreach (var purchaseItem in PurchaseItems.Where(it => it.Product != null && it.Product.Id != 0))
            {
                var stockItem = new StockItemEntity
                {
                    Count      = purchaseItem.Count,
                    Stock      = info,
                    Product    = purchaseItem.Product,
                    Storehouse = Storehouse,
                    Name       = purchaseItem.Name,
                    SaveType   = SaveType.Add
                };
                info.StockItems.Add(stockItem);
            }

            return(info);
        }
Esempio n. 2
0
        private async void SavePurchaseItem()
        {
            IRestDataMapper mapper = containerExtension.Resolve <IRestDataMapper>();

            CurrentPurchaseItem.recordState  = ConstValues.RCS_FINE;
            CurrentPurchaseItem.purchaseType = GetPurchaseType();
            decimal      rq = (CurrentPurchaseItem.reorderLevel * SelectedUom.baseRatioToPurchase * SelectedUom.purchaseQuantifyValue);
            PurchaseItem pi = PurchaseItems.Where(i => i.item.id == SelectedItem.id).FirstOrDefault();

            if (pi != null)
            {
                SelectedStore.reorderLevel      += rq;
                CurrentPurchaseItem.reorderLevel = rq;
                CurrentPurchaseItem = CurrentPurchaseItem.Merge(pi);
                _ = await PurchaseRestService.UpdatePurchaseItemAsync(mapper, CurrentPurchaseItem);

                _ = await ItemRestService.UpdateStoreInforAsync(mapper, SelectedStore);

                PurchaseItem np = CurrentPurchaseItem.CloneObject();
                PurchaseItems.Remove(pi);
                PurchaseItems.Add(np);
                SelectedStore       = null;
                SelectedUom         = null;
                SelectedItem        = null;
                SelectedItmCt       = null;
                CurrentPurchaseItem = null;
            }
            else
            {
                CurrentPurchaseItem.reorderLevel = rq;
                SelectedStore.reorderLevel       = rq;
                CurrentPurchaseItem = await PurchaseRestService.CreatePurchaseItemAsync(mapper, CurrentPurchaseItem);

                if (CurrentPurchaseItem.id > 0)
                {
                    _ = await ItemRestService.UpdateStoreInforAsync(mapper, SelectedStore);

                    PurchaseItems.Add(CurrentPurchaseItem.CloneObject());
                    SelectedStore       = null;
                    SelectedUom         = null;
                    SelectedItem        = null;
                    SelectedItmCt       = null;
                    CurrentPurchaseItem = null;
                }
                else
                {
                    _ = ShowMessageDialg("Saving Purchase Item", "Can't Savae Purchase Item, found Some problems.", MsgDialogType.error);
                }
            }
            CurrenPurchase.CalaculatePurchase(PurchaseItems);
            _ = await PurchaseRestService.UpdatePurchaseAsync(mapper, CurrenPurchase);
        }