コード例 #1
0
ファイル: W_MessageSB.xaml.cs プロジェクト: SokolSib/FRANCE
 private void WindowKeyUp(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Return)
     {
         ClassEtcFun.WmSound(@"Data\Computer_Error.wav");
     }
 }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: SokolSib/FRANCE
        private void DispatcherTimerTick(object sender, EventArgs e)
        {
            var dt = DateTime.Now;

            _countTick++;

            ldt.Content = $"{dt} ({Sec - _countTick}) ";

            if (!Config.FromLoadSyncAll)
            {
                if (_countTick == Sec)
                {
                    _countTick = 0;

                    foreach (var bs in ClassEtcFun.FindVisualChildren <Button>(this).Where(bs => (string)bs.ToolTip == "UpdateDB"))
                    {
                        if (_bUpdText == string.Empty)
                        {
                            _bUpdText = bs.Content.ToString();
                        }
                        bs.Content = $"{_bUpdText} ({RepositoryProduct.GetAbCountFromDb()})";
                    }

                    ldtc.Content = "BD a été MàJ " + dt.ToLongTimeString();
                }
            }
            else
            {
                ldtc.Content = "Происходит фоновая синхронизация... работайте ....";
            }

            CommandManager.InvalidateRequerySuggested();
        }
コード例 #3
0
ファイル: W_NumPadMini.xaml.cs プロジェクト: SokolSib/FRANCE
 private void UserControlLoaded(object sender, RoutedEventArgs e)
 {
     foreach (var bs in ClassEtcFun.FindVisualChildren <Button>(this))
     {
         bs.Click += ButtonClick;
     }
 }
コード例 #4
0
ファイル: CheckService.cs プロジェクト: SokolSib/FRANCE
        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);
        }
コード例 #5
0
        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            if (((Button)sender).Name == "Save")
            {
                string error = "";

                foreach (TextBox bs in ClassEtcFun.FindVisualChildren <TextBox>(this))
                {
                    if (!Valid(bs))
                    {
                        error += (bs.Name + " incorrect") + Environment.NewLine;
                    }
                }

                if (error.Length == 0)
                {
                    FunctionsService.Click(sender);
                }
                else
                {
                    FunctionsService.ShowMessageTimeList(error);
                }
            }
            else
            {
                FunctionsService.Click(sender);
            }
        }
コード例 #6
0
        public static void Move(bool devis)
        {
            FunctionsService.ShowMessage(null, " please  waite....");

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

            if (mw != null)
            {
                mw.IsEnabled = false;
            }
            _worker = new BackgroundWorker();

            if (devis)
            {
                _worker.DoWork             += WorkerDoWorkDevis;
                _worker.RunWorkerCompleted += WorkerRunWorkerCompleted;
            }
            else
            {
                _worker.DoWork             += WorkerDoWorkFact;
                _worker.RunWorkerCompleted += WorkerRunWorkerCompleted;
            }

            _worker.RunWorkerAsync();
        }
コード例 #7
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;
            }
        }
コード例 #8
0
ファイル: W_Add_Product.xaml.cs プロジェクト: SokolSib/FRANCE
        public WAddProduct(ProductType product = null)
        {
            var windowProducts = ClassEtcFun.FindWindow("NameWGridProduct");

            if (windowProducts == null)
            {
                windowProducts = new WGridProduct();
                windowProducts.Show();
            }
            InitializeComponent();
            TvaBox.ItemsSource   = RepositoryTva.Tvases;
            GroupBox.ItemsSource = RepositoryGroupProduct.GroupProducts;

            if (product != null)
            {
                Save.Content        = Properties.Resources.BtnUpdate;
                Product             = product;
                xName.Text          = product.Name;
                xCodeBar.Text       = product.CodeBare;
                xPrice.Text         = $"{product.Price}";
                TvaBox.SelectedItem = product.Tva;
                xBalance.IsChecked  = product.Balance;

                var group =
                    RepositoryGroupProduct.GroupProducts.FirstOrDefault(g => g.Id == product.SubGrpProduct.Group.Id);
                GroupBox.SelectedItem = group;

                if (group != null)
                {
                    SubgroupBox.ItemsSource  = group.SubGroups;
                    SubgroupBox.SelectedItem = group.SubGroups.FirstOrDefault(s => s.Id == product.SubGrpProduct.Id);
                }
            }

            if (!RepositoryAccountUser.LoginedUser.Role.IsPermiss(Privelege.RedactStockCount))
            {
                lStockCount.Visibility = Visibility.Collapsed;
                xStockCount.Visibility = Visibility.Collapsed;
            }
            else if (product != null)
            {
                var stockReal = RepositoryStockReal.GetByProduct(product);
                xStockCount.Text = $"{stockReal.Qty}";
            }

            BoxErrorText.Text = string.Empty;

            _workerAdd.RunWorkerCompleted  += WorkerCompleted;
            _workerEdit.RunWorkerCompleted += WorkerCompleted;
            _workerAdd.DoWork  += WorkerAddDoWork;
            _workerEdit.DoWork += WorkerEditDoWork;
        }
