Пример #1
0
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            _typesPay.Content = PayType.Name;
            tbS.Text          = RepositoryCurrencyRelations.Residue().ToString();
            numPad.TextBox    = tbS;
            numPad.BEnter     = xEnter;
            var owner = Owner as MainWindow;

            if (owner != null)
            {
                owner.qty_label.Text = "__";
            }
        }
Пример #2
0
        public static decimal RenduCalc()
        {
            var rendu   = 0.0m;
            var noRendu = 0.0m;
            var sum     = RepositoryCurrencyRelations.GetSumMoney();

            foreach (var tm in RepositoryTypePay.TypePays)
            {
                rendu += tm.RenduAvoir ?? false?RepositoryCurrencyRelations.GetMoneyFromType(tm) : 0.0m;

                noRendu += !tm.RenduAvoir ?? false?RepositoryCurrencyRelations.GetMoneyFromType(tm) : 0.0m;
            }

            return(sum - noRendu < 0 ? -rendu : sum - noRendu - rendu);
        }
Пример #3
0
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            GridLoad("m", ClassGridGroup.GridCurrencyPathGetPath(TypesPay));

            foreach (var bs in ClassEtcFun.FindVisualChildren <Button>(this))
            {
                bs.Click += ButtonClick;
            }

            var owner = Owner as MainWindow;

            if (owner != null)
            {
                var cc = RepositoryCurrencyRelations.Transform(FunctionsService.GetMoney((this.Owner as MainWindow).qty_label), this.TypesPay);

                foreach (var h in cc)
                {
                    FunctionsService.AddCurrency(h.Currency, h.Count, this);
                }

                owner.qty_label.Text = "__";
            }
        }
Пример #4
0
        public static void Bay()
        {
            RepositoryCheck.GetDucument();

            if (RepositoryCheck.Document.Element("checks") != null && RepositoryCheck.DocumentProductCheck.GetXElements("check", "product").Any())
            {
                RepositoryCheck.DocumentProductCheck = RepositoryActionHashBox.MergeProductsInCheck(RepositoryCheck.DocumentProductCheck);

                try
                {
                    foreach (var type in RepositoryTypePay.TypePays)
                    {
                        var money = RepositoryCurrencyRelations.GetMoneyFromType(type);
                        RepositoryCheck.DocumentProductCheck.GetXElement("check").Add(new XAttribute(type.NameCourt.TrimEnd(), money));
                    }
                }
                catch (System.Exception ex)
                {
                    var text = ex.Message;
                    FunctionsService.ShowMessageSb(text);
                    LogService.Log(TraceLevel.Error, 1, text + RepositoryCheck.DocumentProductCheck);
                }

                var rendu = ClassEtcFun.RenduCalc();

                try
                {
                    RepositoryCheck.DocumentProductCheck.GetXElement("check").Add(new XAttribute("Rendu", rendu.ToString("0.00")));
                }
                catch (System.Exception ex)
                {
                    var text = ex.Message;
                    FunctionsService.ShowMessageSb(text);
                    LogService.Log(TraceLevel.Error, 2, text + RepositoryCheck.DocumentProductCheck + ".");
                }

                try
                {
                    RepositoryCheck.DocumentProductCheck.GetXElement("check").Add(
                        new XAttribute("sum", RepositoryCurrencyRelations.GetSumMoney()),
                        new XAttribute("date", DateTime.Now));
                }
                catch (System.Exception ex)
                {
                    var text = ex.Message;
                    FunctionsService.ShowMessageSb(text);
                    LogService.Log(TraceLevel.Error, 3, text + RepositoryCheck.DocumentProductCheck + ".");
                }

                try
                {
                    if (RepositoryDiscount.Client.Barcode != null && !ClassProMode.ModePro)
                    {
                        AddSetDiscountCardBareCode(
                            RepositoryDiscount.Client.Barcode,
                            RepositoryDiscount.Client.Points - (RepositoryDiscount.Client.AddPoints ? 1 : 0) +
                            (RepositoryDiscount.Client.DiscountSet ? RepositoryDiscount.Client.MaxPoints : 0),
                            RepositoryDiscount.Client.AddPoints ? 1 : 0,
                            RepositoryDiscount.Client.DiscountSet ? 8 : 0,
                            RepositoryDiscount.Client.NameFirst + " " + RepositoryDiscount.Client.NameLast);
                    }
                }
                catch (System.Exception ex)
                {
                    var text = ex.Message;
                    FunctionsService.ShowMessageSb(text);
                    LogService.Log(TraceLevel.Error, 4, text + RepositoryCheck.DocumentProductCheck + ".");
                }

                if (ClassProMode.ModePro || ClassProMode.Devis)
                {
                    ClassProMode.Move(ClassProMode.Devis);
                }
                else
                {
                    var element = RepositoryCheck.DocumentProductCheck.Element("check");
                    element.GetXAttribute("barcodeCheck").SetValue(RepositoryCheck.GetBarCodeCheck());
                    RepositoryCheck.Document.GetXElement("checks").Add(element);
                }

                if (!ClassProMode.ModePro && !ClassProMode.Devis)
                {
                    new ClassPrintCheck(RepositoryCheck.DocumentProductCheck, false);
                }

                try
                {
                    var worker = new BackgroundWorker();

                    if (!ClassProMode.ModePro && !ClassProMode.Devis)
                    {
                        worker.DoWork             += WorkerDoWork;
                        worker.RunWorkerCompleted += WorkerRunWorkerCompleted;
                        worker.RunWorkerAsync();
                    }
                }
                catch (System.Exception ex)
                {
                    var text = ex.Message;
                    LogService.Log(TraceLevel.Error, 7, text + RepositoryCheck.DocumentProductCheck + ".");
                }

                try
                {
                    if (!ClassProMode.ModePro && !ClassProMode.Devis)
                    {
                        RepositoryCheck.Document.Save(RepositoryCheck.Path);
                        RepositoryCheck.DocumentProductCheck = null;
                        CassieService.OpenProductsCheck();
                        RepositoryDiscount.RestoreDiscount();
                        DiscountCalc();
                        FunctionsService.WriteTotal();
                    }
                }
                catch (System.Exception ex)
                {
                    var text = ex.Message;
                    FunctionsService.ShowMessageSb(text);
                    LogService.Log(TraceLevel.Error, 8, text + RepositoryCheck.DocumentProductCheck + ".");
                }
            }
            else
            {
                FunctionsService.ShowMessageSb("файл check.xml отсутвует или структура не правильная");
            }
        }
