public static void AddProductCheck(XElement element, decimal qty) { CassieService.OpenProductsCheck(); if (ClassProMode.ModePro) { element = ClassProMode.Replace(new[] { element }).First(); } var product = ProductType.FromXElement(element); product = RepositoryProduct.Products.FirstOrDefault(p => p.CustomerId == product.CustomerId); if (product.Balance) { if (GetBallance(product) == null) { var button = new Button { ToolTip = "ShowBallance" }; FunctionsService.Click(button, product); } else { AddProductCheck(product, product.Qty); } } else { AddProductCheck(product, qty); } }
public static bool GetCheckFromChecksAndDelete(string bc) { var element = RepositoryCheck.Document.GetXElements("checks", "check") .FirstOrDefault(c => c.GetXAttributeValue("barcodeCheck").Trim() == bc.Trim()); if (element != null) { CassieService.OpenProductsCheck(); foreach (var e in element.Elements("product")) { RepositoryCheck.DocumentProductCheck.GetXElement("check").Add(e); var qty = e.GetXElementValue("qty").ToDecimal(); var customerId = e.GetXElementValue("cusumerIdRealStock").ToGuid(); RepositoryStockReal.AddProductCount(qty, customerId); } element.Remove(); RepositoryCheck.Document.Save(RepositoryCheck.Path); return(true); } return(false); }
public static void AddProductCheck(ProductType product, decimal qty) { product.Discount = RepositoryDiscount.Client.Procent + RepositoryDiscount.Client.ProcentDefault; product.SumDiscount = Math.Truncate(product.Price * qty * product.Discount) / 100; product.Qty = qty; product.Total = Math.Truncate((product.Price * product.Qty - product.SumDiscount) * 100) / 100; CassieService.OpenProductsCheck(); var productElements = RepositoryCheck.DocumentProductCheck.GetXElements("check", "product"); var newProductXElement = ProductType.ToCheckXElement(product, productElements?.ToList() ?? new List <XElement>()); RepositoryCheck.DocumentProductCheck.GetXElement("check").Add(newProductXElement); ClassCustomerDisplay.WritePrice(product.Name, qty, product.Price); FunctionsService.WriteTotal(); ClassEtcFun.WmSound(@"Data\Beep.wav"); RepositoryCheck.DocumentProductCheck.Save(RepositoryCheck.PathProductCheck); }
public static void EnAttenete() { RepositorySyncPlusProduct.SetCheck(RepositoryCheck.DocumentProductCheck); RepositoryCheck.DocumentProductCheck = null; CassieService.OpenProductsCheck(); }
public static void Bay() { RepositoryCheck.GetDucument(); if (RepositoryCheck.Document.Element("checks") != null && RepositoryCheck.DocumentProductCheck.GetXElements("check", "product").Any()) { RepositoryCheck.DocumentProductCheck = RepositoryActionHashBox.MergeProductsInCheck(RepositoryCheck.DocumentProductCheck); try { foreach (var type in RepositoryTypePay.TypePays) { var money = RepositoryCurrencyRelations.GetMoneyFromType(type); RepositoryCheck.DocumentProductCheck.GetXElement("check").Add(new XAttribute(type.NameCourt.TrimEnd(), money)); } } catch (System.Exception ex) { var text = ex.Message; FunctionsService.ShowMessageSb(text); LogService.Log(TraceLevel.Error, 1, text + RepositoryCheck.DocumentProductCheck); } var rendu = ClassEtcFun.RenduCalc(); try { RepositoryCheck.DocumentProductCheck.GetXElement("check").Add(new XAttribute("Rendu", rendu.ToString("0.00"))); } catch (System.Exception ex) { var text = ex.Message; FunctionsService.ShowMessageSb(text); LogService.Log(TraceLevel.Error, 2, text + RepositoryCheck.DocumentProductCheck + "."); } try { RepositoryCheck.DocumentProductCheck.GetXElement("check").Add( new XAttribute("sum", RepositoryCurrencyRelations.GetSumMoney()), new XAttribute("date", DateTime.Now)); } catch (System.Exception ex) { var text = ex.Message; FunctionsService.ShowMessageSb(text); LogService.Log(TraceLevel.Error, 3, text + RepositoryCheck.DocumentProductCheck + "."); } try { if (RepositoryDiscount.Client.Barcode != null && !ClassProMode.ModePro) { AddSetDiscountCardBareCode( RepositoryDiscount.Client.Barcode, RepositoryDiscount.Client.Points - (RepositoryDiscount.Client.AddPoints ? 1 : 0) + (RepositoryDiscount.Client.DiscountSet ? RepositoryDiscount.Client.MaxPoints : 0), RepositoryDiscount.Client.AddPoints ? 1 : 0, RepositoryDiscount.Client.DiscountSet ? 8 : 0, RepositoryDiscount.Client.NameFirst + " " + RepositoryDiscount.Client.NameLast); } } catch (System.Exception ex) { var text = ex.Message; FunctionsService.ShowMessageSb(text); LogService.Log(TraceLevel.Error, 4, text + RepositoryCheck.DocumentProductCheck + "."); } if (ClassProMode.ModePro || ClassProMode.Devis) { ClassProMode.Move(ClassProMode.Devis); } else { var element = RepositoryCheck.DocumentProductCheck.Element("check"); element.GetXAttribute("barcodeCheck").SetValue(RepositoryCheck.GetBarCodeCheck()); RepositoryCheck.Document.GetXElement("checks").Add(element); } if (!ClassProMode.ModePro && !ClassProMode.Devis) { new ClassPrintCheck(RepositoryCheck.DocumentProductCheck, false); } try { var worker = new BackgroundWorker(); if (!ClassProMode.ModePro && !ClassProMode.Devis) { worker.DoWork += WorkerDoWork; worker.RunWorkerCompleted += WorkerRunWorkerCompleted; worker.RunWorkerAsync(); } } catch (System.Exception ex) { var text = ex.Message; LogService.Log(TraceLevel.Error, 7, text + RepositoryCheck.DocumentProductCheck + "."); } try { if (!ClassProMode.ModePro && !ClassProMode.Devis) { RepositoryCheck.Document.Save(RepositoryCheck.Path); RepositoryCheck.DocumentProductCheck = null; CassieService.OpenProductsCheck(); RepositoryDiscount.RestoreDiscount(); DiscountCalc(); FunctionsService.WriteTotal(); } } catch (System.Exception ex) { var text = ex.Message; FunctionsService.ShowMessageSb(text); LogService.Log(TraceLevel.Error, 8, text + RepositoryCheck.DocumentProductCheck + "."); } } else { FunctionsService.ShowMessageSb("файл check.xml отсутвует или структура не правильная"); } }