Exemple #1
0
        public ReceiptWares AddReceiptWares(ReceiptWares pW, bool pRecalcPriceOnLine = true)
        {
            bool isZeroPrice = false;

            lock (db.GetObjectForLockByIdWorkplace(pW.IdWorkplace))
            {
                var Quantity = db.GetCountWares(pW);
                pW.QuantityOld = Quantity;
                pW.Quantity   += Quantity;

                if (pW.AmountSalesBan > 0 && pW.Quantity > pW.AmountSalesBan && pW.CodeUnit != Global.WeightCodeUnit && pW.CodeUnit != Global.WeightCodeUnit)
                {
                    pW.Quantity = pW.AmountSalesBan;
                    if (Global.IsOldInterface)
                    {
                        isZeroPrice = true;
                        return(null);
                    }
                    else
                    {
                        Global.OnClientWindows?.Invoke(pW.IdWorkplace, eTypeWindows.LimitSales, $"Даний товар {pW.NameWares} {Environment.NewLine} має обмеження в кількості {pW.AmountSalesBan} шт");
                    }
                }
                if (Quantity > 0)
                {
                    db.UpdateQuantityWares(pW);
                }
                else
                {
                    db.AddWares(pW);
                }
            }

            //Кешконтроль
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            // Get the elapsed time as a TimeSpan value.

            _ = VR.SendMessageAsync(pW.IdWorkplace, pW.NameWares, pW.Articl, pW.Quantity, pW.Sum);
            stopWatch.Stop();
            TimeSpan ts = stopWatch.Elapsed;

            Console.WriteLine("\nVR=>" + ts.TotalMilliseconds + "\n");

            if (pRecalcPriceOnLine && Global.RecalcPriceOnLine)
            {
                db.RecalcPriceAsync(pW);
            }

            /*if (pW.PLU > 0)
            *    GenQRAsync(pW);*/
            if (isZeroPrice)
            {
                pW.Price       = 0;
                pW.PriceDealer = 0;
            }
            return(pW);
        }