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 XmlToDbSaveD(XDocument x) { var infoClientsCustomerId = ModePro ? Pro.CustomerId : new Guid("87da7ba2-5e52-4d31-8def-5a2dad508e94"); var di = new DevisIdType(-1, DateTime.Now, false, infoClientsCustomerId, 0); var products = x.GetXElements("check", "product"); var p = new List <XElement>(); foreach (var product in products) { var pf = p.Find(l => (l.GetXElementValue("CustomerId") == product.GetXElementValue("CustomerId"))); if (pf == null || (pf.GetXElementValue("price") != product.GetXElementValue("price"))) { p.Add(product); } else { var qty = pf.GetXElementValue("qty").ToDecimal(); var qty1 = product.GetXElementValue("qty").ToDecimal(); var total = pf.GetXElementValue("total").ToDecimal(); var total1 = product.GetXElementValue("total").ToDecimal(); pf.GetXElement("qty").SetValue(qty + qty1); pf.GetXElement("total").SetValue(total + total1); } } x.GetXElements("check", "product").Remove(); di.DivisWebs = new List <DevisWebType>(); foreach (var product in p) { x.GetXElement("check").Add(product); var prixHt = Math.Round(product.GetXElementValue("price").ToDecimal(), 2); var tva = RepositoryTva.GetById(product.GetXElementValue("tva").ToInt()); var tva1 = PrixTtcOnlyTva(product.GetXElementValue("price").ToDecimal(), tva); var monPrixHt = product.GetXElementValue("contenance").ToDecimal(); var qty = product.GetXElementValue("qty").ToDecimal(); var prixHtValue = prixHt - tva1; var dw = new DevisWebType(Guid.NewGuid(), -1, prixHtValue, monPrixHt == 0 ? 1 : monPrixHt, qty, qty * prixHtValue, 0, true, product.GetXElementValue("CustomerId").ToGuid(), di.InfoClientsCustomerId ?? Guid.Empty); var cusumerIdRealStock = Guid.Parse(product.GetXElementValue("cusumerIdRealStock").Replace('.', ',')); RepositoryStockReal.AddProductCount(-dw.Qty, cusumerIdRealStock); RepositoryStockReal.UpdateProductCountByEstablishment(dw.Qty, Config.IdEstablishmentGros, dw.ProductsCustomerId); di.DivisWebs.Add(dw); } di.Total = di.DivisWebs.Sum(l => l.TotalHt); SyncService.InsDevis(di); FileMove(); }
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; }
public static void MegaSync() { // check tables var syncTask = Task <bool> .Factory.StartNew( () => { RepositoryActionHashBox.Sync(); //RepositoryCheck RepositoryCheckTicket.Sync(); RepositoryCheckTicketTmp.Sync(); RepositoryPro.Sync(); RepositoryClientInfo.Sync(); RepositoryCloseTicket.Sync(); RepositoryCloseTicketCheckDiscount.Sync(); RepositoryCloseTicketG.Sync(); RepositoryCloseTicketTmp.Sync(); RepositoryCountry.Sync(); RepositoryCurrency.Sync(); //RepositoryCurrencyRelations RepositoryDevisId.Sync(); RepositoryDevisWeb.Sync(); //RepositoryDiscount RepositoryDiscountCard.Sync(); RepositoryEstablishment.Sync(); RepositoryGeneral.Sync(); RepositoryGroupProduct.Sync(); //RepositoryHistoryChangeProduct RepositoryInfoClientsDiscountsType.Sync(); RepositoryLastUpdate.Sync(); RepositoryOpenTicketWindow.Sync(); RepositoryPayProduct.Sync(); RepositoryPayProductTmp.Sync(); //RepositoryPriceGros RepositoryProduct.Sync(); RepositoryProductBc.Sync(); RepositoryStatNation.Sync(); RepositoryStatNationPopup.Sync(); RepositoryStatPlaceArrond.Sync(); //RepositoryStockLogs RepositoryStockReal.Sync(); RepositorySyncPlus.Sync(); RepositorySyncPlusProduct.Sync(); //RepositoryTes RepositoryTva.Sync(); RepositoryTypePay.Sync(); //RepositoryXmlFile return(true); }); syncTask.ContinueWith( s => { }); }
private void WorkerAddDoWork(object sender, DoWorkEventArgs e) { var product = (ProductType)e.Argument; RepositoryProduct.Add(product); if (RepositoryAccountUser.LoginedUser.Role.IsPermiss(Privelege.RedactStockCount)) { var stockReal = RepositoryStockReal.GetByProduct(product); RepositoryStockReal.AddAsNull(product.CustomerId, Config.IdEstablishment); RepositoryStockReal.UpdateProductCount(_stockRealCount, stockReal.CustomerId); } }
private void WorkerEditDoWork(object sender, DoWorkEventArgs e) { var product = (ProductType)e.Argument; RepositoryProduct.Update(product); RepositoryProduct.UpdateProductPrice(product); if (RepositoryAccountUser.LoginedUser.Role.IsPermiss(Privelege.RedactStockCount)) { var stockReal = RepositoryStockReal.GetByProduct(product); RepositoryStockReal.UpdateProductCount(_stockRealCount, stockReal.CustomerId); } }
public static void RemoveProductCountFromStockReal(CloseTicketTmp closeTicket) { foreach (var checkTicket in closeTicket.ChecksTicket) { foreach (var product in checkTicket.PayProducts) { var productFromStock = RepositoryProduct.Products.FirstOrDefault(p => p.CustomerId == product.ProductId); if (productFromStock != null) { RepositoryStockReal.AddProductCount(-product.Qty, productFromStock.CusumerIdRealStock); } else { var message = " нет записи об данном продукте в таблице СТОК, Детали: IDcustomer " + product.ProductId + " - Название продукта " + product.Name + " - Количество " + product.Qty + " Штрих код : " + product.Barcode; LogService.LogText(TraceLevel.Error, message); } } } }
private void BtnAddStock_OnClick(object sender, RoutedEventArgs e) { const int minQty = 10; if (_stocks.Count > 0) { foreach (var productBc in _stocks) { if (productBc.Product != null) { var minQtyOfProduct = productBc.Qty > minQty ? productBc.Qty : minQty; RepositoryStockReal.AddOrUpdateCounts(productBc.Product.CustomerId, Config.IdEstablishment, productBc.Qty, minQtyOfProduct, productBc.Product.Price); } } _stocks.Clear(); FunctionsService.ShowMessageTime(Properties.Resources.LabelOperationComplete); } }
public static void XmlToDbSave(XDocument x) { var tes = new Tes { CustomerId = Guid.NewGuid(), ACodeFournisseur = 0, AFrtva = Pro.Frtva ?? string.Empty, AMail = Pro.Mail, AName = Pro.Name ?? string.Empty, ASex = Pro.SexToInt(Pro.Sex), ASurname = Pro.Surname ?? string.Empty, ANameCompany = Pro.NameCompany, AOfficeAddress = Pro.OfficeAddress ?? string.Empty, AOfficeCity = Pro.OfficeCity ?? string.Empty, AOfficeZipCode = Pro.OfficeZipCode ?? string.Empty, ASiret = Pro.Siret ?? string.Empty, ATelephone = Pro.Telephone }; tes.CustomerId = Guid.NewGuid(); tes.DateTime = DateTime.Now; tes.Description = string.Empty; tes.Id = RepositoryTes.MaxId(0) + 1; tes.Livraison = false; tes.Montant = x.GetXAttributeValue("check", "sum").ToDecimal(); tes.Nclient = Pro.Nclient.ToString(); tes.Payement = false; tes.Type = 0; tes.VAdresse = RepositoryEstablishment.Establishment.Adress; tes.VCodeNaf = "0"; tes.VCp = RepositoryEstablishment.Establishment.Cp; tes.VFax = RepositoryEstablishment.Establishment.Phone; tes.VFrtva = ""; tes.VMail = RepositoryEstablishment.Establishment.Mail; tes.VNameCompany = RepositoryEstablishment.Establishment.Name; tes.VPhone = RepositoryEstablishment.Establishment.Phone; tes.VSiret = ""; tes.VVille = RepositoryEstablishment.Establishment.Ville; var products = x.GetXElements("check", "product"); var p = new List <XElement>(); foreach (var product in products) { var pf = p.Find(l => l.GetXElementValue("CustomerId") == product.GetXElementValue("CustomerId")); if (pf == null || (pf.GetXElementValue("price") != product.GetXElementValue("price"))) { p.Add(product); } else { var qty = pf.GetXElementValue("qty").ToDecimal(); var qty1 = product.GetXElementValue("qty").ToDecimal(); var total = pf.GetXElementValue("total").ToDecimal(); var total1 = product.GetXElementValue("total").ToDecimal(); pf.GetXElement("qty").SetValue(qty + qty1); pf.GetXElement("total").SetValue(total + total1); } } x.GetXElements("check", "product").Remove(); foreach (var product in p) { x.GetXElement("check").Add(product); var prod = new TesProduct { Balance = product.GetXElementValue("balance").ToBool(), CodeBar = ReplaceCodeBare(product.GetXElementValue("CodeBare")), ConditionAchat = 1, CustomerId = -1, CustomerIdProduct = product.GetXElementValue("CustomerId").ToGuid(), Date = DateTime.Now, Description = Config.Name, Group = RepositoryGroupProduct.GetGroupNameById(product.GetXElementValue("grp").ToInt()), NameProduct = product.GetXElementValue("Name"), PrixHt = Math.Round(product.GetXElementValue("price").ToDecimal(), 2), ProductsWeb = product.GetXElementValue("ProductsWeb_CustomerId").ToGuid(), Qty = product.GetXElementValue("qty").Replace('.', ',').ToDecimal(), SubGroup = RepositoryGroupProduct.GetGroupNameById(product.GetXElementValue("grp").ToInt()), TesCustomerId = tes.CustomerId, Tva = RepositoryTva.GetById(product.GetXElementValue("tva").ToInt()) }; var tva = PrixTtcOnlyTva(product.GetXElementValue("price").ToDecimal(), prod.Tva); prod.PrixHt = prod.PrixHt - tva; prod.TotalHt = prod.Qty * prod.PrixHt; prod.TypeId = 1; tes.TesProducts.Add(prod); var qty = prod.Qty; var cusumerIdRealStock = product.GetXElementValue("cusumerIdRealStock").ToGuid(); RepositoryStockReal.AddProductCount(-qty, cusumerIdRealStock); } foreach (var type in RepositoryTypePay.TypePays) { var reglement = new TesReglament(); var r = RepositoryTypePay.TypePays.FirstOrDefault(l => l.NameCourt == type.NameCourt); var elm = x.GetXAttribute("check", type.NameCourt); if (elm != null && r != null) { reglement.Caisse = Config.NameTicket; reglement.CustomerId = Guid.NewGuid(); reglement.DateTime = DateTime.Now; if (r.Name == "En espèces") { var rendux = x.GetXAttribute("check", "Rendu"); if (rendux != null) { var rendu = rendux.Value.ToDecimal(); reglement.Montant = elm.Value.ToDecimal() + rendu; } else { reglement.Montant = elm.Value.ToDecimal(); } } else { reglement.Montant = elm.Value.ToDecimal(); } reglement.TesCustomerId = tes.CustomerId; reglement.TypePay = r.Name; tes.TesReglaments.Add(reglement); } tes.Payement = (tes.TesReglaments.Sum(l => l.Montant) >= tes.Montant); } if (tes.TesReglaments.Count > 0) { var newTes = new Tes { CustomerId = Guid.NewGuid(), ACodeFournisseur = (short)(Pro.Nclient), AFrtva = Pro.Frtva ?? string.Empty, AMail = Pro.Mail, AName = Pro.Name ?? string.Empty, ASex = Pro.SexToInt(Pro.Sex), ASurname = Pro.Surname ?? string.Empty, ANameCompany = Pro.NameCompany, AOfficeAddress = Pro.OfficeAddress ?? string.Empty, AOfficeCity = Pro.OfficeCity ?? string.Empty, AOfficeZipCode = Pro.OfficeZipCode ?? string.Empty, ASiret = Pro.Siret ?? string.Empty, ATelephone = Pro.Telephone, DateTime = DateTime.Now, Description = "{" + tes.CustomerId + "}{" + tes.Id + "}{" + tes.Type + "}", Id = RepositoryTes.MaxId(1) + 1, Livraison = tes.Livraison, Montant = decimal.Parse(x.Element("check").Attribute("sum").Value.Replace('.', ',')), Nclient = Pro.Nclient.ToString(), Payement = tes.Payement, Type = 1, VAdresse = tes.VAdresse, VCodeNaf = tes.VCodeNaf, VCp = tes.VCp, VFax = tes.VFax, VFrtva = tes.VFrtva, VMail = tes.VMail, VNameCompany = tes.VNameCompany, VPhone = tes.VPhone, VSiret = tes.VSiret, VVille = tes.VVille }; tes.Description = "{" + newTes.CustomerId + "}{" + newTes.Id + "}{" + newTes.Type + "}"; foreach (var t in tes.TesReglaments) { if (t.Montant > 0) { t.TesCustomerId = newTes.CustomerId; newTes.TesReglaments.Add(t); } } tes.TesReglaments.Clear(); RepositoryTes.AddToDb(newTes); } RepositoryTes.AddToDb(tes); Nfact = tes.Id ?? -1; FileMove(); }