Пример #5
0
        public void KeyReturn()
        {
            var barcode = xProduct.Text.Trim();

            if (barcode.Length > 0)
            {
                var count = barcode.Split('-').Length;
                lrendu.Content = "Rendu: " + RepositoryCurrencyRelations.Residue().ToString("0.00") + " €";

                if (count != 4)
                {
                    decimal qty = 1;

                    // Сток
                    if (BlockStock.Visibility == Visibility.Visible)
                    {
                        var product = RepositoryProduct.GetByBarcode(barcode);
                        if (product != null)
                        {
                            qty = GetQtyFromBarcode(product.CodeBare, barcode);
                            var resultQty = qty != 1 ? qty : FunctionsService.GetQty(qty_label);
                            var productBc = new ProductBc(product, resultQty);
                            _stocks.Add(productBc);

                            xProduct.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 0));
                            xProduct.Text       = "";
                        }
                        else
                        {
                            FunctionsService.ShowMessageTime(Properties.Resources.LabelProductNotFind);
                        }
                    }
                    else
                    {
                        var xP = RepositoryProduct.GetXElementByBarcode(barcode);

                        if (xP != null)
                        {
                            qty = GetQtyFromBarcode(xP.GetXElementValue("CodeBare"), barcode);
                        }

                        if (xP != null)
                        {
                            try
                            {
                                CheckService.AddProductCheck(xP, qty != 1 ? qty : FunctionsService.GetQty(qty_label));
                                xProduct.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 0));
                                xProduct.Text       = "";
                            }
                            catch (System.Exception ex)
                            {
                                LogService.Log(TraceLevel.Error, 3, "Barcode :" + barcode + " " + ex.Message + ".");
                            }
                        }
                        else
                        {
                            if (count == 10)
                            {
                                var cent = int.Parse(barcode.Substring(barcode.Length - 2, 2));
                                var sd   = barcode.Substring(barcode.Length - 11, 8).Replace("-", "");
                                var euro = int.Parse(sd);
                                var m    = ((decimal)(euro * 100 + cent)) / 100;
                                qty_label.Text = m.ToString();
                            }
                            else
                            {
                                if (barcode.Length == 13)
                                {
                                    xP = RepositoryProduct.GetXElementByBarcode(barcode.Substring(0, 7));

                                    if (xP != null)
                                    {
                                        var qtyCurrent = decimal.Parse(barcode.Substring(7, 5)) / 1000;
                                        CheckService.AddProductCheck(xP, qtyCurrent);
                                        xProduct.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 0));
                                        xProduct.Text       = "";
                                    }
                                }

                                if (xP == null && barcode.Length == 13)
                                {
                                    xP = RepositoryProduct.GetXElementByBarcode(barcode.Substring(0, 8));

                                    if (xP != null)
                                    {
                                        var qtyCurrent = decimal.Parse(barcode.Substring(8, 4)) / 1000;
                                        CheckService.AddProductCheck(xP, qtyCurrent);
                                        xProduct.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 0));
                                        xProduct.Text       = "";
                                    }
                                }

                                if (xP == null)
                                {
                                    try
                                    {
                                        xProduct.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0));
                                        xProduct.Text       = "";
                                        ClassEtcFun.WmSound(@"Data\Computer_Error.wav");
                                        var result = FunctionsService.ShowMessage(Properties.Resources.BtnAdd,
                                                                                  "Cet article n'existe pas! Ajouter un article?", Properties.Resources.BtnAdd);
                                        if (result)
                                        {
                                            var windowAddProduct = new WAddProduct {
                                                xCodeBar = { Text = barcode }
                                            };
                                            windowAddProduct.ShowDialog();
                                        }
                                    }
                                    catch (System.Exception ex)
                                    {
                                        LogService.Log(TraceLevel.Error, 4,
                                                       "Barcode :" + barcode + " " + ex.Message + ".");
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (RepositoryDiscount.Client.Barcode == barcode)
                    {
                        RepositoryDiscount.RestoreDiscount();
                        CheckService.DiscountCalc();
                        FunctionsService.WriteTotal();
                    }
                    else
                    {
                        var discountCard = RepositoryDiscount.GetDiscount(barcode);
                        if (discountCard == null)
                        {
                            FunctionsService.ShowMessageSb("La carte n'existe pas ");
                        }
                        else if (discountCard.IsActive)
                        {
                            FunctionsService.WriteTotal();
                        }
                        else
                        {
                            FunctionsService.ShowMessageSb(" La carte est bloquée ");
                        }

                        RepositoryDiscount.GetClientInfoById(RepositoryDiscount.Client.InfoClientsCustomerId);
                    }

                    xProduct.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 0));
                    xProduct.Text       = "";
                }
            }
        }