コード例 #9
0
ファイル: MainWindow.xaml.cs プロジェクト: SokolSib/FRANCE
        private void MainWindowLoaded(object sender, RoutedEventArgs e)
        {
            lnm.Content = Config.Name;
            lnt.Content = Config.NameTicket;
            lnu.Content = Config.User;

            if (Config.IsUseServer)
            {
                _dispatcherTimer          = new DispatcherTimer();
                _dispatcherTimer.Tick    += DispatcherTimerTick;
                _dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1, 0);
                _dispatcherTimer.Start();
            }

            ClassBallanceMAGELLAN_8400.Opn();
            //Windows 8 API to enable touch keyboard to monitor for focus tracking in this WPF application
            try
            {
                var cp  = new InputPanelConfiguration();
                var icp = cp as IInputPanelConfiguration;
                if (icp != null)
                {
                    icp.EnableFocusTracking();
                }
            }
            catch
            {
                // ignored
            }

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

            xProduct.Focus();
            ClassCustomerDisplay.Hi();

            status_message.Text += Environment.NewLine + "--------------------------------" + Environment.NewLine +
                                   "Caisse : " + Config.NameTicket + Environment.NewLine +
                                   "Post : " + Config.NumberTicket + Environment.NewLine +
                                   "Nom d'usager : " + Config.User + Environment.NewLine + Environment.NewLine +
                                   "--------------------------------" + Environment.NewLine +
                                   "La clé d'ouverture générale : " + GlobalVar.TicketWindowG + Environment.NewLine +
                                   "La clé d'ouverture local : " + GlobalVar.TicketWindow + Environment.NewLine;

            foreach (var gs in ClassEtcFun.FindVisualChildren <GridSplitter>(this))
            {
                gs.IsEnabled = Config.GridModif;
            }
        }
コード例 #10
0
 private void ButtonClick(object sender, RoutedEventArgs e)
 {
     if (Product.Price == 0.0m)
     {
         var window = ClassEtcFun.FindWindow("MainWindow_") as MainWindow;
         if (window != null)
         {
             var dataGrid = window.GridProducts;
             var selected = (XElement)dataGrid.SelectedItem;
             if (selected != null)
             {
                 CheckService.DelProductCheck(selected.GetXElementValue("ii").ToInt());
             }
         }
     }
     Close();
 }
コード例 #11
0
ファイル: CheckService.cs プロジェクト: SokolSib/FRANCE
        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);
        }
コード例 #12
0
ファイル: CheckService.cs プロジェクト: SokolSib/FRANCE
        public static void AddProductCheck(ProductType product, decimal qty)
        {
            product.Discount    = RepositoryDiscount.Client.Procent + RepositoryDiscount.Client.ProcentDefault;
            product.SumDiscount = Math.Truncate(product.Price * qty * product.Discount) / 100;
            product.Qty         = qty;
            product.Total       = Math.Truncate((product.Price * product.Qty - product.SumDiscount) * 100) / 100;

            CassieService.OpenProductsCheck();

            var productElements    = RepositoryCheck.DocumentProductCheck.GetXElements("check", "product");
            var newProductXElement = ProductType.ToCheckXElement(product,
                                                                 productElements?.ToList() ?? new List <XElement>());

            RepositoryCheck.DocumentProductCheck.GetXElement("check").Add(newProductXElement);

            ClassCustomerDisplay.WritePrice(product.Name, qty, product.Price);
            FunctionsService.WriteTotal();
            ClassEtcFun.WmSound(@"Data\Beep.wav");

            RepositoryCheck.DocumentProductCheck.Save(RepositoryCheck.PathProductCheck);
        }
コード例 #13
0
ファイル: MainWindow.xaml.cs プロジェクト: SokolSib/FRANCE
        private void XProductKeyUp(object sender, KeyEventArgs e)
        {
            _countTick = 0;
            if (e.Key == Key.F11)
            {
                foreach (var gs in ClassEtcFun.FindVisualChildren <GridSplitter>(this))
                {
                    gs.IsEnabled = !gs.IsEnabled;
                }
            }

            if (e.Key == Key.F12)
            {
                Settings.Default.Reset();
            }

            if (e.Key == Key.Return)
            {
                KeyReturn();
            }
        }
コード例 #14
0
ファイル: W_GridPay.xaml.cs プロジェクト: SokolSib/FRANCE
        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 = "__";
            }
        }
コード例 #15
0
ファイル: W_updateDB.xaml.cs プロジェクト: SokolSib/FRANCE
        public void WindowLoaded(object sender, RoutedEventArgs e)
        {
            var rec = RepositoryHistoryChangeProduct.Document.GetXElements("HistoryChangeProducts", "rec");

            var xElements = rec as XElement[] ?? rec.ToArray();
            var first     = xElements.FirstOrDefault();

            if (first != null)
            {
                SelectGroup           = first.GetXElementValue("group").ToInt();
                dataGrid1.DataContext = xElements.Where(l => l.GetXElementValue("group") == first.GetXElementValue("group"));

                var p = xElements.Count(l => l.GetXElementValue("group") == (SelectGroup + 1).ToString());
                xP.IsEnabled = p != 0;
                xN.IsEnabled = xElements.Count(l => l.GetXElementValue("group") == (SelectGroup - 1).ToString()) != 0;
            }

            foreach (var bs in ClassEtcFun.FindVisualChildren <Button>(this))
            {
                bs.Click += (o, a) => { FunctionsService.Click(o); }
            }
            ;
        }
    }
コード例 #16
0
ファイル: CheckService.cs プロジェクト: SokolSib/FRANCE
        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 отсутвует или структура не правильная");
            }
        }
コード例 #17
0
ファイル: MainWindow.xaml.cs プロジェクト: SokolSib/FRANCE
        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       = "";
                }
            }
        }