Exemplo n.º 1
0
        public static void Print(string barCode, decimal money)
        {
            var printDialog = new PrintDialog();

            var docContext = CreateDocumentContext(barCode, money);
            var docString  = TemplatePathReturnPrint.Render(docContext);

            try
            {
                var doc       = (FlowDocument)XamlReader.Parse(docString);
                var paginator = ((IDocumentPaginatorSource)doc).DocumentPaginator;

                doc.PageWidth   = 280;
                doc.PagePadding = new Thickness(0);
                doc.ColumnGap   = 0;
                doc.ColumnWidth = 0;

                var queue  = printDialog.PrintQueue;
                var writer = PrintQueue.CreateXpsDocumentWriter(queue);
                writer.Write(paginator);
            }
            catch (System.Exception ex)
            {
                var text = ex.Message + docString + ".";
                FunctionsService.ShowMessageSb(text);
                LogService.Log(TraceLevel.Error, 11, text);
            }
        }
Exemplo n.º 2
0
        public static bool ModifProductCheck(int ii, decimal price, string name, decimal qty)
        {
            var res = ModifProductCheckInXml(ii, price, name, qty);

            FunctionsService.WriteTotal();
            return(res);
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
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;
            }
        }
Exemplo n.º 5
0
        public static void Print(List <object[]> objects, DateTime date, int group)
        {
            var printDialog = new PrintDialog();

            var docContext = CreateDocumentContext(objects, date, group);
            var docString  = TemplatePathRaportPricePrint.Render(docContext);

            try
            {
                var doc       = (FlowDocument)XamlReader.Parse(docString);
                var paginator = ((IDocumentPaginatorSource)doc).DocumentPaginator;

                doc.PageWidth   = 280;
                doc.PagePadding = new Thickness(0);
                doc.ColumnGap   = 0;
                doc.ColumnWidth = 0;

                var queue  = printDialog.PrintQueue;
                var writer = PrintQueue.CreateXpsDocumentWriter(queue);
                writer.Write(paginator);
            }
            catch (System.Exception ex)
            {
                var text = ex.Message + docString + ".";
                FunctionsService.ShowMessageSb(text);
                LogService.Log(TraceLevel.Error, 13, text);
            }
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        public static void AddProductCheck(XElement element, decimal qty)
        {
            CassieService.OpenProductsCheck();

            if (ClassProMode.ModePro)
            {
                element = ClassProMode.Replace(new[] { element }).First();
            }

            var product = ProductType.FromXElement(element);

            product = RepositoryProduct.Products.FirstOrDefault(p => p.CustomerId == product.CustomerId);

            if (product.Balance)
            {
                if (GetBallance(product) == null)
                {
                    var button = new Button {
                        ToolTip = "ShowBallance"
                    };
                    FunctionsService.Click(button, product);
                }
                else
                {
                    AddProductCheck(product, product.Qty);
                }
            }
            else
            {
                AddProductCheck(product, qty);
            }
        }
Exemplo n.º 8
0
        public static bool HasPermisson(this WebViewPage view)
        {
            var controller = view.ViewContext.RouteData.Values["controller"].ToString();
            var action     = view.ViewContext.RouteData.Values["action"].ToString();

            return(FunctionsService.Authorize(controller, action, view.GetNhaThuoc(false)));
        }
Exemplo n.º 9
0
        public static void Print(string barcode, string head, List <PrintGroupProduct> printGroupProducts, string total, string sumDiscount, List <PrintTypePay> printPays,
                                 decimal rendu, string footer, PrintClientInfo infoOfClient, bool duplicateF)
        {
            var printDialog = new PrintDialog();

            var docContext = CreateDocumentContext(barcode, head, printGroupProducts, total, sumDiscount, printPays, rendu, footer, infoOfClient, duplicateF);
            var docString  = TemplatePathCheckPrint.Render(docContext);

            try
            {
                var doc       = (FlowDocument)XamlReader.Parse(docString);
                var paginator = ((IDocumentPaginatorSource)doc).DocumentPaginator;

                doc.PageWidth   = 285;
                doc.PagePadding = new Thickness(11, 0, 0, 0);
                doc.ColumnGap   = 0;
                doc.ColumnWidth = 0;

                var queue  = printDialog.PrintQueue;
                var writer = PrintQueue.CreateXpsDocumentWriter(queue);
                writer.Write(paginator);
            }
            catch (System.Exception ex)
            {
                var text = ex.Message + docString + ".";
                FunctionsService.ShowMessageSb(text);
                LogService.Log(TraceLevel.Error, 11, text);
            }
        }
Exemplo n.º 10
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.º 11
0
        public static void StartCheck()
        {
            if (File.Exists(RepositoryCheck.Path))
            {
                try
                {
                    RepositoryCheck.Document = XDocument.Load(RepositoryCheck.Path);
                }
                catch (System.Exception ex)
                {
                    FunctionsService.ShowMessageSb("ошибка файла check.xml " + ex.Message);
                }
            }
            else
            {
                RepositoryCheck.OpenTicket();
            }

            if (File.Exists(RepositoryCheck.PathEnAttenete))
            {
                RepositoryCheck.DocumentEnAttenete = XDocument.Load(RepositoryCheck.PathEnAttenete);
            }
            else
            {
                RepositoryCheck.DocumentEnAttenete = new XDocument();

                RepositoryCheck.DocumentEnAttenete.Add(new XElement("checks",
                                                                    new XAttribute("ticket", Config.NumberTicket),
                                                                    new XAttribute("openDate", DateTime.Now.ToString())
                                                                    ));

                RepositoryCheck.DocumentEnAttenete.Save(RepositoryCheck.PathEnAttenete);
            }
        }
Exemplo n.º 12
0
        async Task <bool> RegisterValidations()
        {
            if (!FunctionsService.ValidateEmail(Mail))
            {
                await _page.DisplayAlert(T.GetValue("app_name"), T.GetValue("mail_error"), T.GetValue("ok"));

                return(false);
            }

            if (!FunctionsService.ValidatePhone(Phone))
            {
                await _page.DisplayAlert(T.GetValue("app_name"), T.GetValue("phone_error"), T.GetValue("ok"));

                return(false);
            }

            if (Password != RePassword)
            {
                await _page.DisplayAlert(T.GetValue("app_name"), T.GetValue("password_differents_message"), T.GetValue("ok"));

                return(false);
            }

            return(true);
        }
Exemplo n.º 13
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);
            }
        }
