private void button10_Click_1(object sender, EventArgs e) { try { using (Forms.GeneralConfig form = new Forms.GeneralConfig()) { form.ShowDialog(); } } // Récupération d'une possible SDKException catch (SDKException ex) { MessageBox.Show(ex.Message); } }
public Main() { InitializeComponent(); string version = new Connecteur_Info.ConnecteurInfo().Version; label3.Text = "Connecteur Sage v" + version + " \nImport et export de documents commerciaux."; labelVersion.Text = "Version : " + version; labelCopyright.Text = "Copyright © 2013 - 2022"; // Init Connecteur Info, Version and Database path in a file Init.Init init = new Init.Init(); if (init.isSettings()) { init.Load(); init.connecteurInfo.installation_dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); init.saveInfo(); } else { init.connecteurInfo = new Connecteur_Info.ConnecteurInfo(); init.connecteurInfo.installation_dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); init.saveInfo(); } Forms.ProgressDialog progressDialog = new Forms.ProgressDialog(); // Initialize the thread that will handle the background process Thread backgroundThread = new Thread( new ThreadStart(() => { //Loading General Settings if (progressDialog.InvokeRequired) { progressDialog.BeginInvoke(new System.Action(() => progressDialog.Text = "Loading General Settings....")); } for (int n = 0; n < 10; n++) { Thread.Sleep(1); progressDialog.UpdateProgress(n); } // Init database && tables Database.Database db = new Database.Database(); db.initTables(); Database.Model.Settings settings_ = db.settingsManager.get(db.connectionString, 1); if (settings_ != null) { //settings.configurationGeneral.general.showWindow == 5 ---> show software label_debugMode.Text = ((settings_.showWindow == 5) ? "Mode Débugage : Activé" : "Mode Débugage : Désactivé"); label_tarifaire.Text = ((settings_.priceType_active == 1 ? true : false) ? "Configuration Tarifaire : Activé" : "Config Tarifaire : Désactivé"); label_retraitement.Text = ((settings_.reprocess_active == 1 ? true : false) ? "Retraitement : Activé" : "Retraitement : Désactivé"); } else { try { using (Forms.GeneralConfig form = new Forms.GeneralConfig()) { form.ShowDialog(); } } // Récupération d'une possible SDKException catch (SDKException ex) { MessageBox.Show(ex.Message); } } //Loading Connexion Settings if (progressDialog.InvokeRequired) { progressDialog.BeginInvoke(new System.Action(() => progressDialog.Text = "Loading Connexion Settings....")); } for (int n = 10; n < 20; n++) { Thread.Sleep(1); progressDialog.UpdateProgress(n); } Connexion.ConnexionSaveLoad conn_Settings = new ConnexionSaveLoad(); if (conn_Settings.isSettings()) { conn_Settings.Load(); label1.Text = "DSN ODBC : " + conn_Settings.configurationConnexion.ODBC.DNS; label2.Text = "DSN ODBC Nom : " + conn_Settings.configurationConnexion.ODBC.USER; label5.Text = "DSN SQL : " + conn_Settings.configurationConnexion.SQL.DNS; label9.Text = "DSN SQL Nom : " + conn_Settings.configurationConnexion.SQL.USER; } else { try { using (Forms.ConfigConnexion form = new Forms.ConfigConnexion()) { form.ShowDialog(); } } // Récupération d'une possible SDKException catch (SDKException ex) { MessageBox.Show(ex.Message); } } //Loading Import Settings if (progressDialog.InvokeRequired) { progressDialog.BeginInvoke(new System.Action(() => progressDialog.Text = "Loading Import Settings....")); } for (int n = 20; n < 40; n++) { Thread.Sleep(1); progressDialog.UpdateProgress(n); } Config_Import.ConfigurationSaveLoad import_Settings = new Config_Import.ConfigurationSaveLoad(); if (import_Settings.isSettings()) { import_Settings.Load(); int cpt = 0; int count = -1; //Doc Export Achat //no config yet, so show désactivated only cpt = 0; count = 3; cpt += ((import_Settings.configurationImport.Doc_Achat.Commande.Activate == "true") ? 1 : 0); isDocAchatCommande = ((import_Settings.configurationImport.Doc_Achat.Commande.Activate == "true") ? true : false); cpt += ((import_Settings.configurationImport.Doc_Achat.DSADV.Activate == "true") ? 1 : 0); isDocAchatDESADV = ((import_Settings.configurationImport.Doc_Achat.DSADV.Activate == "true") ? true : false); cpt += ((import_Settings.configurationImport.Doc_Achat.Facture.Activate == "true") ? 1 : 0); isDocAchatFacture = ((import_Settings.configurationImport.Doc_Achat.Facture.Activate == "true") ? true : false); label2.Text = ((cpt == 0) ? "Document Achat d'import : désactivé" : "Document Achat d'import : " + cpt + "/" + count + " activé"); //Doc Export Vente cpt = 0; count = 3; cpt += ((import_Settings.configurationImport.Doc_Ventes.Commande.Activate == "true") ? 1 : 0); isDocVenteCommande = ((import_Settings.configurationImport.Doc_Ventes.Commande.Activate == "true") ? true : false); cpt += ((import_Settings.configurationImport.Doc_Ventes.DSADV.Activate == "true") ? 1 : 0); isDocVenteDESADV = ((import_Settings.configurationImport.Doc_Ventes.DSADV.Activate == "true") ? true : false); cpt += ((import_Settings.configurationImport.Doc_Ventes.Facture.Activate == "true") ? 1 : 0); isDocVenteFacture = ((import_Settings.configurationImport.Doc_Ventes.Facture.Activate == "true") ? true : false); label9.Text = ((cpt == 0) ? "Document Vente d'import : désactivé" : "Document Vente d'import : " + cpt + "/" + count + " activé"); // Stock cpt = 0; count = 1; cpt += ((import_Settings.configurationImport.Doc_Stock.Stock.Activate == "true") ? 1 : 0); isDocStock = ((import_Settings.configurationImport.Doc_Stock.Stock.Activate == "true") ? true : false); label11.Text = ((cpt == 0) ? "Document de stock import : désactivé" : "Document de stock import : " + cpt + "/" + count + " activé"); } else { try { using (ConfigImport form = new ConfigImport()) { form.ShowDialog(); } } // Récupération d'une possible SDKException catch (SDKException ex) { MessageBox.Show(ex.Message); } } // Loading Export Settings if (progressDialog.InvokeRequired) { progressDialog.BeginInvoke(new System.Action(() => progressDialog.Text = "Loading Export Settings....")); } for (int n = 40; n < 60; n++) { Thread.Sleep(1); progressDialog.UpdateProgress(n); } Config_Export.ConfigurationSaveLoad export_Settings = new Config_Export.ConfigurationSaveLoad(); if (export_Settings.isSettings()) { export_Settings.Load(); int cpt = 0; int count = -1; //Doc Export Achat //no config yet, so show désactivated only cpt = 0; count = 3; label7.Text = ((cpt == 0) ? "Document Achat d'Export : désactivé" : "Document Achat d'Export : " + cpt + "/" + count + " activé"); groupBox_export_doc_achat.Enabled = ((cpt == 0) ? false : true); label_export_doc_achat.Text = ((cpt == 0) ? "Ces fonctionnalité ne sont pas accessible..." : "....."); //Doc Export Vente cpt = 0; count = 3; cpt += ((export_Settings.configurationExport.Commande.Activate) ? 1 : 0); cpt += ((export_Settings.configurationExport.DSADV.Activate) ? 1 : 0); cpt += ((export_Settings.configurationExport.Facture.Activate) ? 1 : 0); label8.Text = ((cpt == 0) ? "Document Vente d'Export : désactivé" : "Document Vente d'Export : " + cpt + "/" + count + " activé"); groupBox_export_doc_vente.Enabled = ((cpt == 0) ? false : true); label_groupBox_export_doc_vente.Text = ((cpt == 0) ? "la configuration est nécessaire. Veuillez vous rendre dans la configuration d'export et la remplir, merci..." : ""); // Stock cpt = 0; count = 1; cpt += ((export_Settings.configurationExport.Stock.Activate) ? 1 : 0); label10.Text = ((cpt == 0) ? "Document stock d'Export : désactivé" : "Document stock d'Export : " + cpt + "/" + count + " activé"); groupBox_export_doc_stock.Enabled = ((cpt == 0) ? false : true); label_export_doc_stock.Text = ((cpt == 0) ? "Veuillez vous rendre dans la configuration d'export et la remplir, merci..." : ""); } else { try { using (ConfExport form = new ConfExport()) { form.ShowDialog(); } } // Récupération d'une possible SDKException catch (SDKException ex) { MessageBox.Show(ex.Message); } } //Loading Backup Settings if (progressDialog.InvokeRequired) { progressDialog.BeginInvoke(new System.Action(() => progressDialog.Text = "Loading Backup Settings....")); } for (int n = 60; n < 80; n++) { Thread.Sleep(1); progressDialog.UpdateProgress(n); } if (File.Exists(pathModule + @"\SettingBackup.xml")) { ConfigurationBackup backup = new ConfigurationBackup(); backup.Load(); label_backup_activation.Text = ((backup.activate) ? "Activation : Oui" : "Activation : Non"); label_backup_generalLog.Text = ((backup.general_Log != 0) ? "Log général : " + backup.general_Log + " jours" : "Log général : désactiver"); label_backup_importLog.Text = ((backup.import_Log != 0) ? "Log d'import : " + backup.import_Log + " jours" : "Log d'import : désactiver"); label_backup_exportLog.Text = ((backup.export_Log != 0) ? "Log d'export : " + backup.export_Log + " jours" : "Log d'export : désactiver"); label_backup_import_success.Text = ((backup.import_files_success != 0) ? "Fichier EDI import (Success) : " + backup.import_files_success + " jours" : "Fichier EDI import (Success) : désactiver"); label_backup_import_error.Text = ((backup.import_files_error != 0) ? "Fichier EDI import (Erreur) : " + backup.import_files_error + " jours" : "Fichier EDI import (Erreur) : désactiver"); label_fichier_backup.Text = ((backup.backup_files != 0) ? "Fichier EDI backup : " + backup.backup_files + " jours" : "Fichier EDI backup : désactiver"); } else { try { using (Forms.ConfigBackup form = new Forms.ConfigBackup()) { form.ShowDialog(); } } // Récupération d'une possible SDKException catch (SDKException ex) { MessageBox.Show(ex.Message); } } bool ok = false; for (int n = 80; n < 100; n++) { Thread.Sleep(1); progressDialog.UpdateProgress(n); if (n == 99) { ok = true; } ; } // Close the dialog if it hasn't been already if (ok && progressDialog.InvokeRequired) { progressDialog.BeginInvoke(new System.Action(() => progressDialog.Close())); string msg = "Vous pouvez réaliser l'import des documents commerciaux suivantes :\n\n"; msg += "Import des bons de commandes d'achat : " + ((isDocAchatCommande) ? "activé" : "désactivé") + "\n"; msg += "Import des bons de livraison d'achat : " + ((isDocAchatDESADV) ? "activé" : "désactivé") + "\n"; msg += "Import des factures d'achat : " + ((isDocAchatFacture) ? "activé" : "désactivé") + "\n\n"; msg += "Import des bons de commandes vente : " + ((isDocVenteCommande) ? "activé" : "désactivé") + "\n"; msg += "Import des bons de livraison vente : " + ((isDocVenteDESADV) ? "activé" : "désactivé") + "\n"; msg += "Import des factures vente : " + ((isDocVenteFacture) ? "activé" : "désactivé") + "\n\n"; msg += "Import des stock : " + ((isDocStock) ? "activé" : "désactivé") + "\n"; label4.Text = msg; } } )); // Start the background process thread backgroundThread.Start(); // Open the dialog progressDialog.ShowDialog(); }