예제 #1
0
        private void BindControls()
        {
            ClassProducts details = DataAccessor.SelectProduct(id);

            NameProductLabel.Text        = details.NameProduct;
            ImageProducts.ImageUrl       = details.ImageProduct;
            LabelDescriptionProduct.Text = details.DescriptionProduct;
            LabelNameProduct.Text        = details.NameProduct;
        }
예제 #2
0
        private void mod(string number)
        {
            XElement elm = (XElement)_ProductsGrid.SelectedItem;

            if (elm != null)
            {
                string s = (tbcb.IsChecked ?? false ? elm.Element("QTY_box").Value : elm.Element("QTY").Value).Replace('.', ',');

                decimal a = 0.0m;

                decimal.TryParse(s, out a);

                decimal c = 0.0m;

                if (!comma)
                {
                    if (s.IndexOf(',') != -1)
                    {
                        string[] comma_ = s.Split(',');

                        comma_[0] += number;

                        decimal.TryParse(comma_[0] + "," + comma_[1], out c);
                    }

                    else
                    {
                        decimal.TryParse(s + number, out c);
                    }

                    //   ClassProducts.updQTYProduct(c - a, elm, tbcb.IsChecked ?? false);
                }

                else
                {
                    if (s.IndexOf(',') == -1)
                    {
                        s += ",";
                    }

                    string[] comma_ = s.Split(',');

                    comma_[1] += number;

                    decimal.TryParse(comma_[0] + "," + comma_[1], out c);
                }

                ClassProducts.updQTYProduct(c - a, elm, tbcb.IsChecked ?? false, typefind);

                _ProductsGrid.Items.Refresh();

                calcTotal();
            }
        }
예제 #3
0
        private void Window_Closed(object sender, EventArgs e)
        {
            ClassProducts.saveLocal();

            Close();
        }
예제 #4
0
        private void modeStandart(KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                string item = text.Text.TrimEnd().TrimStart().ToUpper();

                long digital;

                bool f = long.TryParse(item, out digital);

                text.Text = "";
                if (f)
                {
                    XElement elm = find(item);

                    if (elm == null)
                    {
                        var w = new B.messageDlgTime();

                        w.message.Text = "not found";



                        w.Show();

                        _ProductsGrid.Items.Refresh();
                    }
                    else
                    {
                        int indx = shelfProducts.FindIndex(l => l == elm);

                        string qtys = qty_label.Text.Replace(" box ", "").Replace(" pièces ", "").Replace('_', ' ').Replace('.', ',').Trim();

                        qty_label.Text = "__";

                        decimal qty_ = 0.0m;

                        decimal.TryParse(qtys == "0,0" || qtys == string.Empty ? "1,00" : qtys, out qty_);

                        if (indx == -1)
                        {
                            shelfProducts.Insert(0, elm);

                            ClassProducts.updQTYProduct(qty_, elm, tbcb.IsChecked ?? false, typefind);
                        }
                        else
                        {
                            ClassProducts.updQTYProduct(qty_, elm, tbcb.IsChecked ?? false, typefind);

                            shelfProducts.Remove(elm);

                            shelfProducts.Insert(0, elm);
                        }


                        _ProductsGrid.SelectedItem = elm;



                        _ProductsGrid.Items.Refresh();


                        _ProductsGrid.ScrollIntoView(_ProductsGrid.SelectedItem);

                        ClassF.wm_sound(@"Data\Beep.wav");

                        //   tbcb.IsChecked = true;

                        calcTotal();
                    }
                }
            }
        }
예제 #5
0
        private void setLabelQTY(string number)
        {
            switch (number.TrimEnd())
            {
            case "cl":
                if (!modif)
                {
                    qty_label.Text = "__";
                }
                else
                {
                    modCancel();
                }
                break;

            case "Enter":
                if (modif)
                {
                    modEnd();
                }



                break;

            case ",":
                if (!modif)
                {
                    string fe = (tbcb.IsChecked ?? false) ? " box " : " pièces ";

                    qty_label.Text = (qty_label.Text.Replace(" box ", "").Replace(" pièces ", "").Replace("_", "")) + "," + fe;
                }

                else
                {
                    comma = comma ? false : true;

                    _k.Foreground = comma ? Brushes.Red : Brushes.White;

                    _k.BorderThickness = comma ? new Thickness(5) : new Thickness(0);

                    _k.BorderBrush = comma ? Brushes.Red : Brushes.White;
                }
                break;



            case "Annuler":

                if (shelfProducts.Count > 0)
                {
                    var w = new B.AnullerDevis();

                    w.Owner = this;

                    w.data = shelfProducts.ToArray();

                    w.ShowDialog();

                    _ProductsGrid.Items.Refresh();
                }
                break;

            case "CE":

                XElement selectElm = (XElement)_ProductsGrid.SelectedItem;

                if (selectElm != null)
                {
                    ClassProducts.clrElm(new XElement[] { selectElm });

                    _ProductsGrid.Items.Refresh();
                }
                break;

            case "Valider":
                sendDevis();
                break;

            case "BOX": break;

            case "Modif": if (modif)
                {
                    modCancel();
                }
                else
                {
                    modStart();
                } break;

            case "Find": break;

            case "sync":
                var mes = new B.Sync();

                mes.Owner           = this;
                mes.message.Content = "load please wite ...";

                mes.ShowDialog();
                break;

            case "Close":
                Window_Closed(this, null);
                break;

            case "Réduire":
                WindowState = WindowState.Minimized;
                break;

            default:
                if (!modif)
                {
                    string fe = (tbcb.IsChecked ?? false) ? " box " : " pièces ";

                    qty_label.Text = (qty_label.Text.Replace(" box ", "").Replace(" pièces ", "").Replace("_", "")) + int.Parse(number) + fe;
                }

                else
                {
                    mod(number);
                }

                break;
            }
        }
