Exemplo n.º 1
0
        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            int indx = Snp.FindIndex(l => l.CustomerId == CustomerId);

            if (indx != -1)
            {
                RepositoryStatPlaceArrond.Delete(Snp[indx]);
                Snp.RemoveAt(indx);
            }
            else
            {
                FunctionsService.ShowMessageTime("Erroer ");
            }

            CollectionViewSource.GetDefaultView(((WGrid)Owner).dataGrid.ItemsSource).Refresh();

            foreach (Window window in Application.Current.Windows)
            {
                if (window.GetType() == typeof(WStat))
                {
                    WStat w = (window as WStat);
                    w.Reload();
                }
            }

            Close();
        }
Exemplo n.º 2
0
        private void GetBallance()
        {
            var f = false;

            if (_product.Price == 0.0m)
            {
                _product.Price = 1;
                f = true;
            }
            ClassBallanceMAGELLAN_8400.Send(_product.Price, _product.Tare);

            if (ClassBallanceMAGELLAN_8400.Busy_0X15)
            {
                FunctionsService.ShowMessageTime("Pour résoudre ce problème, il vous suffit de re-peser l'article");
            }
            if (ClassBallanceMAGELLAN_8400.Error_0X15)
            {
                FunctionsService.ShowMessageTime("Pour résoudre ce problème, il vous suffit de redémarrer la balance!");
            }

            var prix = 0.0m;

            try
            {
                prix = decimal.Parse(ClassBallanceMAGELLAN_8400.Prix) / 100;
                _qty = decimal.Parse(ClassBallanceMAGELLAN_8400.Poinds) / 1000;
                xBallance_kg.Text = _qty.ToString();
                xPrix_kg.Content  = prix.ToString();
            }
            catch (System.Exception e)
            {
                xBallance_kg.Text = "0";
                xPrix_kg.Content  = "0";

                LogService.Log(TraceLevel.Error, 22, "Error ballance.");
                xLog.Content = e.Message + Environment.NewLine;
            }
            xLog.Content += ClassBallanceMAGELLAN_8400.Error;
            try
            {
                if (!f)
                {
                    xTotal_kg.Content = (Math.Round(decimal.Parse(ClassBallanceMAGELLAN_8400.Montant) / 100, 2));
                }
                else
                {
                    xTotal_kg.Content = "0.0";
                }
            }
            catch
            {
                xTotal_kg.Content = "0";
            }
            if (_qty > 0)
            {
                _product.Contenance = _qty;
                _product.Price      = prix;
            }
        }
Exemplo n.º 3
0
        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            string name = xNamePlaceArrond.Text;
            string QTY  = xQTY.Text;

            if (name.Length == 0)
            {
                FunctionsService.ShowMessageTime("Пустое знаение ");
            }

            else
            {
                if (Snp.FindAll(l => l.NamePlaceArrond == name).Count > 0)
                {
                    FunctionsService.ShowMessageTime("Такое имя сущ-ет ");
                }
                else
                {
                    int qty;

                    if (int.TryParse(QTY, out qty))
                    {
                        int indx = Snp.FindIndex(l => l.CustomerId == this.CustomerId);

                        if (indx != -1)
                        {
                            Snp[indx].NamePlaceArrond = name;
                            Snp[indx].Qty             = qty;
                            RepositoryStatPlaceArrond.Update(Snp[indx]);
                        }
                        else
                        {
                            FunctionsService.ShowMessageTime("Erroer ");
                        }

                        CollectionViewSource.GetDefaultView(((WGrid)Owner).dataGrid.ItemsSource).Refresh();

                        foreach (Window window in Application.Current.Windows)
                        {
                            if (window.GetType() == typeof(WStat))
                            {
                                WStat w = (window as WStat);
                                w.Reload();
                            }
                        }

                        Close();
                    }
                    else
                    {
                        FunctionsService.ShowMessageTime("Неверое значние поля QTY ");
                    }
                }
            }
        }
Exemplo n.º 4
0
 public WHistory()
 {
     InitializeComponent();
     try
     {
         RepositoryCheck.GetDucument();
         TableChecks.DataContext = RepositoryCheck.Document.GetXElements("checks", "check").Reverse();
     }
     catch
     {
         FunctionsService.ShowMessageTime("Пусто");
     }
 }
Exemplo n.º 5
0
        public void AddStock(Guid productId)
        {
            var product = RepositoryProduct.Products.FirstOrDefault(p => p.CustomerId == productId);

            if (product != null)
            {
                _stocks.Add(new ProductBc(product, FunctionsService.GetQty(qty_label)));
            }
            else
            {
                FunctionsService.ShowMessageTime(Properties.Resources.LabelProductNotFind);
            }
        }
Exemplo n.º 6
0
        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            var barCode = codebare.Text.Trim();
            var check   = GetCheck(barCode);

            if (check != null)
            {
                FunctionsService.Click(button, check);
            }
            else
            {
                FunctionsService.ShowMessageTime(Properties.Resources.LabelNofFound);
            }

            codebare.Text = "";
        }
