Example #1
0
        public static void DelProductCheck(string barcode)
        {
            var selectedIndex   = ((MainWindow)ClassEtcFun.FindWindow("MainWindow_")).GridProducts.SelectedIndex;
            var productElements = RepositoryCheck.DocumentProductCheck.GetXElements("check", "product").Where(p => p.GetXElementValue("CodeBare").Trim() == barcode.Trim()).ToList();

            if (productElements.Count > 0)
            {
                var firstQty = productElements.First().GetXElementValue("qty").ToDecimal();

                if (RepositoryProduct.Products.Find(l => l.CustomerId == productElements.First().GetXElementValue("id").ToGuid()).Balance || (firstQty == 0))
                {
                    productElements.First().Remove();
                }
                else
                {
                    productElements.First().GetXElement("qty").Value = (firstQty - 1).ToString();
                }
            }
            else
            {
                RepositoryDiscount.RestoreDiscount();
                DiscountCalc();
                FunctionsService.WriteTotal();
            }
            FunctionsService.WriteToatl(selectedIndex);
            RepositoryCheck.DocumentProductCheck.Save(RepositoryCheck.PathProductCheck);
        }
Example #2
0
        public static void DelProductCheck(int id)
        {
            RepositoryCheck.C = null;
            var selectedIndex   = ((MainWindow)ClassEtcFun.FindWindow("MainWindow_")).GridProducts.SelectedIndex;
            var productElements = RepositoryCheck.DocumentProductCheck.GetXElements("check", "product").ToList();

            if (productElements.Count == 0)
            {
                RepositoryDiscount.RestoreDiscount();
                DiscountCalc();
                FunctionsService.WriteTotal();
            }
            else
            {
                var curElement = productElements.FirstOrDefault(l => l.GetXElementValue("ii").ToInt() == id);
                curElement?.Remove();
            }
            FunctionsService.WriteToatl(selectedIndex);
            RepositoryCheck.DocumentProductCheck.Save(RepositoryCheck.PathProductCheck);
        }