private void ComboBoxTheme_SelectionChanged(object sender, SelectionChangedEventArgs e) { String Theme = this.ComboBoxTheme.SelectedItem.ToString(); Theme = Theme.Replace("System.Windows.Controls.ComboBoxItem: ", ""); string uri = @"\ReuxablesLegacy;component\" + Theme + ".xaml"; ((App)Application.Current).ChangeTheme(new Uri(uri, UriKind.Relative)); Model.Local.ConfigRepository ConfigRepository = new Model.Local.ConfigRepository(); Model.Local.Config Config = new Model.Local.Config(); Boolean isConfig = false; if (ConfigRepository.ExistName(Core.Global.ConfigTheme)) { Config = ConfigRepository.ReadName(Core.Global.ConfigTheme); isConfig = true; } Config.Con_Value = Theme; if (isConfig == true) { ConfigRepository.Save(); } else { Config.Con_Name = Core.Global.ConfigTheme; ConfigRepository.Add(Config); } }
private void LoadButtonImageDocument() { Boolean flag = false; Model.Local.ConfigRepository ConfigRepository = new Model.Local.ConfigRepository(); if (ConfigRepository.ExistName(Core.AppConfig.ConfigImage)) { if (ConfigRepository.ReadName(Core.AppConfig.ConfigImage).Con_Value.ToString() == "True") { flag = true; } } this.ButtonImportPrestashopImage.IsEnabled = flag; this.ButtonImportPrestashopDocumentJoin.IsEnabled = flag; this.TabItemImportMedia.IsEnabled = flag; this.TabItemImportDocumentsRules.IsEnabled = flag; this.ButtonClearPsImage.IsEnabled = flag; }
public SynchronisationCommande(DateTime?filtre = null) { this.InitializeComponent(); this.LabelInformation.Content = "Recherche des commandes à transférer ..."; this.worker.WorkerReportsProgress = true; this.worker.DoWork += delegate(object s, DoWorkEventArgs args) { // récupération des commandes PrestaShop (le filtrage par date est appliqué dans la requête SQL) Model.Prestashop.PsOrdersRepository PsOrdersRepository = new Model.Prestashop.PsOrdersRepository(); List <Model.Prestashop.idorder> ListOrders = PsOrdersRepository.ListID(Core.Global.CurrentShop.IDShop); if (ListOrders.Count > 0) { Model.Local.OrderRepository OrderRepository = new Model.Local.OrderRepository(); this.ListSync = OrderRepository.ListPrestaShop(); // filtrage sur uniquement les commandes non synchronisées et dont le statut demande une création dans Sage Model.Local.ConfigRepository ConfigRepository = new Model.Local.ConfigRepository(); Model.Local.Config ConfigBC = (ConfigRepository.ExistName(Core.Global.ConfigCommandeStatutCreateBC)) ? ConfigRepository.ReadName(Core.Global.ConfigCommandeStatutCreateBC) : null; Model.Local.Config ConfigDevis = (ConfigRepository.ExistName(Core.Global.ConfigCommandeStatutCreateDevis)) ? ConfigRepository.ReadName(Core.Global.ConfigCommandeStatutCreateDevis) : null; List <string> idstate_string = new List <string>(); idstate_string.AddRange((ConfigBC != null && !string.IsNullOrEmpty(ConfigBC.Con_Value)) ? ConfigBC.Con_Value.Split('#') : string.Empty.Split('#')); idstate_string.AddRange((ConfigDevis != null && !string.IsNullOrEmpty(ConfigDevis.Con_Value)) ? ConfigDevis.Con_Value.Split('#') : string.Empty.Split('#')); List <Model.Prestashop.idorder> ListNotSync = ListOrders.Where(o => !this.ListSync.Contains((int)o.id_order) && idstate_string.Contains(o.current_state.ToString())).ToList(); this.ListCount = ListNotSync.Count; if (ListNotSync.Count > 0) { // ouverture de la connexion ODBC this.worker.ReportProgress(-42); Connexion = Core.Global.GetODBC(); Model.Prestashop.PsOrders PsOrders = null; if (Connexion != null) { foreach (Model.Prestashop.idorder Orders in ListNotSync) { try { PsOrders = PsOrdersRepository.ReadOrder((int)Orders.id_order); Core.Sync.SynchronisationCommande SynchronisationCommande = new Core.Sync.SynchronisationCommande(); SynchronisationCommande.Exec(Connexion, PsOrders, PsOrdersRepository); } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } lock (this) { this.CurrentCount += 1; } this.worker.ReportProgress((this.CurrentCount * 100 / this.ListCount)); } } else { this.CurrentCount += ListNotSync.Count; } } } }; this.worker.ProgressChanged += delegate(object s, ProgressChangedEventArgs args) { if (args.ProgressPercentage >= 0) { this.ProgressBarCommande.Value = args.ProgressPercentage; this.LabelInformation.Content = "Informations : " + args.ProgressPercentage + " %"; } else if (args.ProgressPercentage == -42) { this.LabelInformation.Content = "Ouverture connexion ODBC Sage..."; } }; this.worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args) { if (Connexion != null) { Connexion.Close_Connexion(); } this.Close(); }; // Insérez le code requis pour la création d’objet sous ce point. this.worker.RunWorkerAsync(); }
private void LoadComponent() { // <JG> 26/12/2012 this.CbGroupeClient.ItemsSource = new Model.Local.GroupRepository().ListGroupesLies(); this.ButtonOustanding.IsEnabled = Core.Global.GetConfig().ModuleAECCustomerOutstandingActif; if (Core.Global.GetConfig().ConfigBToB) { this.TabItemClientBToB.IsEnabled = true; this.TabItemClientBToC.IsEnabled = false; this.TabItemClientBToB.IsSelected = true; this.GroupBoxSageCustomer.Header = (Core.Global.GetConfig().ConfigClientMultiMappageBtoB) ? "Client(s) Sage" : "Client(s) Sage non mappé(s)"; this.LoadBTOBCustomer(); } else if (Core.Global.GetConfig().ConfigBToC) { this.TabItemClientBToC.IsEnabled = true; this.TabItemClientBToB.IsEnabled = false; this.TabItemClientBToC.IsSelected = true; Model.Prestashop.PsCustomerRepository PsCustomerRepository = new Model.Prestashop.PsCustomerRepository(); this.DataGridClient.ItemsSource = (Core.Global.GetConfig().ConfigClientFiltreCommande) ? PsCustomerRepository.ListTopActiveOrderByDateAdd(60, 1, Core.Global.CurrentShop.IDShop) : PsCustomerRepository.ListTopActiveOrderByDateAddWithOrder(60, 1, Core.Global.CurrentShop.IDShop); this.TabItemClientBToB.IsEnabled = false; #region centralisation clients Model.Local.Config Config = new Model.Local.Config(); Model.Local.ConfigRepository ConfigRepository = new Model.Local.ConfigRepository(); if (ConfigRepository.ExistName(Core.Global.ConfigClientTypeLien) && ConfigRepository.ReadName(Core.Global.ConfigClientTypeLien).Con_Value == Core.Global.ConfigClientTypeLienEnum.CompteCentralisateur.ToString()) { if (ConfigRepository.ExistName(Core.Global.ConfigClientCompteCentralisateur)) { Config = ConfigRepository.ReadName(Core.Global.ConfigClientCompteCentralisateur); if (Core.Global.IsInteger(Config.Con_Value)) { Int32 cbMarqCentralisateur = Int32.Parse(Config.Con_Value); Model.Sage.F_COMPTETRepository F_COMPTETRepositoryCentralisateur = new Model.Sage.F_COMPTETRepository(); Model.Sage.F_COMPTET F_COMPTETCentralisateur; if (F_COMPTETRepositoryCentralisateur.ExistId(cbMarqCentralisateur)) { F_COMPTETCentralisateur = F_COMPTETRepositoryCentralisateur.Read(cbMarqCentralisateur); this.LabelClientCentralisateur.Content = "Commandes et adresses des clients Prestashop centralisées vers le compte Sage " + F_COMPTETCentralisateur.CT_Num + " " + F_COMPTETCentralisateur.CT_Intitule; } } } } #endregion } else { this.BtTransfert.IsEnabled = false; } LoadModules(); }
public MainWindow() { try { Core.UpdateVersion.LicenseIsActive = ReadLicence(); if (Core.UpdateVersion.LicenseIsActive == UpdateVersion.LicenceActivation.enabled) { DataContext = new MainContext(); InitializeComponent(); this.Title = (!Core.UpdateVersion.License.ExtranetOnly) ? "Prestaconnect pour Sage " + Core.UpdateVersion.SageFolder(Core.UpdateVersion.CurrentSageVersion) + " et Prestashop " + Core.UpdateVersion.PrestaShopFolder(Core.UpdateVersion.CurrentPrestaShopVersion) : "Module Extranet pour Sage " + Core.UpdateVersion.SageFolder(Core.UpdateVersion.CurrentSageVersion); if (Core.UpdateVersion.License.ExtranetOnly) { Core.Global.GetConfig().UpdateConfigBtoCBtoB(false, true); Core.Global.GetConfig().UpdateConfigMailActive(true); } this.SyncSupply(); String[] Args = Environment.GetCommandLineArgs(); if (Args.Length > 1) { Core.Global.UILaunch = false; this.ExecWithArgs(Args); } else { Core.Global.UILaunch = true; #region Theme Model.Local.ConfigRepository ConfigRepository = new Model.Local.ConfigRepository(); if (ConfigRepository.ExistName(Core.Global.ConfigTheme)) { Model.Local.Config Config = ConfigRepository.ReadName(Core.Global.ConfigTheme); foreach (ComboBoxItem ComboBoxItem in this.ComboBoxTheme.Items) { if (ComboBoxItem.Content.ToString() == Config.Con_Value) { this.ComboBoxTheme.SelectedItem = ComboBoxItem; break; } } } #endregion #region Infos Prestashop Model.Prestashop.PsConfigurationRepository PsConfigurationRepository = new Model.Prestashop.PsConfigurationRepository(); Model.Prestashop.PsConfiguration PsConfiguration = new Model.Prestashop.PsConfiguration(); PsConfiguration = new Model.Prestashop.PsConfiguration(); Model.Prestashop.PsShopURLRepository PsShopURLRepository = new Model.Prestashop.PsShopURLRepository(); Model.Prestashop.PsShopURL PsShopURL = PsShopURLRepository.ReadShopId(Global.CurrentShop.IDShop); //TODO vérification du domaine pour création hyperlien if (PsShopURL != null) { Global.URL_Prestashop = String.Format("http://{0}{1}{2}", PsShopURL.Domain, PsShopURL.PhysicalUri, PsShopURL.VirtualUri); while (Global.URL_Prestashop.EndsWith("/")) { Global.URL_Prestashop = Global.URL_Prestashop.Substring(0, Global.URL_Prestashop.Length - 1); } string logoUri = string.Empty; //try //{ // if (PsConfigurationRepository.ExistNameShop(Core.Global.PrestaShopLogo)) // { // logoUri = "img/" + PsConfigurationRepository.ReadNameShop(Core.Global.PrestaShopLogo).Value; // } //} //catch (Exception) { if (PsConfigurationRepository.ExistName(Core.Global.PrestaShopLogo)) { logoUri = "/img/" + PsConfigurationRepository.ReadName(Core.Global.PrestaShopLogo).Value; } else if (PsConfigurationRepository.ExistNameShop(Core.Global.PrestaShopLogo)) { logoUri = "/img/" + PsConfigurationRepository.ReadNameShop(Core.Global.PrestaShopLogo).Value; } else { logoUri = (PsShopURL.IDShop == 1) ? "/img/logo.jpg" : "/img/logo-" + PsShopURL.IDShop + ".jpg"; } } LabelPrestashopLink.NavigateUri = new Uri(Global.URL_Prestashop); LabelPrestashopLink.ToolTip = Global.URL_Prestashop; ImagePrestashopLogo.Source = new BitmapImage(new Uri(Global.URL_Prestashop + logoUri)); ImagePrestashopLogo.ToolTip = Global.URL_Prestashop; } #endregion #region liste commandes/clients this.LoadOrdersAndCustomers(); #endregion this.ReadVersion(); this.ActiveSupplierMenuItem(); if (Core.Global.GetConfig().UIMaximizeWindow) { this.WindowState = System.Windows.WindowState.Maximized; Core.Temp.Current = System.Windows.WindowState.Maximized; } } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }