Exemplo n.º 1
0
        private static ClassProducts.product getBallance(ClassProducts.product p)
        {
            Class.ClassBallance.send(p.price, p.tare);



            decimal prix = 0.0m;
            decimal qty  = 0.0m;

            try
            {
                prix = decimal.Parse(Class.ClassBallance.prix) / 100;
                qty  = decimal.Parse(Class.ClassBallance.poinds) / 1000;
            }
            catch (Exception e)
            {
                new Class.ClassLog("Code 021 Error ballance =" + ClassBallance.error + e.Message);
                p = null;
            }

            if (qty > 0)
            {
                p.contenance = qty;
                p.qty        = qty;
                p.price      = prix;
            }

            if ((ClassBallance._busy_0x15) || (ClassBallance._error_0x15))
            {
                p = null;
            }

            return(p);
        }
Exemplo n.º 2
0
        public static void addProductCheck(XElement elm, decimal qty)
        {
            openProductsCheck();

            if (ClassProMode.modePro)
            {
                elm = ClassProMode.replace(new XElement[] { elm }).First();
            }

            ClassProducts.product p = ClassProducts.transform(elm);

            if (p.balance)
            {
                ClassProducts.product tmp = getBallance(p);

                if (tmp == null)
                {
                    Button b = new Button();
                    b.ToolTip = "ShowBallance";
                    new ClassFunctuon().Click(b, p);
                }
                else
                {
                    addProductCheck(p, p.qty);
                }
            }
            else
            {
                addProductCheck(p, qty);
            }
        }
Exemplo n.º 3
0
        private static XElement XelementCopy(XElement xe)
        {
            XDocument x = new XDocument();

            x.Add(new XElement("rec"));

            ClassProducts.product p = ClassProducts.transform(xe);

            x.Element("rec").Add(
                new XElement("ii", p.ii),
                new XElement("CustumerId", p.CustumerId),
                new XElement("Name", p.Name.ToUpper()),
                new XElement("Desc", p.Desc),
                new XElement("price", p.price),
                new XElement("priceGros", p.priceGros),
                new XElement("tva", p.tva),
                new XElement("qty", p.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)
                );

            return(x.Element("rec"));
        }
Exemplo n.º 4
0
        public static void discountCalc()
        {
            if (b != null)
            {
                IEnumerable <XElement> elms = ClassCheck.b.Element("check").Elements("product");

                foreach (var e in elms)
                {
                    ClassProducts.product p = ClassProducts.transform(e);
                    ClassCheck.modifProductCheck_(p.ii, p.price, p.Name, p.qty);
                }
                ClassCheck.getTotalPrice();
            }
        }
