Exemple #1
0
        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();
        }
Exemple #2
0
        public ConfigImport()
        {
            InitializeComponent();

            Boolean[] list1 = new Boolean[2];   //List pour activer ou desactiver l'export
            list1[0] = true;
            list1[1] = false;

            string[] list2 = new string[3];     //List des formats d'export
            list2[0] = "";
            list2[1] = "Plat";
            list2[2] = "Véolog";

            string[] list3 = new string[4];     //List des statuts
            list3[0] = "";
            list3[1] = "Saisie";
            list3[2] = "Confirmé";
            list3[3] = "A Préparé";


            // Init les comboBoxs
            for (int i = 0; i < getValuesExport().Length; i++)
            {
                comboBox_import_achats_cmd_active.Items.Add(((list1[i] == true) ? "Activer" : "Désactiver"));
                comboBox_import_achats_dsadv_active.Items.Add(((list1[i] == true) ? "Activer" : "Désactiver"));
                comboBox_import_achats_facture_active.Items.Add(((list1[i] == true) ? "Activer" : "Désactiver"));

                comboBox_import_ventes_cmd_active.Items.Add(((list1[i] == true) ? "Activer" : "Désactiver"));
                comboBox_import_ventes_dsadv_active.Items.Add(((list1[i] == true) ? "Activer" : "Désactiver"));
                comboBox_import_ventes_facture_active.Items.Add(((list1[i] == true) ? "Activer" : "Désactiver"));

                comboBox_import_stock_active.Items.Add(((list1[i] == true) ? "Activer" : "Désactiver"));
            }
            for (int i = 0; i < getFormatExport().Length; i++)
            {
                comboBox_import_achats_cmd_format.Items.Add(list2[i]);
                comboBox_import_achats_dsadv_format.Items.Add(list2[i]);
                comboBox_import_achats_facture_format.Items.Add(list2[i]);

                comboBox_import_ventes_cmd_format.Items.Add(list2[i]);
                comboBox_import_ventes_dsadv_format.Items.Add(list2[i]);
                comboBox_import_ventes_facture_format.Items.Add(list2[i]);

                comboBox_import_stock_format.Items.Add(list2[i]);
            }
            for (int i = 0; i < getStatutExport().GetLength(0); i++)
            {
                comboBox_import_achats_cmd_statut.Items.Add(list3[i]);
                comboBox_import_achats_dsadv_statut.Items.Add(list3[i]);
                comboBox_import_achats_facture_statut.Items.Add(list3[i]);

                comboBox_import_ventes_cmd_statut.Items.Add(list3[i]);
                comboBox_import_ventes_dsadv_statut.Items.Add(list3[i]);
                comboBox_import_ventes_facture_statut.Items.Add(list3[i]);

                comboBox_import_stock_statut.Items.Add(list3[i]);
            }


            Config_Import.ConfigurationSaveLoad settings = new Config_Import.ConfigurationSaveLoad();
            if (settings.isSettings())
            {
                settings.Load();
                Config_Import.Classes.ConfigurationImport configurationImport = settings.configurationImport;

                // Achats
                comboBox_import_achats_cmd_active.Text     = ((Boolean.Parse(configurationImport.Doc_Achat.Commande.Activate)) ? "Activer" : "Désactiver");
                comboBox_import_achats_dsadv_active.Text   = ((Boolean.Parse(configurationImport.Doc_Achat.DSADV.Activate)) ? "Activer" : "Désactiver");
                comboBox_import_achats_facture_active.Text = ((Boolean.Parse(configurationImport.Doc_Achat.Facture.Activate)) ? "Activer" : "Désactiver");

                comboBox_import_achats_cmd_format.Text     = configurationImport.Doc_Achat.Commande.Format;
                comboBox_import_achats_dsadv_format.Text   = configurationImport.Doc_Achat.DSADV.Format;
                comboBox_import_achats_facture_format.Text = configurationImport.Doc_Achat.Facture.Format;

                comboBox_import_achats_cmd_statut.Text     = getStatutName(configurationImport.Doc_Achat.Commande.Status);
                comboBox_import_achats_dsadv_statut.Text   = getStatutName(configurationImport.Doc_Achat.DSADV.Status);
                comboBox_import_achats_facture_statut.Text = getStatutName(configurationImport.Doc_Achat.Facture.Status);

                // Ventes
                comboBox_import_ventes_cmd_active.Text     = ((Boolean.Parse(configurationImport.Doc_Ventes.Commande.Activate)) ? "Activer" : "Désactiver");
                comboBox_import_ventes_dsadv_active.Text   = ((Boolean.Parse(configurationImport.Doc_Ventes.DSADV.Activate)) ? "Activer" : "Désactiver");
                comboBox_import_ventes_facture_active.Text = ((Boolean.Parse(configurationImport.Doc_Ventes.Facture.Activate)) ? "Activer" : "Désactiver");

                comboBox_import_ventes_cmd_format.Text     = configurationImport.Doc_Ventes.Commande.Format;
                comboBox_import_ventes_dsadv_format.Text   = configurationImport.Doc_Ventes.DSADV.Format;
                comboBox_import_ventes_facture_format.Text = configurationImport.Doc_Ventes.Facture.Format;

                comboBox_import_ventes_cmd_statut.Text     = getStatutName(configurationImport.Doc_Ventes.Commande.Status);
                comboBox_import_ventes_dsadv_statut.Text   = getStatutName(configurationImport.Doc_Ventes.DSADV.Status);
                comboBox_import_ventes_facture_statut.Text = getStatutName(configurationImport.Doc_Ventes.Facture.Status);

                // Stock
                comboBox_import_stock_active.Text = ((Boolean.Parse(configurationImport.Doc_Stock.Stock.Activate)) ? "Activer" : "Désactiver");
                comboBox_import_stock_format.Text = configurationImport.Doc_Stock.Stock.Format;
                comboBox_import_stock_statut.Text = getStatutName(configurationImport.Doc_Stock.Stock.Status);
            }
        }