示例#1
0
        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            var main   = Owner as MainWindow;
            var name   = Sub + "_" + xName.Content + "x" + yName.Content;
            var button = (Button)main.FindName(name);

            if (button != null)
            {
                button.Background = new SolidColorBrush(xColor.SelectedColor);
                button.Foreground = new SolidColorBrush(xColorFont.SelectedColor);
                button.Content    = xCaption.Text;

                var elm = button.Tag as ClassGridGroup.Elm ?? new ClassGridGroup.Elm(
                    RepositoryXmlFile.GetPathByType(XmlDocEnum.B),
                    (byte)X,
                    (byte)Y,
                    button.Content.ToString(),
                    GetSelected(xGBFunction));

                elm.Func       = GetSelected(xGBFunction);
                elm.Background = button.Background;
                elm.Foreground = button.Foreground;
                elm.Caption    = button.Content.ToString();
                if (elm.Caption == string.Empty)
                {
                    ProductType product;
                    elm.Caption    = FunctionsTranslateService.GetTranslatedFunctionWithProd(elm.Func, out product);
                    button.Content = elm.Caption;
                }

                button.Tag = elm;

                var bReset = (Button)sender;
                if (bReset.Tag.ToString() == "Réinitialiser la configuration")
                {
                    button.Tag = "None - Vide";
                }

                if (button.Tag != null && button.Tag.ToString() == "None - Vide")
                {
                    button.ClearValue(BackgroundProperty);
                    button.Content = string.Empty;
                    button.ToolTip = Properties.Resources.LabelNone;
                }
                ClassGridGroup.Save(button);
                Close();
            }
        }
示例#2
0
        public static Elm[,] Load(XmlDocEnum type, int payId = -1)
        {
            var g       = new Elm[12, 12];
            var xmlGrid = RepositoryXmlFile.Load(type, payId);

            var xId         = (from el in xmlGrid.Elements("Grid").Elements("rec").Elements("id") select el).ToList();
            var xX          = (from el in xmlGrid.Elements("Grid").Elements("rec").Elements("X") select el).ToList();
            var xY          = (from el in xmlGrid.Elements("Grid").Elements("rec").Elements("Y") select el).ToList();
            var xCaption    = (from el in xmlGrid.Elements("Grid").Elements("rec").Elements("Caption") select el).ToList();
            var xColor      = (from el in xmlGrid.Elements("Grid").Elements("rec").Elements("Color") select el).ToList();
            var xImg        = (from el in xmlGrid.Elements("Grid").Elements("rec").Elements("Img") select el).ToList();
            var xFunc       = (from el in xmlGrid.Elements("Grid").Elements("rec").Elements("Fun") select el).ToList();
            var xForeground = (from el in xmlGrid.Elements("Grid").Elements("rec").Elements("foreground") select el).ToList();

            for (var i = 0; i < xId.Count; i++)
            {
                var f = new Elm(RepositoryXmlFile.GetPathByType(type, payId), xX[i].Value.ToByte(), xY[i].Value.ToByte(), xCaption[i].Value, xFunc[i].Value);

                var argbtColor      = xColor[i].Value.Split(',');
                var argbtForeground = xForeground.Count != xId.Count ? new[] { "255", "255", "255", "255" } : xForeground[i].Value.Split(',');

                if (argbtColor.Length == 0)
                {
                    f.Background = null;
                }

                if (argbtColor.Length == 4)
                {
                    f.Background =
                        new SolidColorBrush(Color.FromArgb(byte.Parse(argbtColor[0]), byte.Parse(argbtColor[1]), byte.Parse(argbtColor[2]), byte.Parse(argbtColor[3])));
                }

                if (argbtColor.Length == 3)
                {
                    f.Background = new SolidColorBrush(Color.FromRgb(byte.Parse(argbtColor[0]), byte.Parse(argbtColor[1]), byte.Parse(argbtColor[2])));
                }

                if (argbtForeground.Length == 0)
                {
                    f.Foreground = null;
                }

                if (argbtForeground.Length == 4)
                {
                    f.Foreground =
                        new SolidColorBrush(Color.FromArgb(byte.Parse(argbtForeground[0]), byte.Parse(argbtForeground[1]), byte.Parse(argbtForeground[2]),
                                                           byte.Parse(argbtForeground[3])));
                }

                if (argbtForeground.Length == 3)
                {
                    f.Foreground = new SolidColorBrush(Color.FromRgb(byte.Parse(argbtForeground[0]), byte.Parse(argbtForeground[1]), byte.Parse(argbtForeground[2])));
                }

                var myImage3 = new Image();
                var bi3      = new BitmapImage();
                bi3.BeginInit();
                bi3.UriSource = new Uri(xImg[i].Value, UriKind.Relative);
                bi3.EndInit();
                myImage3.Stretch = Stretch.Fill;
                myImage3.Source  = bi3;

                f.Img = myImage3;

                g[f.X, f.Y] = f;
            }
            return(g);
        }
