public static void MegaSync() { // check tables var syncTask = Task <bool> .Factory.StartNew( () => { RepositoryActionHashBox.Sync(); //RepositoryCheck RepositoryCheckTicket.Sync(); RepositoryCheckTicketTmp.Sync(); RepositoryPro.Sync(); RepositoryClientInfo.Sync(); RepositoryCloseTicket.Sync(); RepositoryCloseTicketCheckDiscount.Sync(); RepositoryCloseTicketG.Sync(); RepositoryCloseTicketTmp.Sync(); RepositoryCountry.Sync(); RepositoryCurrency.Sync(); //RepositoryCurrencyRelations RepositoryDevisId.Sync(); RepositoryDevisWeb.Sync(); //RepositoryDiscount RepositoryDiscountCard.Sync(); RepositoryEstablishment.Sync(); RepositoryGeneral.Sync(); RepositoryGroupProduct.Sync(); //RepositoryHistoryChangeProduct RepositoryInfoClientsDiscountsType.Sync(); RepositoryLastUpdate.Sync(); RepositoryOpenTicketWindow.Sync(); RepositoryPayProduct.Sync(); RepositoryPayProductTmp.Sync(); //RepositoryPriceGros RepositoryProduct.Sync(); RepositoryProductBc.Sync(); RepositoryStatNation.Sync(); RepositoryStatNationPopup.Sync(); RepositoryStatPlaceArrond.Sync(); //RepositoryStockLogs RepositoryStockReal.Sync(); RepositorySyncPlus.Sync(); RepositorySyncPlusProduct.Sync(); //RepositoryTes RepositoryTva.Sync(); RepositoryTypePay.Sync(); //RepositoryXmlFile return(true); }); syncTask.ContinueWith( s => { }); }
public static void Close() { Mess = string.Empty; if (GlobalVar.IsOpen) { Mess += Properties.Resources.FuncCloseCashbox + Config.NameTicket + Environment.NewLine + Environment.NewLine + Environment.NewLine; var otw = RepositoryOpenTicketWindow.GetCurrent(); RepositoryCloseTicket.Close(); RepositoryCheck.CloseTicket(); //PrintService.PrintCloseTicket(closeTicket, Config.NameTicket); Mess += Properties.Resources.LabelOperationComplete + Environment.NewLine; if (otw != null) { otw.DateOpen = DateTime.Now; otw.IsOpen = false; otw.IdTicketWindow = Guid.Empty; otw.IdTicketWindowG = Guid.Empty; RepositoryOpenTicketWindow.Update(otw); Mess += Config.NameTicket + " " + Properties.Resources.LabelCloseEnd.ToLower() + "..." + Environment.NewLine; GlobalVar.IsOpen = false; } else { Mess += Config.NameTicket + " " + Properties.Resources.LabelErrorClosing.ToLower() + "..." + Environment.NewLine; } } else { Mess += Config.NameTicket + " " + Properties.Resources.LabelAlreadyClosing.ToLower() + "..." + Environment.NewLine; } }
public static bool Open() { RepositoryGeneral.Set(); if (!RepositoryGeneral.IsOpen) { var ticketWindowGeneral = RepositoryCloseTicketG.Create(); var general = RepositoryGeneral.Generals.FirstOrDefault(g => g.EstablishmentCustomerId == Config.IdEstablishment); if (general != null) { general.Name = Config.NameTicket; general.IsOpen = true; general.TicketWindowGeneral = ticketWindowGeneral; general.User = Config.User; general.Date = DateTime.Now; general.EstablishmentCustomerId = Config.IdEstablishment; RepositoryGeneral.Update(general); } else { general = new GeneralType(Guid.NewGuid(), ticketWindowGeneral, true, Config.NameTicket, Config.User, DateTime.Now, Config.IdEstablishment); RepositoryGeneral.Add(general); } GlobalVar.TicketWindowG = ticketWindowGeneral; foreach (var rec in RepositoryOpenTicketWindow.OpenTicketWindows.FindAll(l => l.EstablishmentCustomerId == Config.IdEstablishment)) { rec.IdTicketWindowG = GlobalVar.TicketWindowG; RepositoryOpenTicketWindow.Update(rec); } return(true); } FunctionsService.ShowMessageTime("Уже открыта просто продолжите работать"); return(false); }
private void ButtonClick(object sender, RoutedEventArgs e) { RepositoryOpenTicketWindow.Open(); RepositoryHistoryChangeProduct.ToArh(); Close(); }
private static bool CloseOpenTicketWindows() { RepositoryOpenTicketWindow.Sync(false); var openTicketWindows = RepositoryOpenTicketWindow.OpenTicketWindows.FindAll(otw => otw.IsOpen && (otw.IdTicketWindowG == GlobalVar.TicketWindowG)); var flag = false; if (openTicketWindows.Count == 0) { var closeTicketG = RepositoryCloseTicketG.Get(GlobalVar.TicketWindowG).FirstOrDefault(); RepositoryGeneral.Mess += Config.NameTicket + Environment.NewLine; if (closeTicketG != null) { foreach (var el in RepositoryCloseTicket.GetByCloseTicketGId(GlobalVar.TicketWindowG)) { closeTicketG.Pay1 += el.Pay1; closeTicketG.Pay2 += el.Pay2; closeTicketG.Pay3 += el.Pay3; closeTicketG.Pay4 += el.Pay4; closeTicketG.Pay5 += el.Pay5; closeTicketG.Pay6 += el.Pay6; closeTicketG.Pay7 += el.Pay7; closeTicketG.Pay8 += el.Pay8; closeTicketG.Pay9 += el.Pay9; closeTicketG.Pay10 += el.Pay10; closeTicketG.Pay11 += el.Pay11; closeTicketG.Pay12 += el.Pay12; closeTicketG.Pay13 += el.Pay13; closeTicketG.Pay14 += el.Pay14; closeTicketG.Pay15 += el.Pay15; closeTicketG.Pay16 += el.Pay16; closeTicketG.Pay17 += el.Pay17; closeTicketG.Pay18 += el.Pay18; closeTicketG.Pay19 += el.Pay19; closeTicketG.Pay20 += el.Pay20; closeTicketG.PayBankCards += el.PayBankCards; closeTicketG.PayBankChecks += el.PayBankChecks; closeTicketG.PayCash += el.PayCash; closeTicketG.PayResto += el.PayResto; } closeTicketG.DateClose = DateTime.Now; RepositoryCloseTicketG.Update(closeTicketG); flag = true; } else { RepositoryGeneral.Mess += Properties.Resources.LabelErrorClosing + Environment.NewLine; } } else { foreach (var window in openTicketWindows) { RepositoryGeneral.Mess += window.NameTicket + " " + Properties.Resources.LabelOpened.ToLower() + Environment.NewLine; } } return(flag); }
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(); }