예제 #6
0
        public void keyReturn()
        {
            string barcode = xProduct.Text.TrimEnd().TrimStart().Trim();

            if (barcode.Length > 0)
            {
                //1234-1234-1234-1234
                //01-12-08-09-30-45-00-22-16-00
                int count__ = barcode.Split('-').Length;

                lrendu.Content = "Rendu: " + ClassBond.residue().ToString("0.00") + " €";

                if (count__ != 4)
                {
                    XElement xP  = null;
                    decimal  qty = 1;
                    try
                    {
                        xP = ClassProducts.findCodeBar(barcode);

                        string cb = xP.Element("CodeBare").Value;


                        string[] cbm = cb.Split('[');

                        foreach (var s in cbm)
                        {
                            int indx = s.IndexOf(barcode + "]");

                            if (indx != -1)
                            {
                                string sqty = s.Replace(barcode + "]", "").Replace("^", "");

                                if (sqty.Length > 0)
                                {
                                    qty = decimal.Parse(sqty);
                                }
                            }
                        }
                    }

                    catch (Exception ex)
                    {
                        new ClassLog("  code 0002 barcode :" + barcode + " " + ex.Message);
                    }
                    if (xP != null)
                    {
                        try
                        {
                            ClassCheck.addProductCheck(xP, qty != 1 ? qty : new ClassFunctuon().getQTY(qty_label));
                            xProduct.Foreground = new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 255, 0));
                            xProduct.Text       = "";
                        }
                        catch (Exception ex)
                        {
                            new ClassLog("  code 0003 barcode :" + barcode + " " + ex.Message);
                        }
                    }
                    else
                    {
                        if (count__ == 10)
                        {
                            int    cent = int.Parse(barcode.Substring(barcode.Length - 2, 2));
                            string sd   = barcode.Substring(barcode.Length - 11, 8).Replace("-", "");
                            int    euro = int.Parse(sd);

                            decimal m = ((decimal)(euro * 100 + cent)) / 100;

                            //   new ClassFunctuon().showMessageTime(m.ToString());

                            qty_label.Text = m.ToString();
                        }
                        else
                        {
                            if (barcode.Length == 13)
                            {
                                xP = Class.ClassProducts.findCodeBar(barcode.Substring(0, 7));

                                if (xP != null)
                                {
                                    decimal qty_ = decimal.Parse(barcode.Substring(7, 5)) / 1000;

                                    ClassCheck.addProductCheck(xP, qty_);
                                    xProduct.Foreground = new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 255, 0));
                                    xProduct.Text       = "";
                                }
                            }

                            if (xP == null && barcode.Length == 13)
                            {
                                //  2386999903842
                                xP = Class.ClassProducts.findCodeBar(barcode.Substring(0, 8));

                                if (xP != null)
                                {
                                    decimal qty_ = decimal.Parse(barcode.Substring(8, 4)) / 1000;

                                    ClassCheck.addProductCheck(xP, qty_);
                                    xProduct.Foreground = new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 255, 0));
                                    xProduct.Text       = "";
                                }
                            }

                            if (xP == null)
                            {
                                try
                                {
                                    xProduct.Foreground = new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 0, 0));
                                    xProduct.Text       = "";
                                    ClassETC_fun.wm_sound(@"Data\Computer_Error.wav");
                                    //  new ClassFunctuon().showMessage("Add Product", "Cet article n'existe pas! Ajouter un article?");

                                    new ClassFunctuon().showMessageSB("Cet article n'existe pas! Ajouter un article?");
                                }
                                catch (Exception ex)
                                {
                                    new ClassLog("  code 0004 barcode :" + barcode + " " + ex.Message);
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (ClassDiscounts.client.barcode == barcode)
                    {
                        ClassDiscounts.restoreDiscount();
                    }
                    else
                    {
                        ClassDiscounts.getDiscount(barcode);

                        ClassDiscounts.getInfClt(ClassDiscounts.client.InfoClients_customerId);
                    }

                    xProduct.Foreground = new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 255, 0));

                    xProduct.Text = "";
                }
            }
        }