示例#3
0
        public void Save(Elm el, int x, int y)
        {
            Grid[x, y, Convert.ToInt16(el.X), Convert.ToInt16(el.Y)] = el;

            var solid  = (el.Background as SolidColorBrush);
            var solid2 = (el.Font as SolidColorBrush);

            var colorText     = solid != null ? solid.Color.R + "," + solid.Color.G + "," + solid.Color.B : "255,0,0";
            var colorFontText = solid2 != null ? solid2.Color.R + "," + solid2.Color.G + "," + solid2.Color.B : "255,0,0";

            var      doc = XDocument.Load(Path);
            XElement target;

            try
            {
                target =
                    doc.Elements("GridProduct")
                    .Elements("_" + x + "x" + y)
                    .Elements("rec")
                    .SingleOrDefault(e => (e.GetXElementValue("X") == el.X.ToString()) & (e.GetXElementValue("Y") == el.Y.ToString()));
            }
            catch
            {
                target = null;
            }

            if (target != null)
            {
                var d           = target.Nodes().ToArray();
                var dateUpd     = (d[1] as XElement);
                var description = (d[4] as XElement);
                var background  = (d[5] as XElement);
                var font        = (d[7] as XElement);

                if (d.Length > 8)
                {
                    var customerId = d[8] as XElement;
                    customerId.Value = el.CustomerId.ToString();
                }
                else
                {
                    target.Add(new XElement("customerId", el.CustomerId));
                }
                dateUpd.Value = DateTime.Now.ToString(Config.DateFormat);

                description.Value = el.Description;
                background.Value  = colorText;
                font.Value        = colorFontText;
            }
            else
            {
                var e = doc.Element("GridProduct").Element("_" + x + "x" + y);

                if (e != null)
                {
                    e.Add(new XElement("rec",
                                       new XElement("id", (el.X * el.Y).ToString()),
                                       new XElement("Date_upd", DateTime.Now.ToString(Config.DateFormat)),
                                       new XElement("X", el.X),
                                       new XElement("Y", el.Y),
                                       new XElement("Description", el.Description),
                                       new XElement("background", colorText),
                                       new XElement("img", el.Img),
                                       new XElement("font", el.Font),
                                       new XElement("customerId", el.CustomerId)));
                }
                else
                {
                    doc.GetXElement("GridProduct").Add(new XElement("_" + x + "x" + y,
                                                                    new XElement("rec",
                                                                                 new XElement("id", (el.X * el.Y).ToString()),
                                                                                 new XElement("Date_upd", DateTime.Now.ToString(Config.DateFormat)),
                                                                                 new XElement("X", el.X),
                                                                                 new XElement("Y", el.Y),
                                                                                 new XElement("Description", el.Description),
                                                                                 new XElement("background", colorText),
                                                                                 new XElement("img", el.Img),
                                                                                 new XElement("font", el.Font),
                                                                                 new XElement("customerId", el.CustomerId)
                                                                                 )
                                                                    )
                                                       );
                }
            }
            doc.Save(Path);

            RepositoryXmlFile.SaveToDb(Path, doc);
        }
