Ejemplo n.º 1
0
        public static void DelProductCheck(string barcode)
        {
            var selectedIndex   = ((MainWindow)ClassEtcFun.FindWindow("MainWindow_")).GridProducts.SelectedIndex;
            var productElements = RepositoryCheck.DocumentProductCheck.GetXElements("check", "product").Where(p => p.GetXElementValue("CodeBare").Trim() == barcode.Trim()).ToList();

            if (productElements.Count > 0)
            {
                var firstQty = productElements.First().GetXElementValue("qty").ToDecimal();

                if (RepositoryProduct.Products.Find(l => l.CustomerId == productElements.First().GetXElementValue("id").ToGuid()).Balance || (firstQty == 0))
                {
                    productElements.First().Remove();
                }
                else
                {
                    productElements.First().GetXElement("qty").Value = (firstQty - 1).ToString();
                }
            }
            else
            {
                RepositoryDiscount.RestoreDiscount();
                DiscountCalc();
                FunctionsService.WriteTotal();
            }
            FunctionsService.WriteToatl(selectedIndex);
            RepositoryCheck.DocumentProductCheck.Save(RepositoryCheck.PathProductCheck);
        }
Ejemplo n.º 2
0
        private static void WorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            SyncData.SetSunc(false);
            new ClassPrintCheck(RepositoryCheck.DocumentProductCheck, false);
            RepositoryCheck.DocumentProductCheck = null;
            CassieService.OpenProductsCheck();
            Pro     = null;
            Ndevis  = -1;
            Nfact   = -1;
            Check   = null;
            Devis   = false;
            ModePro = false;

            RepositoryDiscount.RestoreDiscount();
            CheckService.DiscountCalc();
            FunctionsService.WriteTotal();

            var de = ClassEtcFun.FindWindow("_W_Message");

            if (de != null)
            {
                de.Close();
            }

            var mw = ClassEtcFun.FindWindow("MainWindow_");

            if (mw != null)
            {
                mw.IsEnabled = true;
            }
        }
Ejemplo n.º 3
0
        private void SetInfo()
        {
            if (_card != null)
            {
                _info = RepositoryDiscount.GetClientInfoById(_card.InfoClientsCustomerId);
            }

            ClientInfoControl.SetClientInfo(_info);

            if (_card != null)
            {
                BtnActive.Content = _card.IsActive
                    ? Properties.Resources.BtnToDeactive
                    : Properties.Resources.BtnToActive;

                BtnActive.Visibility         = Visibility.Visible;
                BtnSave.Visibility           = Visibility.Visible;
                ClientInfoControl.Visibility = Visibility.Visible;
                BoxNotFound.Visibility       = Visibility.Collapsed;
            }
            else
            {
                BtnActive.Visibility         = Visibility.Collapsed;
                BtnSave.Visibility           = Visibility.Collapsed;
                ClientInfoControl.Visibility = Visibility.Collapsed;
                BoxNotFound.Visibility       = Visibility.Visible;
            }
        }
Ejemplo n.º 4
0
 public static void BufAddXElm(XElement element)
 {
     RepositoryCheck.DocumentProductCheck = new XDocument();
     RepositoryCheck.DocumentProductCheck.Add(element);
     RepositoryDiscount.RestoreDiscount();
     DiscountCalc();
     FunctionsService.WriteTotal();
 }
Ejemplo n.º 5
0
        public static void DelProductCheck(int id)
        {
            RepositoryCheck.C = null;
            var selectedIndex   = ((MainWindow)ClassEtcFun.FindWindow("MainWindow_")).GridProducts.SelectedIndex;
            var productElements = RepositoryCheck.DocumentProductCheck.GetXElements("check", "product").ToList();

            if (productElements.Count == 0)
            {
                RepositoryDiscount.RestoreDiscount();
                DiscountCalc();
                FunctionsService.WriteTotal();
            }
            else
            {
                var curElement = productElements.FirstOrDefault(l => l.GetXElementValue("ii").ToInt() == id);
                curElement?.Remove();
            }
            FunctionsService.WriteToatl(selectedIndex);
            RepositoryCheck.DocumentProductCheck.Save(RepositoryCheck.PathProductCheck);
        }
Ejemplo n.º 6
0
        public static void AddSetDiscountCardBareCode(string barcode, int biloP, int dobavileP, int otnayliP, string name)
        {
            var a  = RepositoryCheck.DocumentProductCheck.GetXAttribute("check", "DCBC");
            var a1 = RepositoryCheck.DocumentProductCheck.GetXAttribute("check", "DCBC_BiloPoints");
            var a2 = RepositoryCheck.DocumentProductCheck.GetXAttribute("check", "DCBC_DobavilePoints");
            var a3 = RepositoryCheck.DocumentProductCheck.GetXAttribute("check", "DCBC_OtnayliPoints");
            var a4 = RepositoryCheck.DocumentProductCheck.GetXAttribute("check", "DCBC_OstalosPoints");
            var a5 = RepositoryCheck.DocumentProductCheck.GetXAttribute("check", "DCBC_name");

            if (a == null)
            {
                RepositoryCheck.DocumentProductCheck.GetXElement("check").Add(
                    new XAttribute("DCBC", barcode),
                    new XAttribute("DCBC_BiloPoints", biloP),
                    new XAttribute("DCBC_DobavilePoints", dobavileP),
                    new XAttribute("DCBC_OtnayliPoints", otnayliP),
                    new XAttribute("DCBC_OstalosPoints", biloP + dobavileP - otnayliP),
                    new XAttribute("DCBC_name", name));
            }
            else
            {
                a.SetValue(barcode);
                a1.SetValue(biloP);
                a2.SetValue(dobavileP);
                a3.SetValue(otnayliP);
                a4.SetValue(biloP + dobavileP - otnayliP);
                a5.SetValue(name);
            }

            if (barcode != null)
            {
                TmpBarcode = barcode;
                TmpPoints  = biloP + dobavileP - otnayliP;
                if (dobavileP > 0 || otnayliP > 0)
                {
                    RepositoryDiscount.SetDiscountPoint(TmpBarcode, TmpPoints, true);
                }
            }
        }
Ejemplo n.º 7
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 отсутвует или структура не правильная");
            }
        }
Ejemplo n.º 8
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       = "";
                }
            }
        }