Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public static void buf_addXElm(XElement x)
 {
     b = null;
     if (b == null)
     {
         b = new XDocument();
     }
     b.Add(x);
     ClassDiscounts.restoreDiscount();
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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;
            }
        }
Exemplo n.º 5
0
        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 отсутвует или структура не правильная");
            }
        }