Exemplo n.º 5
0
        /*   public static XDocument DbToXelemet(ClassSync.ClassCloseTicketTmp.ChecksTicket check)
         * {
         *
         *     XDocument doc;
         *
         *     doc = new XDocument(
         *         new XElement("check",
         *             new XAttribute("barcodeCheck", check.BarCode))
         *             )
         *             ;
         *     foreach (ClassSync.TypesPayDB type in ClassSync.TypesPayDB.t)
         *     {
         *
         *         decimal m = 0.0m;
         *
         *         switch (type.NameCourt)
         *         {
         *             case "BankChecks": m = check.PayBankChecks; break;
         *             case "BankCards": m = check.PayBankCards; break;
         *             case "Cash": m = check.PayCash; break;
         *             case "Resto": m = check.PayResto; break;
         *             case "1": m = check.Pay1; break;
         *             case "2": m = check.Pay2; break;
         *             case "3": m = check.Pay3; break;
         *             case "4": m = check.Pay4; break;
         *             case "5": m = check.Pay5; break;
         *             case "6": m = check.Pay6; break;
         *             case "7": m = check.Pay7; break;
         *             case "8": m = check.Pay8; break;
         *             case "9": m = check.Pay9; break;
         *             case "10": m = check.Pay10; break;
         *             case "11": m = check.Pay11; break;
         *             case "12": m = check.Pay12; break;
         *             case "13": m = check.Pay13; break;
         *             case "14": m = check.Pay14; break;
         *             case "15": m = check.Pay15; break;
         *             case "16": m = check.Pay16; break;
         *             case "17": m = check.Pay17; break;
         *             case "18": m = check.Pay18; break;
         *             case "19": m = check.Pay19; break;
         *             case "20": m = check.Pay20; break;
         *             default: break;
         *         }
         *
         *         if (m != 0) doc.Element("check").Add(new XAttribute(type.NameCourt.TrimEnd(), m));
         *     }
         *     doc.Element("check").Add(new XAttribute("Rendu", check.Rendu));
         *     doc.Element("check").Add(new XAttribute("sum", check.TotalTTC));
         *     doc.Element("check").Add(new XAttribute("date", check.Date));
         *     doc.Element("check").Add(new XAttribute("DCBC", check.DCBC));
         *     doc.Element("check").Add(new XAttribute("DCBC_BiloPoints", check.DCBC_BiloPoints));
         *     doc.Element("check").Add(new XAttribute("DCBC_DobavilePoints", check.DCBC_DobavilePoints));
         *     doc.Element("check").Add(new XAttribute("DCBC_OtnayliPoints", check.DCBC_OtnayliPoints));
         *     doc.Element("check").Add(new XAttribute("DCBC_OstalosPoints", check.DCBC_OstalosPoints));
         *     doc.Element("check").Add(new XAttribute("DCBC_name", check.DCBC_name));
         *
         *
         *     check.PayProducts = ClassSync.ClassCloseTicketTmp.PayProducts.sel(check.CustumerId);
         *
         *     foreach (var p in check.PayProducts)
         *     {
         *         ClassProducts.product ptemp = ClassProducts.listProducts.Find(la => la.CustumerId == p.ProductId);
         *
         *
         *         XElement el = (
         *                new XElement("product",
         *                    new XElement("CustumerId", p.ProductId),
         *                    new XElement("grp", ClassGroupProduct.getGrpId(ptemp == null ? 3 : ptemp.cusumerIdSubGroup).grp),
         *                    new XElement("qty", p.QTY),
         *                    new XElement("Name", p.Name),
         *                    new XElement("CodeBare", p.Barcode),
         *                    new XElement("price", p.PriceHT),
         *                    new XElement("tva", ClassTVA.listTVA.Find(l => l.val == p.TVA).id),
         *                    new XElement("total", p.Total),
         *                    new XElement("Discount", p.Discount),
         *                    new XElement("sumDiscount", p.sumDiscount)
         *                    )
         *                );
         *         doc.Element("check").Add(el);
         *     }
         *
         *     return doc;
         * }
         */
        public static XDocument DbToXelemet(ClassSync.ClassCloseTicket.ChecksTicket check)
        {
            XDocument doc;

            doc = new XDocument(
                new XElement("check",
                             new XAttribute("barcodeCheck", check.BarCode))
                )
            ;
            foreach (ClassSync.TypesPayDB type in ClassSync.TypesPayDB.t)
            {
                decimal m = 0.0m;

                switch (type.NameCourt)
                {
                case "BankChecks": m = check.PayBankChecks; break;

                case "BankCards": m = check.PayBankCards; break;

                case "Cash": m = check.PayCash; break;

                case "Resto": m = check.PayResto; break;

                case "1": m = check.Pay1; break;

                case "2": m = check.Pay2; break;

                case "3": m = check.Pay3; break;

                case "4": m = check.Pay4; break;

                case "5": m = check.Pay5; break;

                case "6": m = check.Pay6; break;

                case "7": m = check.Pay7; break;

                case "8": m = check.Pay8; break;

                case "9": m = check.Pay9; break;

                case "10": m = check.Pay10; break;

                case "11": m = check.Pay11; break;

                case "12": m = check.Pay12; break;

                case "13": m = check.Pay13; break;

                case "14": m = check.Pay14; break;

                case "15": m = check.Pay15; break;

                case "16": m = check.Pay16; break;

                case "17": m = check.Pay17; break;

                case "18": m = check.Pay18; break;

                case "19": m = check.Pay19; break;

                case "20": m = check.Pay20; break;

                default: break;
                }

                if (m != 0)
                {
                    doc.Element("check").Add(new XAttribute(type.NameCourt.TrimEnd(), m));
                }
            }
            doc.Element("check").Add(new XAttribute("Rendu", check.Rendu));
            doc.Element("check").Add(new XAttribute("sum", check.TotalTTC));
            doc.Element("check").Add(new XAttribute("date", check.Date));

            doc.Element("check").Add(new XAttribute("DCBC", check.CheckDiscount.DCBC ?? ""));
            doc.Element("check").Add(new XAttribute("DCBC_BiloPoints", check.CheckDiscount.DCBC_BiloPoints ?? 0));
            doc.Element("check").Add(new XAttribute("DCBC_DobavilePoints", check.CheckDiscount.DCBC_DobavilePoints ?? 0));
            doc.Element("check").Add(new XAttribute("DCBC_OtnayliPoints", check.CheckDiscount.DCBC_OtnayliPoints ?? 0));
            doc.Element("check").Add(new XAttribute("DCBC_OstalosPoints", check.CheckDiscount.DCBC_OstalosPoints ?? 0));
            doc.Element("check").Add(new XAttribute("DCBC_name", check.CheckDiscount.DCBC_name ?? ""));


            check.PayProducts = new ClassSync.ClassCloseTicket.PayProducts().get(check.CustumerId);

            foreach (var p in check.PayProducts)
            {
                ClassProducts.product ptemp = ClassProducts.listProducts.Find(la => la.CustumerId == p.ProductId);

                XElement el = (
                    new XElement("product",
                                 new XElement("CustumerId", p.ProductId),
                                 new XElement("grp", ClassGroupProduct.getGrpId(ptemp == null ? 3 : ptemp.cusumerIdSubGroup).grp),
                                 new XElement("qty", p.QTY),
                                 new XElement("Name", p.Name),
                                 new XElement("CodeBare", p.Barcode),
                                 new XElement("price", p.PriceHT),
                                 new XElement("tva", ClassTVA.listTVA.Find(l => l.val == p.TVA).id),
                                 new XElement("total", p.Total),
                                 new XElement("Discount", p.Discount),
                                 new XElement("sumDiscount", p.sumDiscount)
                                 )
                    );
                doc.Element("check").Add(el);
            }

            return(doc);
        }