示例#4
0
        public static void Save(Button b)
        {
            var windowGridPay = Window.GetWindow(b) as WGridPay;
            var cr            = "Default";
            var cr1           = "Default";
            var dd            = b.Name.Split('x');
            var x             = dd[0].Substring(2, dd[0].Length - 2);
            var y             = dd[1];
            var caption       = b.Content.ToString();
            var sBackground   = b.Background as SolidColorBrush;
            var sForeground   = b.Foreground as SolidColorBrush;

            if (sBackground != null)
            {
                cr = sBackground.Color.A + "," + sBackground.Color.R + "," + sBackground.Color.G + "," +
                     sBackground.Color.B;
            }
            if (sForeground != null)
            {
                cr1 = sForeground.Color.A + "," + sForeground.Color.R + "," + sForeground.Color.G + "," +
                      sForeground.Color.B;
            }

            string funcType = null;
            var    elmTag   = b.Tag as Elm;

            funcType = elmTag != null ? elmTag.Func : b.Tag.ToString();

            var typePayId = -1;

            if (windowGridPay != null)
            {
                typePayId = windowGridPay.TypesPay.Id;
            }

            var type = RepositoryXmlFile.ToXmlDocEnum(b.Name);

            if (type == XmlDocEnum.M)
            {
                caption = ((Label)((StackPanel)b.Content).FindName("mlb_" + x + "x" + y)).Content.ToString();
            }

            var      doc = RepositoryXmlFile.Load(type, typePayId);
            XElement target;

            try
            {
                target =
                    doc.GetXElements("Grid", "rec")
                    .Single(e => (e.GetXElementValue("X") == x) & (e.GetXElementValue("Y") == y));
            }
            catch
            {
                target = null;
            }

            if (target != null)
            {
                var d        = target.Nodes().ToArray();
                var dateUpd  = d[1] as XElement;
                var caption1 = d[4] as XElement;
                var color    = d[5] as XElement;
                var color1   = d[6] as XElement;
                var fun      = d[8] as XElement;

                dateUpd.Value  = DateTime.Now.ToString(Config.DateFormat);
                caption1.Value = caption;
                color.Value    = cr;
                color1.Value   = cr1;
                fun.Value      = funcType;

                if (cr == "Default")
                {
                    target.Remove();
                }
                if (cr1 == "Default")
                {
                    target.Remove();
                }
            }
            else
            {
                if (cr != "Default")
                {
                    doc.GetXElement("Grid").Add(
                        new XElement("rec",
                                     new XElement("id", (int.Parse(x) * int.Parse(y)).ToString()),
                                     new XElement("Date_upd", DateTime.Now.ToString(Config.DateFormat)),
                                     new XElement("X", x),
                                     new XElement("Y", y),
                                     new XElement("Caption", caption),
                                     new XElement("Color", cr),
                                     new XElement("foreground", cr1),
                                     new XElement("Img", ""),
                                     new XElement("Fun", funcType)
                                     )
                        );
                }
            }
            ProductType product;

            b.ToolTip = FunctionsTranslateService.GetTranslatedFunctionWithProd(funcType, out product);

            if (string.IsNullOrEmpty(b.Content?.ToString()) && product != null)
            {
                b.Content = product.Name;
            }

            RepositoryXmlFile.Save(doc, type, typePayId);
        }
