예제 #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);
        }
예제 #2
0
        public static void move(bool devis)
        {
            new ClassFunctuon().showMessage(null, " please  waite....");

            var mw = ClassETC_fun.findWindow("MainWindow_");

            if (mw != null)
            {
                mw.IsEnabled = false;
            }
            worker = new System.ComponentModel.BackgroundWorker();

            if (devis)
            {
                worker.DoWork             += new System.ComponentModel.DoWorkEventHandler(worker_DoWorkDevis);
                worker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
            }
            else
            {
                worker.DoWork             += new System.ComponentModel.DoWorkEventHandler(worker_DoWorkFact);
                worker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
            }

            worker.RunWorkerAsync();
        }
예제 #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);
        }
예제 #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;
            }
        }
예제 #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 отсутвует или структура не правильная");
            }
        }
예제 #6
0
        public static void addProductCheck(ClassProducts.product p, decimal qty)
        {
            decimal procent     = ClassDiscounts.client.procent + ClassDiscounts.client.procent_default;
            decimal sumDiscount = Math.Truncate(p.price * qty * procent) / 100;
            decimal total       = (p.price * qty - sumDiscount);
            int     ii          = 0;

            openProductsCheck();
            if (b.Element("check").Elements("product").Count() > 0)
            {
                //    string val = b.Element("check").Elements("product").LastOrDefault().Element("ii").Value;
                ii = b.Element("check").Elements("product").Count();   //int.Parse(val) + 1;
            }
            XElement e = (
                new XElement("product",
                             new XElement("ii", ii),
                             new XElement("CustumerId", p.CustumerId),
                             new XElement("Name", p.Name),
                             new XElement("Desc", p.Desc),
                             new XElement("price", p.price),
                             new XElement("priceGros", p.priceGros),
                             new XElement("tva", p.tva),
                             new XElement("qty", qty),
                             new XElement("CodeBare", p.CodeBare),
                             new XElement("balance", p.balance),
                             new XElement("contenance", p.contenance),
                             new XElement("uniteContenance", p.uniteContenance),
                             new XElement("tare", p.tare),
                             new XElement("date", p.date ?? DateTime.Now),
                             new XElement("cusumerIdRealStock", p.cusumerIdRealStock),
                             new XElement("cusumerIdSubGroup", p.cusumerIdSubGroup),
                             new XElement("ProductsWeb_CustomerId", p.ProductsWeb_CustomerId),
                             new XElement("grp", p.grp),
                             new XElement("sgrp", p.sgrp),
                             new XElement("Discount", procent),
                             new XElement("sumDiscount", sumDiscount),
                             new XElement("total", Math.Truncate(total * 100) / 100)
                             )
                );

            b.Element("check").Add(e);

            ClassCustomerDisplay.writePrice(p.Name, qty, p.price);
            new ClassFunctuon().writeToatl();
            ClassETC_fun.wm_sound(@"Data\Beep.wav");

            b.Save(path_b);

            ClassCheck.c = null;

            if (worker.IsBusy)
            {
                //  worker.CancelAsync();

                worker.Dispose();

                worker = new System.ComponentModel.BackgroundWorker();
            }
            worker.DoWork             += new System.ComponentModel.DoWorkEventHandler(worker_DoWork_Total);
            worker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(worker_RunWorkerCompleted_Total);
            worker.RunWorkerAsync();
        }