Exemplo n.º 7
0
        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            var name    = xNameNation.Text;
            var qtyText = xQTY.Text;

            if (name.Length == 0)
            {
                FunctionsService.ShowMessageTime("Пустое знаение ");
            }
            else
            {
                if (Snp.Find(l => l.NameNation == name) != null)
                {
                    FunctionsService.ShowMessageTime("Такое имя сущ-ет ");
                }
                else
                {
                    int qty = 0;

                    if (int.TryParse(qtyText, out qty))
                    {
                        var sn = new StatNationPopup(Guid.NewGuid(), name, qty);
                        RepositoryStatNationPopup.Add(sn);
                        Snp.Add(sn);

                        CollectionViewSource.GetDefaultView((Owner as WGrid).dataGrid.ItemsSource).Refresh();

                        foreach (Window window in Application.Current.Windows)
                        {
                            if (window.GetType() == typeof(WStat))
                            {
                                WStat w = (window as WStat);
                                w.Reload();
                            }
                        }

                        Close();
                    }
                    else
                    {
                        FunctionsService.ShowMessageTime("Неверое значние поля QTY ");
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void BtnAddStock_OnClick(object sender, RoutedEventArgs e)
        {
            const int minQty = 10;

            if (_stocks.Count > 0)
            {
                foreach (var productBc in _stocks)
                {
                    if (productBc.Product != null)
                    {
                        var minQtyOfProduct = productBc.Qty > minQty ? productBc.Qty : minQty;

                        RepositoryStockReal.AddOrUpdateCounts(productBc.Product.CustomerId, Config.IdEstablishment,
                                                              productBc.Qty, minQtyOfProduct, productBc.Product.Price);
                    }
                }

                _stocks.Clear();
                FunctionsService.ShowMessageTime(Properties.Resources.LabelOperationComplete);
            }
        }
Exemplo n.º 9
0
        public static bool Open()
        {
            RepositoryGeneral.Set();

            if (!RepositoryGeneral.IsOpen)
            {
                var ticketWindowGeneral = RepositoryCloseTicketG.Create();

                var general = RepositoryGeneral.Generals.FirstOrDefault(g => g.EstablishmentCustomerId == Config.IdEstablishment);

                if (general != null)
                {
                    general.Name   = Config.NameTicket;
                    general.IsOpen = true;
                    general.TicketWindowGeneral = ticketWindowGeneral;
                    general.User = Config.User;
                    general.Date = DateTime.Now;
                    general.EstablishmentCustomerId = Config.IdEstablishment;
                    RepositoryGeneral.Update(general);
                }
                else
                {
                    general = new GeneralType(Guid.NewGuid(), ticketWindowGeneral, true, Config.NameTicket, Config.User, DateTime.Now, Config.IdEstablishment);
                    RepositoryGeneral.Add(general);
                }

                GlobalVar.TicketWindowG = ticketWindowGeneral;

                foreach (var rec in RepositoryOpenTicketWindow.OpenTicketWindows.FindAll(l => l.EstablishmentCustomerId == Config.IdEstablishment))
                {
                    rec.IdTicketWindowG = GlobalVar.TicketWindowG;
                    RepositoryOpenTicketWindow.Update(rec);
                }
                return(true);
            }
            FunctionsService.ShowMessageTime("Уже открыта просто продолжите работать");
            return(false);
        }
Exemplo n.º 10
0
        public void Recalc(decimal qty, PayProduct p)
        {
            var q = qty > 0;

            p = q ? GridProducts.SelectedItem as PayProduct : GridReturnedProducts.SelectedItem as PayProduct;

            if (p != null)
            {
                qty   = Math.Abs(qty);
                p.Qty = p.Qty - qty;

                if (p.Qty < 1)
                {
                    if (q)
                    {
                        _check.PayProducts.Remove(p);
                    }
                    else
                    {
                        _returnedProducts.Remove(p);
                    }
                }

                var g = (q) ? _returnedProducts.Find(l => l.ProductId == p.ProductId) : _check.PayProducts.ToList().Find(l => l.ProductId == p.ProductId);

                if (g != null)
                {
                    g.Qty   = g.Qty + qty;
                    g.Total = (g.PriceHt * g.Qty);
                    p.Total = (p.PriceHt * p.Qty);
                }
                else
                {
                    var n = new PayProduct(
                        p.IdCheckTicket,
                        p.ProductId,
                        p.Name,
                        p.Barcode,
                        qty,
                        p.Tva,
                        p.PriceHt,
                        (p.PriceHt * qty),
                        p.ChecksTicketCustomerId,
                        p.ChecksTicketCloseTicketCustomerId,
                        0,
                        0);

                    p.Total = (p.PriceHt * p.Qty);
                    if (q)
                    {
                        _returnedProducts.Add(n);
                    }
                    else
                    {
                        _check.PayProducts.Add(n);
                    }
                }
                CollectionViewSource.GetDefaultView(GridProducts.ItemsSource).Refresh();
                CollectionViewSource.GetDefaultView(GridReturnedProducts.ItemsSource).Refresh();
            }
            else
            {
                FunctionsService.ShowMessageTime(Properties.Resources.LabelNofFound);
            }
        }
Exemplo n.º 11
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       = "";
                }
            }
        }