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); }
public static void Move(bool devis) { FunctionsService.ShowMessage(null, " please waite...."); var mw = ClassEtcFun.FindWindow("MainWindow_"); if (mw != null) { mw.IsEnabled = false; } _worker = new BackgroundWorker(); if (devis) { _worker.DoWork += WorkerDoWorkDevis; _worker.RunWorkerCompleted += WorkerRunWorkerCompleted; } else { _worker.DoWork += WorkerDoWorkFact; _worker.RunWorkerCompleted += WorkerRunWorkerCompleted; } _worker.RunWorkerAsync(); }
private static void WorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { SyncData.SetSunc(false); new ClassPrintCheck(RepositoryCheck.DocumentProductCheck, false); RepositoryCheck.DocumentProductCheck = null; CassieService.OpenProductsCheck(); Pro = null; Ndevis = -1; Nfact = -1; Check = null; Devis = false; ModePro = false; RepositoryDiscount.RestoreDiscount(); CheckService.DiscountCalc(); FunctionsService.WriteTotal(); var de = ClassEtcFun.FindWindow("_W_Message"); if (de != null) { de.Close(); } var mw = ClassEtcFun.FindWindow("MainWindow_"); if (mw != null) { mw.IsEnabled = true; } }
public WAddProduct(ProductType product = null) { var windowProducts = ClassEtcFun.FindWindow("NameWGridProduct"); if (windowProducts == null) { windowProducts = new WGridProduct(); windowProducts.Show(); } InitializeComponent(); TvaBox.ItemsSource = RepositoryTva.Tvases; GroupBox.ItemsSource = RepositoryGroupProduct.GroupProducts; if (product != null) { Save.Content = Properties.Resources.BtnUpdate; Product = product; xName.Text = product.Name; xCodeBar.Text = product.CodeBare; xPrice.Text = $"{product.Price}"; TvaBox.SelectedItem = product.Tva; xBalance.IsChecked = product.Balance; var group = RepositoryGroupProduct.GroupProducts.FirstOrDefault(g => g.Id == product.SubGrpProduct.Group.Id); GroupBox.SelectedItem = group; if (group != null) { SubgroupBox.ItemsSource = group.SubGroups; SubgroupBox.SelectedItem = group.SubGroups.FirstOrDefault(s => s.Id == product.SubGrpProduct.Id); } } if (!RepositoryAccountUser.LoginedUser.Role.IsPermiss(Privelege.RedactStockCount)) { lStockCount.Visibility = Visibility.Collapsed; xStockCount.Visibility = Visibility.Collapsed; } else if (product != null) { var stockReal = RepositoryStockReal.GetByProduct(product); xStockCount.Text = $"{stockReal.Qty}"; } BoxErrorText.Text = string.Empty; _workerAdd.RunWorkerCompleted += WorkerCompleted; _workerEdit.RunWorkerCompleted += WorkerCompleted; _workerAdd.DoWork += WorkerAddDoWork; _workerEdit.DoWork += WorkerEditDoWork; }
private void ButtonClick(object sender, RoutedEventArgs e) { if (Product.Price == 0.0m) { var window = ClassEtcFun.FindWindow("MainWindow_") as MainWindow; if (window != null) { var dataGrid = window.GridProducts; var selected = (XElement)dataGrid.SelectedItem; if (selected != null) { CheckService.DelProductCheck(selected.GetXElementValue("ii").ToInt()); } } } Close(); }
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); }