Ejemplo 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);
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
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");
            }
        }
Ejemplo n.º 8
0
 private static dotTemplate Func(string path)
 {
     try
     {
         var         stream = new FileStream(path, FileMode.Open);
         dotTemplate template;
         using (stream)
         {
             using (var reader = new StreamReader(stream))
                 template = dotTemplate.Parse(reader.ReadToEnd());
         }
         return(template);
     }
     catch (System.Exception ex)
     {
         var s = "Ошибка " + path + ex.Message + ".";
         FunctionsService.ShowMessageSb(s);
         LogService.Log(TraceLevel.Error, 92, s);
         return(null);
     }
 }
Ejemplo n.º 9
0
        private void TestProduct(PayProductBase p, bool minus)
        {
            var pr = RepositoryProduct.Products.Find(l => l.CustomerId == p.ProductId);

            if (pr != null)
            {
                var h = new WHow(p.Qty, pr.Balance)
                {
                    Owner = this
                };
                h.ShowDialog();
            }
            else
            {
                FunctionsService.ShowMessageSb(Properties.Resources.LabelProductRemoved);
                var h = new WHow(p.Qty * (minus ? -1 : 1), p.Qty - (int)p.Qty != 0)
                {
                    Owner = this
                };
                h.ShowDialog();
            }
        }
Ejemplo n.º 10
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.º 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       = "";
                }
            }
        }