Exemplo n.º 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();
        }
Exemplo n.º 7
0
        public string getSelected(GroupBox grpBox)
        {
            string res = "None - Vide";
            //   Grid grd = (Grid)grpBox.Content;
            UIElementCollection uiec = panelA.Children;

            foreach (UIElement uelement in uiec)
            {
                if (typeof(RadioButton) == uelement.GetType())
                {
                    RadioButton rbtn = (RadioButton)uelement;
                    if ((bool)rbtn.IsChecked)
                    {
                        cb.SelectedItem = null;
                        res             = rbtn.Content.ToString();
                    }
                }
            }
            uiec = panelB.Children;
            foreach (UIElement uelement in uiec)
            {
                if (typeof(RadioButton) == uelement.GetType())
                {
                    RadioButton rbtn = (RadioButton)uelement;
                    if ((bool)rbtn.IsChecked)
                    {
                        cb.SelectedItem = null;
                        res             = rbtn.Content.ToString();
                    }
                }
            }

            if (cb.SelectedItem != null)
            {
                res = "_TypesPayDynamic" + (cb.SelectedItem as ClassSync.TypesPayDB).Id;
            }

            if (xDescription.Text.TrimEnd() != "")
            {
                List <Class.ClassProducts.product> lp = Class.ClassProducts.getProduct(xDescription.Text);

                switch (lp.Count)
                {
                case 0: statusMes.Content = ("С таким именем продукт не найден "); this.xtbc.SelectedIndex = 3; _expander.IsExpanded = true; break;

                case 1: statusMes.Content = (""); res = "Products id=[" + lp[0].CustumerId.ToString() + "]"; break;

                default:
                    Class.ClassProducts.product pe = list.SelectedItem as Class.ClassProducts.product;
                    if (pe == null)
                    {
                        this.xtbc.SelectedIndex = 3;
                        _expander.IsExpanded    = true;
                    }

                    else
                    {
                        res = "Products id=[" + lp[0].CustumerId.ToString() + "]";
                    }

                    break;
                }
            }

            return(res);
        }
Exemplo n.º 8
0
        public void setSelected(GroupBox grpBox, string textSelector)
        {
            bool flgrbt = false;
            //    Grid grd = (Grid)grpBox.Content;
            UIElementCollection uiec = panelA.Children;

            foreach (UIElement uelement in uiec)
            {
                if (typeof(RadioButton) == uelement.GetType())
                {
                    RadioButton rbtn = (RadioButton)uelement;
                    rbtn.IsChecked = false;
                    if (rbtn.Content.ToString() == textSelector)
                    {
                        rbtn.IsChecked = true;
                        flgrbt         = true;
                    }
                }
            }
            uiec = panelB.Children;

            foreach (UIElement uelement in uiec)
            {
                if (typeof(RadioButton) == uelement.GetType())
                {
                    RadioButton rbtn = (RadioButton)uelement;
                    rbtn.IsChecked = false;
                    if (rbtn.Content.ToString() == textSelector)
                    {
                        rbtn.IsChecked = true;
                        flgrbt         = true;
                    }
                }
            }
            if ((!flgrbt) && (textSelector.Substring(0, textSelector.Length > 15 ? 15 : 0) == "_TypesPayDynamic"))
            {
                int indx = -1;
                if (int.TryParse(textSelector == null ? "-1" : textSelector.Replace("_TypesPayDynamic", ""), out indx))
                {
                    cb.SelectedItem = ClassBond.getTypesPayDBFromId(indx);
                }
            }

            if ((!flgrbt) && (textSelector.Substring(0, textSelector.Length > 13 ? 13 : 0) == "Products id=["))
            {
                string sd = textSelector.Substring(textSelector.IndexOf("[") + 1, textSelector.IndexOf("]") - textSelector.IndexOf("[") - 1);

                Guid g = Guid.Parse(sd);

                List <Class.ClassProducts.product> lp = Class.ClassProducts.listProducts.FindAll(l => l.CustumerId == g);

                switch (lp.Count)
                {
                case 0: statusMes.Content = ("С таким именем продукт не найден "); this.xtbc.SelectedIndex = 3; _expander.IsExpanded = true; break;

                case 1: statusMes.Content = (""); xDescription.Text = lp[0].Name; break;

                default:
                    Class.ClassProducts.product pe = list.SelectedItem as Class.ClassProducts.product;
                    if (pe == null)
                    {
                        this.xtbc.SelectedIndex = 3;
                        _expander.IsExpanded    = true;
                    }

                    //    else

                    xDescription.Text = lp[0].Name;

                    break;
                }
            }
        }
Exemplo n.º 9
0
 public static decimal calc_total(ClassProducts.product p, decimal qty)
 {
     return(Math.Round(p.price * qty, 2));//+ p.price * qty * (ClassTVA.getTVA(p.tva) / 100), 2);
 }