Esempio n. 1
0
        public void CheckOut(FinishedProducts finishedProducts)
        {
            var prod = FinishedProducts.FindById(finishedProducts.Id);

            prod.PriceOut = finishedProducts.PriceOut;
            FinishedProducts.Update(prod);
            FinishedGoodsStatistics eF = new FinishedGoodsStatistics();

            eF.Count           = finishedProducts.Count;
            eF.Date            = DateTime.Now;
            eF.FinishGildArray = prod.FinishGildArray;
            eF.PriceIn         = prod.PriceIn;
            eF.PriceOut        = prod.PriceOut;
            FinishedGoodsStatistics.Create(eF);
            var fn = FinishedGoodsStatistics.Get(x => x.Count == eF.Count && x.Date.Value.Day == eF.Date.Value.Day && x.Date.Value.Month == eF.Date.Value.Month && x.Date.Value.Year == eF.Date.Value.Year && x.PriceIn == eF.PriceIn && x.PriceOut == eF.PriceOut && x.Date.Value.Hour == eF.Date.Value.Hour && x.Date.Value.Minute == eF.Date.Value.Minute && x.Date.Value.Second == eF.Date.Value.Second).First();

            FinishedProducts_FinishedGoodsStatistics.Create(new db.FinishedProducts_FinishedGoodsStatistics()
            {
                FinishedProductsId = prod.Id, FinishedGoodsStatisticsId = fn.Id
            });
        }
Esempio n. 2
0
        public void InFinishedProduct(FinishedProducts finishedProducts)
        {
            List <int> CountSpec = new List <int>();
            List <int> CountProd = new List <int>();

            Gild = new EFRepository <Gild>(new ApplicationDbContext());
            var prod = FinishedProducts.FindById(finishedProducts.Id);

            prod.Count += finishedProducts.Count;
            var pack = Packaging.FindById(prod.PackagingId.Value);

            pack.Count -= finishedProducts.Count;
            if (pack.Count < 0)
            {
                return;
            }
            foreach (var item in prod.FinishGildArray)
            {
                var gild = Gild.FindById(item.GildId.Value);
                if (gild.ProductId != null)
                {
                    CountProd.Add(int.Parse(item.CountSyr.ToString()));
                    gild.Count -= int.Parse(item.CountSyr.ToString());

                    Task.Factory.StartNew(() =>
                    {
                        Gild.Update(gild);
                    }).Wait();
                }
                else
                {
                    gild.Count -= int.Parse(item.CountSpec.ToString());
                    CountSpec.Add(int.Parse(item.CountSpec.ToString()));
                    Task.Factory.StartNew(() =>
                    {
                        Gild.Update(gild);
                    }).Wait();
                }
            }

            Task.Factory.StartNew(() =>
            {
                Packaging.Update(pack);
            }).Wait();
            Task.Factory.StartNew(() =>
            {
                FinishedProducts.Update(prod);
            }).Wait();
            FinishedGoodsStatistics eF = new FinishedGoodsStatistics()
            {
                Count = finishedProducts.Count, Date = DateTime.Now, FinishGildArray = finishedProducts.FinishGildArray, PriceIn = prod.PriceIn, PriceOut = prod.PriceOut, CountPack = finishedProducts.Count
            };

            Task.Factory.StartNew(() =>
            {
                FinishedGoodsStatistics.Create(eF);
            }).Wait();
            var b = FinishedGoodsStatistics.Get(x => x.Count == eF.Count && x.Date.Value.Day == eF.Date.Value.Day && x.Date.Value.Month == eF.Date.Value.Month && x.Date.Value.Year == eF.Date.Value.Year && x.PriceIn == eF.PriceIn && x.PriceOut == eF.PriceOut && x.Date.Value.Hour == eF.Date.Value.Hour && x.Date.Value.Minute == eF.Date.Value.Minute && x.Date.Value.Second == eF.Date.Value.Second).First().Id;

            Task.Factory.StartNew(() =>
            {
                FinishedProducts_FinishedGoodsStatistics.Create(new db.FinishedProducts_FinishedGoodsStatistics()
                {
                    FinishedProductsId = prod.Id, FinishedGoodsStatisticsId = b
                });
            }).Wait();
        }