示例#5
0
        public static void SyncAll(Dispatcher dispatcher)
        {
            var progressCount = Config.IsUseServer ? 7 + RepositorySyncIsLoading.CheckedCount() : 7;

            ProgressHelper.Instance.Start(progressCount, Resources.LabelDataLoading);

            var progressValue = 0;

            ProgressHelper.Instance.SetValue(progressValue++, Resources.LabelConnectionTest);
            SyncData.SetConnect(Config.IsUseServer && DbService.Connect());

            ProgressHelper.Instance.SetValue(progressValue++, Resources.MenuUsers);
            RepositoryAccountUser.Set();

            ProgressHelper.Instance.SetValue(progressValue++, Resources.LabelTypesPays);
            RepositoryTypePay.Sync();
            SetDefoultTypesPays();

            ProgressHelper.Instance.SetValue(progressValue++, Resources.LabelCurrency);
            RepositoryCurrency.Sync();
            if (RepositoryCurrency.Currencys.Count == 0)
            {
                LogService.LogText(TraceLevel.Error, "Currencus count is 0");
                GlobalVar.IsOpen = false;
            }

            ProgressHelper.Instance.SetValue(progressValue++, Resources.LabelCassieData);
            RepositoryGeneral.Set();
            RepositoryOpenTicketWindow.Sync();
            RepositoryCloseTicketG.Sync();
            RepositorySyncIsLoading.LoadFile();
            RepositoryEstablishment.Sync();
            if (RepositoryEstablishment.Establishment != null)
            {
                LogService.EstablishmentInfo = "Ville = " + RepositoryEstablishment.Establishment.Ville + "\r\n" +
                                               "Adress = " + RepositoryEstablishment.Establishment.Adress + "\r\n" +
                                               "Name = " + RepositoryEstablishment.Establishment.Name + "\r\n" +
                                               "Type = " + RepositoryEstablishment.Establishment.Type + "\r\n" +
                                               "Mail = " + RepositoryEstablishment.Establishment.Mail + "\r\n" +
                                               "Phone = " + RepositoryEstablishment.Establishment.Phone + "\r\n" +
                                               "Fax = " + RepositoryEstablishment.Establishment.Fax + "\r\n" +
                                               "CodeNaf = " + RepositoryEstablishment.Establishment.CodeNaf + "\r\n" +
                                               "Cp = " + RepositoryEstablishment.Establishment.Cp + "\r\n" +
                                               "Ntva = " + RepositoryEstablishment.Establishment.Ntva + "\r\n" +
                                               "Siret = " + RepositoryEstablishment.Establishment.Siret;
            }

            ProgressHelper.Instance.SetValue(progressValue++, Resources.LabelProducts);
            RepositoryProduct.Set();

            if (Config.IsUseServer)
            {
                if (RepositorySyncIsLoading.IsLoading(SyncEnum.PayProduct))
                {
                    ProgressHelper.Instance.SetValue(progressValue++, Resources.LabelPayProduct);
                    RepositoryPayProduct.Sync();
                }

                if (RepositorySyncIsLoading.IsLoading(SyncEnum.CloseTicket))
                {
                    ProgressHelper.Instance.SetValue(progressValue++, Resources.LabelCloseTicket);
                    RepositoryCloseTicket.Sync();
                }

                if (RepositorySyncIsLoading.IsLoading(SyncEnum.PayProductTmp))
                {
                    ProgressHelper.Instance.SetValue(progressValue++, Resources.LabelPayProductTmp);
                    RepositoryPayProductTmp.Sync();
                }

                if (RepositorySyncIsLoading.IsLoading(SyncEnum.CheckTicketTmp))
                {
                    ProgressHelper.Instance.SetValue(progressValue++, Resources.LabelCheckTicketTmp);
                    RepositoryCheckTicketTmp.Sync();
                }

                if (RepositorySyncIsLoading.IsLoading(SyncEnum.CheckTicket))
                {
                    ProgressHelper.Instance.SetValue(progressValue++, Resources.LabelCheckTicket);
                    RepositoryCheckTicket.Sync();
                }

                if (RepositorySyncIsLoading.IsLoading(SyncEnum.ClientInfo))
                {
                    ProgressHelper.Instance.SetValue(progressValue++, Resources.LabelClientInfo);
                    RepositoryClientInfo.Sync();
                }

                if (RepositorySyncIsLoading.IsLoading(SyncEnum.Pro))
                {
                    ProgressHelper.Instance.SetValue(progressValue++, Resources.LabelProviders);
                    RepositoryPro.Sync();
                }

                if (RepositorySyncIsLoading.IsLoading(SyncEnum.DiscountCard))
                {
                    ProgressHelper.Instance.SetValue(progressValue++, Resources.LabelDiscountCard);
                    RepositoryDiscountCard.Sync();
                }

                if (RepositorySyncIsLoading.IsLoading(SyncEnum.DevisWeb))
                {
                    ProgressHelper.Instance.SetValue(progressValue++, Resources.LabelDevisWeb);
                    RepositoryDevisWeb.Sync();
                }

                if (RepositorySyncIsLoading.IsLoading(SyncEnum.XmlFile))
                {
                    ProgressHelper.Instance.SetValue(progressValue++, Resources.LabelXmlFile);
                    RepositoryXmlFile.SetAllFromDb();
                }
            }

            ProgressHelper.Instance.SetValue(progressValue, Resources.LabelDataLoading);
            ClassGridGroup.Initialize();
            ClassGridProduct.Initialize();
            ClassGridStatistiqueRegionEtPays.Initialize();
            ProgressHelper.Instance.Stop();

            if (SyncData.IsConnect)
            {
                if (ClassDataTimeSrv.GetDateTimeFromSrv())
                {
                    var text = Resources.LabelServerTime + " : " + ClassDataTimeSrv.DateTimeFromSrv + Environment.NewLine +
                               Resources.LabelCashboxTime + " : " + DateTime.Now + Environment.NewLine;

                    var window = new WDateTimeSrv(text);
                    window.ShowDialog();
                }
            }

            if (!Config.Bureau)
            {
                var generalEstablishment =
                    RepositoryGeneral.Generals.Find(l => l.EstablishmentCustomerId == Config.IdEstablishment);

                GlobalVar.TicketWindowG = generalEstablishment.TicketWindowGeneral; //SQL.OCC.cassieInf.idTicketWindowG;
                var openTicketWindow =
                    RepositoryOpenTicketWindow.OpenTicketWindows.FirstOrDefault(l => l.CustomerId == Config.CustomerId);
                if (openTicketWindow != null)
                {
                    GlobalVar.TicketWindow = openTicketWindow.IdTicketWindow;
                    GlobalVar.IsOpen       = openTicketWindow.IsOpen;
                    if (!GlobalVar.IsOpen)
                    {
                        openTicketWindow = null;
                    }
                }
                else
                {
                    GlobalVar.IsOpen = false;
                }

                // окно закрытия кассы
                if (generalEstablishment.Date.Date != DateTime.Now.Date &&
                    generalEstablishment.TicketWindowGeneral != Guid.Empty
                    )
                {
                    var errorlist = Resources.LabelNow + " : " + DateTime.Now.ToLongDateString() + "  " +
                                    DateTime.Now.ToLongTimeString() + Environment.NewLine +
                                    "--------------------------------" + Environment.NewLine + Environment.NewLine;

                    errorlist += " " + Resources.LabelOpenTotalTW + " : " +
                                 RepositoryGeneral.Generals.First().Date.ToLongDateString() + Environment.NewLine;
                    errorlist += Resources.LabelOpenLocal + " : ";
                    errorlist += openTicketWindow?.DateOpen.ToLongDateString() ?? string.Empty + Environment.NewLine;

                    var tickedWindowId = GlobalVar.TicketWindow != Guid.Empty ? GlobalVar.TicketWindow.ToString() : string.Empty;

                    var window = new WCloseTicketWindow(errorlist)
                    {
                        BtnCloseLocal = { IsEnabled = tickedWindowId != string.Empty }
                    };
                    window.ShowDialog();
                    RepositoryGeneral.Set();
                    RepositoryOpenTicketWindow.Sync();
                }

                if (!GlobalVar.IsBreak)
                {
                    // окно открытия кассы
                    if (!RepositoryGeneral.IsOpen)
                    {
                        if (GlobalVar.TicketWindowG == Guid.Empty)
                        {
                            var status = Environment.NewLine + "--------------------------------" + Environment.NewLine +
                                         Resources.LabelCashBox + " : " + Config.NameTicket + Environment.NewLine +
                                         Resources.LabelPost + " : " + Config.NumberTicket + Environment.NewLine +
                                         Resources.LabelOpenedBy + " : " + Config.User + Environment.NewLine +
                                         Environment.NewLine +
                                         "--------------------------------" + Environment.NewLine + Environment.NewLine +
                                         Resources.LabelTotalOpeningKey + " : " + GlobalVar.TicketWindowG +
                                         Environment.NewLine + Environment.NewLine +
                                         Resources.LabelLocalOpeningKey + " : " + GlobalVar.TicketWindow +
                                         Environment.NewLine;

                            var window = new WOpenTicletG(status);
                            window.ShowDialog();
                        }
                    }

                    if (GlobalVar.TicketWindow == Guid.Empty)
                    {
                        var status = Environment.NewLine + "--------------------------------" + Environment.NewLine +
                                     Resources.LabelCashBox + " : " + Config.NameTicket + Environment.NewLine +
                                     Resources.LabelPost + " : " + Config.NumberTicket + Environment.NewLine +
                                     Resources.LabelOpenedBy + " : " + Config.User + Environment.NewLine +
                                     Environment.NewLine +
                                     "--------------------------------" + Environment.NewLine +
                                     Resources.LabelTotalOpeningKey + " : " + GlobalVar.TicketWindowG +
                                     Environment.NewLine +
                                     Resources.LabelLocalOpeningKey + " : " + GlobalVar.TicketWindow +
                                     Environment.NewLine;
                        var window = new WOpenTicket(status);
                        window.ShowDialog();
                    }
                }
            }

            DotLiquidService.SetPath(0);
            DotLiquidService.SetPath(1);
            DotLiquidService.SetPath(2);

            RepositoryActionHashBox.Sync();
            CassieService.LoadProductCheckFromFile();
        }