public static void delProductCheck(string barcode) { int si = (ClassETC_fun.findWindow("MainWindow_") as MainWindow).dataGrid1.SelectedIndex; IEnumerable <XElement> elm = b.Element("check").Elements("product"). Where(l => l.Element("barcode").Value.Replace(" ", "") == barcode.Replace(" ", "")); if (elm.Count() > 0) { decimal d = decimal.Parse(elm.First().Element("qty").Value); if ((ClassProducts.listProducts.Find(l => l.CustumerId == Guid.Parse(elm.First().Element("id").Value)).balance) || (d == 0)) { elm.First().Remove(); } else { elm.First().Element("qty").Value = (d - 1).ToString(); } } else { ClassDiscounts.restoreDiscount(); } new ClassFunctuon().writeToatl(si); b.Save(path_b); }
public static void buf_addXElm(XElement x) { b = null; if (b == null) { b = new XDocument(); } b.Add(x); ClassDiscounts.restoreDiscount(); }
public static void delProductCheck(int id) { c = null; int si = (ClassETC_fun.findWindow("MainWindow_") as MainWindow).dataGrid1.SelectedIndex; IEnumerable <XElement> elms = b.Element("check").Elements("product"); XElement elm = elms. Where(l => int.Parse(l.Element("ii").Value) == id).FirstOrDefault(); if (elm != null) { elm.Remove(); } if (elms.Count() == 0) { ClassDiscounts.restoreDiscount(); } new ClassFunctuon().writeToatl(si); b.Save(path_b); }
public static void addSetDiscountCardBareCode(string barcode, int BiloP, int DobavileP, int OtnayliP, string name) { XAttribute a = b.Element("check").Attribute("DCBC"); XAttribute a1 = b.Element("check").Attribute("DCBC_BiloPoints"); XAttribute a2 = b.Element("check").Attribute("DCBC_DobavilePoints"); XAttribute a3 = b.Element("check").Attribute("DCBC_OtnayliPoints"); XAttribute a4 = b.Element("check").Attribute("DCBC_OstalosPoints"); XAttribute a5 = b.Element("check").Attribute("DCBC_name"); if (a == null) { b.Element("check").Add( new XAttribute("DCBC", barcode), new XAttribute("DCBC_BiloPoints", BiloP), new XAttribute("DCBC_DobavilePoints", DobavileP), new XAttribute("DCBC_OtnayliPoints", OtnayliP), new XAttribute("DCBC_OstalosPoints", BiloP + DobavileP - OtnayliP), new XAttribute("DCBC_name", name) ); } else { a.SetValue(barcode); a1.SetValue(BiloP); a2.SetValue(DobavileP); a3.SetValue(OtnayliP); a4.SetValue(BiloP + DobavileP - OtnayliP); a5.SetValue(name); } if (barcode != null) { tmpBarcode = barcode; tmp_Points = BiloP + DobavileP - OtnayliP; if (DobavileP > 0 || OtnayliP > 0) { ClassDiscounts.setDiscountPoint(tmpBarcode, tmp_Points, true); } } }
private static void worker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) { ClassSync.sync = false; new ClassPrintCheck(ClassCheck.b, false); ClassCheck.b = null; ClassCheck.openProductsCheck(); pro = null; ndevis = -1; nfact = -1; ClassProMode.check = null; ClassProMode.devis = false; ClassProMode.modePro = false; ClassDiscounts.restoreDiscount(); var de = ClassETC_fun.findWindow("_W_Message"); if (de != null) { de.Close(); } var mw = ClassETC_fun.findWindow("MainWindow_"); if (mw != null) { mw.IsEnabled = true; } }
public static void bay() { if (x.Element("checks") != null && b.Element("check").Elements("product").Count() > 0) { b = new ClassActionsCaisse().Descendants(b); try { foreach (ClassSync.TypesPayDB type in ClassSync.TypesPayDB.t) { decimal m = ClassBond.getMoneyFromType(type); b.Element("check").Add(new XAttribute(type.NameCourt.TrimEnd(), m)); } } catch (Exception ex) { string text = "KOD 001" + ex.Message; new ClassFunctuon().showMessageSB(text); new ClassLog(text + b.ToString()); } decimal rendu = ClassETC_fun.renduCalc(); try { b.Element("check").Add(new XAttribute("Rendu", rendu.ToString("0.00"))); } catch (Exception ex) { string text = "KOD 002" + ex.Message; new ClassFunctuon().showMessageSB(text); new ClassLog(text + b.ToString()); } try { b.Element("check").Add( new XAttribute("sum", ClassBond.getSumMoney()), new XAttribute("date", DateTime.Now) ); } catch (Exception ex) { string text = "KOD 003" + ex.Message; new ClassFunctuon().showMessageSB(text); new ClassLog(text + b.ToString()); } try { if (ClassDiscounts.client.barcode != null && !ClassProMode.modePro) { addSetDiscountCardBareCode( ClassDiscounts.client.barcode, ClassDiscounts.client.points - (ClassDiscounts.client.addPoints ? 1 : 0) + (ClassDiscounts.client.discountSet ? ClassDiscounts.client.maxPoints : 0), ClassDiscounts.client.addPoints ? 1 : 0, ClassDiscounts.client.discountSet ? 8 : 0, ClassDiscounts.client.nameFirst + " " + ClassDiscounts.client.nameLast ); } } catch (Exception ex) { string text = "KOD 004" + ex.Message; new ClassFunctuon().showMessageSB(text); new ClassLog(text + b.ToString()); } // try { // b.Element("check").Add(new XAttribute("barcodeCheck", getCodeBarCheck())); if (ClassProMode.modePro || ClassProMode.devis) { ClassProMode.move(ClassProMode.devis); } else { x.Element("checks").Add( b.Element("check") ); } } // catch (Exception ex) { // string text = "KOD 005" + ex.Message; // new ClassFunctuon().showMessageSB(text); // new ClassLog(text + b.ToString()); } // try { if (!ClassProMode.modePro && !ClassProMode.devis) { new ClassPrintCheck(b, false); } } // catch (Exception ex) { // string text = "KOD 006" + ex.Message; // new ClassFunctuon().showMessageSB(text); //new ClassLog(text + b.ToString()); } try { System.ComponentModel.BackgroundWorker worker = new System.ComponentModel.BackgroundWorker(); if (!ClassProMode.modePro && !ClassProMode.devis) { worker.DoWork += new System.ComponentModel.DoWorkEventHandler(worker_DoWork); worker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(worker_RunWorkerCompleted); worker.RunWorkerAsync(); } } catch (Exception ex) { string text = "KOD 007" + ex.Message; // new ClassFunctuon().showMessageSB(text); new ClassLog(text + b.ToString()); } try { if (!ClassProMode.modePro && !ClassProMode.devis) { x.Save(path); b = null; openProductsCheck(); ClassDiscounts.restoreDiscount(); } } catch (Exception ex) { string text = "KOD 008" + ex.Message; new ClassFunctuon().showMessageSB(text); new ClassLog(text + b.ToString()); } } else { new ClassFunctuon().showMessageSB("файл check.xml отсутвует или структура не правильная"); } }