Ejemplo n.º 1
0
        public static bool GetCheckFromChecksAndDelete(string bc)
        {
            var element = RepositoryCheck.Document.GetXElements("checks", "check")
                          .FirstOrDefault(c => c.GetXAttributeValue("barcodeCheck").Trim() == bc.Trim());

            if (element != null)
            {
                CassieService.OpenProductsCheck();

                foreach (var e in element.Elements("product"))
                {
                    RepositoryCheck.DocumentProductCheck.GetXElement("check").Add(e);

                    var qty        = e.GetXElementValue("qty").ToDecimal();
                    var customerId = e.GetXElementValue("cusumerIdRealStock").ToGuid();

                    RepositoryStockReal.AddProductCount(qty, customerId);
                }

                element.Remove();
                RepositoryCheck.Document.Save(RepositoryCheck.Path);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 public static void EnAttenete()
 {
     RepositorySyncPlusProduct.SetCheck(RepositoryCheck.DocumentProductCheck);
     RepositoryCheck.DocumentProductCheck = null;
     CassieService.OpenProductsCheck();
 }
Ejemplo n.º 5
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.º 6
0
 private static void WorkerDoWork(object sender, DoWorkEventArgs e)
 {
     SyncData.SetSunc(true);
     CassieService.RemoveProductCountFromStockReal(RepositoryCheck.GetCloseTicketTmp());
 }
Ejemplo n.º 7
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();
        }