Exemplo n.º 1
0
        public bool ChangeQuantity(IdReceiptWares pReceiptWaresId, decimal pQuantity)
        {
            bool isZeroPrice = false;
            var  res         = false;
            var  W           = db.FindWares(null, null, pReceiptWaresId.CodeWares, pReceiptWaresId.CodeUnit);

            if (W.Count() == 1)
            {
                var w = W.First();
                w.SetIdReceipt(pReceiptWaresId);
                if (pQuantity == 0)
                {
                    db.DeleteReceiptWares(w);
                    _ = VR.SendMessageAsync(w.IdWorkplace, w.NameWares, w.Articl, w.Quantity, w.Sum, VR.eTypeVRMessage.DeleteWares);
                }
                else
                {
                    //w.SetIdReceiptWares();
                    w.Quantity = pQuantity;
                    w.Sort     = -1;
                    if (w.AmountSalesBan > 0 && w.Quantity > w.AmountSalesBan && (w.CodeUnit != Global.WeightCodeUnit && w.CodeUnit != Global.WeightCodeUnit))
                    {
                        w.Quantity = w.AmountSalesBan;
                        if (Global.IsOldInterface)
                        {
                            isZeroPrice = true;
                        }
                        else
                        {
                            Global.OnClientWindows?.Invoke(w.IdWorkplace, eTypeWindows.LimitSales, $"Даний товар {w.NameWares} {Environment.NewLine} має обмеження в кількості {w.AmountSalesBan} шт");
                        }
                    }
                    res = db.UpdateQuantityWares(w);
                    _   = VR.SendMessageAsync(w.IdWorkplace, w.NameWares, w.Articl, w.Quantity, w.Sum, VR.eTypeVRMessage.UpdateWares);
                }
                if (Global.RecalcPriceOnLine)
                {
                    db.RecalcPriceAsync(pReceiptWaresId);
                }
            }
            return(res);
        }