Exemplo n.º 14
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.º 15
0
 public static void BufAddXElm(XElement element)
 {
     RepositoryCheck.DocumentProductCheck = new XDocument();
     RepositoryCheck.DocumentProductCheck.Add(element);
     RepositoryDiscount.RestoreDiscount();
     DiscountCalc();
     FunctionsService.WriteTotal();
 }
Exemplo n.º 16
0
        public static decimal GetTotalPrice()
        {
            decimal getTotalPrice;

            RepositoryCheck.C = XDocument.Parse(RepositoryCheck.DocumentProductCheck.ToString());
            RepositoryCheck.C = RepositoryActionHashBox.MergeProductsInCheck(RepositoryCheck.C);

            if (RepositoryCheck.C == null)
            {
                getTotalPrice = RepositoryCheck.DocumentProductCheck != null
                    ? Convert.ToDecimal(RepositoryCheck.DocumentProductCheck.GetXElements("check", "product").Sum(l => l.GetXElementValue("total").ToDouble()))
                    : 0.0m;
            }
            else
            {
                getTotalPrice = RepositoryCheck.C != null
                    ? Convert.ToDecimal(RepositoryCheck.C.GetXElements("check", "product").Sum(l => l.GetXElementValue("total").ToDouble()))
                    : 0.0m;
            }

            RepositoryCheck.C = null;

            if (RepositoryDiscount.Client.Barcode != null && getTotalPrice >= RepositoryDiscount.Client.MoneyMax)
            {
                if ((getTotalPrice >= RepositoryDiscount.Client.MoneyMax) && !RepositoryDiscount.Client.AddPoints)
                {
                    if ((DateTime.Now.Day == RepositoryDiscount.Client.LastDateUpd.Day) &&
                        (DateTime.Now.Month == RepositoryDiscount.Client.LastDateUpd.Month) &&
                        (DateTime.Now.Year == RepositoryDiscount.Client.LastDateUpd.Year))
                    {
                        if (RepositoryDiscount.Client.ShowMessaget)
                        {
                            FunctionsService.ShowMessageSb("Cette carte a déjà été utilisé aujourd'hui! " + Environment.NewLine + RepositoryDiscount.Client.LastDateUpd);
                        }

                        RepositoryDiscount.Client.ShowMessaget = false;
                    }
                    else
                    {
                        if (RepositoryDiscount.Client.Points < RepositoryDiscount.Client.MaxPoints)
                        {
                            RepositoryDiscount.Client.AddPoints = true;
                            RepositoryDiscount.Client.Points   += 1;
                        }
                    }
                }
                else
                {
                    if ((getTotalPrice < RepositoryDiscount.Client.MoneyMax) && RepositoryDiscount.Client.AddPoints)
                    {
                        RepositoryDiscount.Client.AddPoints = false;
                        RepositoryDiscount.Client.Points   -= 1;
                    }
                }
            }

            return(getTotalPrice);
        }
Exemplo n.º 17
0
        private void ButtonMouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            _countTick = 0;

            if (RepositoryAccountUser.PermiseByPrivelege(Privelege.RedactButton))
            {
                FunctionsService.ButtonMouseRightButtonDown(sender, e);
            }
        }
Exemplo n.º 18
0
        public static void LoadProductCheckFromFile()
        {
            if (!File.Exists(RepositoryCheck.PathProductCheck))
            {
                OpenProductsCheck();
            }

            RepositoryCheck.DocumentProductCheck = XDocument.Load(RepositoryCheck.PathProductCheck);
            FunctionsService.WriteTotal();
        }
Exemplo n.º 19
0
 public static void OpenProductsCheck()
 {
     if ((RepositoryCheck.DocumentProductCheck == null) || (RepositoryCheck.DocumentProductCheck.Element("check") == null))
     {
         RepositoryCheck.DocumentProductCheck = new XDocument(new XElement("check", new XAttribute("barcodeCheck", RepositoryCheck.GetBarCodeCheck())));
         FunctionsService.WriteTotal();
         RepositoryCheck.DocumentProductCheck.Save(RepositoryCheck.PathProductCheck);
     }
     RepositoryCheck.C = null;
 }
Exemplo n.º 20
0
        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            decimal money;

            if (!string.IsNullOrEmpty(tbS.Text) && decimal.TryParse(tbS.Text.Trim(), out money) &&
                FunctionsService.PayWithValidation(sender, money, MaxMoney, PayType))
            {
                FunctionsService.Click(sender);
            }
        }
Exemplo n.º 21
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.º 22
0
        async Task <bool> RegisterValidations()
        {
            if (!FunctionsService.ValidateEmail(Mail))
            {
                await _page.DisplayAlert(T.GetValue("app_name"), T.GetValue("mail_error"), T.GetValue("ok"));

                return(false);
            }

            return(true);
        }
Exemplo n.º 23
0
        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            var button = sender as Button;

            if (button?.ToolTip != null && button.ToolTip.ToString() == "WNumPadMini")
            {
                string getValue = button.Name.Remove(0, 1);

                switch (getValue)
                {
                case "Sup":
                    TextBox.Text = "";
                    break;

                case "Entree":
                    var window = Tag as WPayEtc;
                    if (window != null)
                    {
                        decimal money;
                        if (!string.IsNullOrEmpty(window.tbS.Text) &&
                            decimal.TryParse(window.tbS.Text.Trim(), out money) &&
                            FunctionsService.PayWithValidation(sender, money, window.MaxMoney, window.PayType))
                        {
                            FunctionsService.Click(BEnter);
                        }
                    }
                    else
                    {
                        FunctionsService.Click(BEnter);
                    }
                    break;

                case "Point":
                    TextBox.Text += ",";
                    break;

                default:
                    if (Clr)
                    {
                        TextBox.Text = "";
                    }
                    int f;
                    if (int.TryParse(getValue, out f))
                    {
                        TextBox.Text += getValue;
                    }
                    break;
                }

                Clr = false;
            }
        }
Exemplo n.º 24
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.º 25
0
 public WHistory()
 {
     InitializeComponent();
     try
     {
         RepositoryCheck.GetDucument();
         TableChecks.DataContext = RepositoryCheck.Document.GetXElements("checks", "check").Reverse();
     }
     catch
     {
         FunctionsService.ShowMessageTime("Пусто");
     }
 }
Exemplo n.º 26
0
        //   public static SerialPort port = new SerialPort("COM4", 9600, Parity.None, 8, StopBits.One);


        public static void Opn()
        {
            try
            {
                Port.ReadTimeout  = 100;
                Port.WriteTimeout = 100;
                Port.Handshake    = Handshake.None;
                Port.Open();
            }
            catch (System.Exception e)
            {
                FunctionsService.ShowMessageSb(e.Message);
            }
        }
Exemplo n.º 27
0
        private void BGetClick(object sender, RoutedEventArgs e)
        {
            decimal newpice;

            if (decimal.TryParse(xPrix.Text.Replace(".", ","), out newpice))
            {
                _product.Price = newpice;
                GetBallance();
                Product = _product;
            }
            else
            {
                FunctionsService.ShowMessageSb("Error prix");
            }
        }
Exemplo n.º 28
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 = "";
        }
        public IActionResult GetFunctions()
        {
            try
            {
                var functions = new FunctionsService(_context).GetFunctions();

                if (!functions.Any())
                {
                    return(NotFound());
                }
                return(Ok(functions));
            }
            catch (System.Exception)
            {
                throw;
            }
        }
Exemplo n.º 30
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 ");
                    }
                }
            }
        }