[C# - SQL]CRÉER UN LOGICIEL DE GESTION DE COMMANDE

Statut
N'est pas ouverte pour d'autres réponses.

Boosterz'

Premium
Inscription
26 Mai 2015
Messages
455
Réactions
500
Points
4 393
RGCoins
25
IA9FMZ.png

[C# - SQL]CRÉER UN LOGICIEL DE GESTION DE COMMANDE

[TABS]
[TAB=SOMMAIRE]I - Présentation
II - Création des bases de donnée
III - La base du design
IV - Base de donnée
V - Nouvelle commande
VI - Modification, suppression
[/TAB]
[TAB=RESSOURCES]MySQL.Data :

Fichiers SQL :

Notepad++

Code source ( Nécessite DevExpress 15.1.3 )

[/TAB]
[TAB=MUSIQUE]Voila pour lire ce topic je vous met de la musique si vous le voulez.
Vous devez être inscrit pour voir les médias
[/TAB]
[/TABS]
fegF7b.png

I - Présentation
Ce programme a pour but de faire une gestion simplifier de vos commandes en tant que lobbyman, graphiste ou autre.
Il ne faut pas suivre ce tutoriel à la lettre du fait que il est unique à chaque personne ( sauf si vous voulez faire exactement comme moi ) il vous faudra aussi bien éditer le code C# que le code SQL que je vous fournis, voila pourquoi vous aurez besoin de Notepad++.
En fonction de vos besoins vous devez modifier la base de donnée et le code du programme je ne vous direz pas comment car pour moi j'ai suffisamment à expliquer pour ne pas avoir à vous montrez comment modifier la commande SQL. Bien sur si vous êtes vraiment bloqué je vous aiderez ( dans la limite du raisonnable, je ne vous ferez pas votre programme ! ) en message privé.
9PT5iN.png

II - Création des bases de donnée
Donc vous allez devoir créer deux bases de donnée, seulement je vous ai fournis les fichiers .sql, donc le fichier BDDs.sql n'est pas à modifier, mais command.sql vous devez modifié, donc voila ce que vous devez modifié.
9a5257679668df00d07dafb17b7bda62.png

Simplement vous modifiez jeu, mail etc suivant ce que vous voulez mettre.
Ensuite pour le mettre il vous suffit sur le PHPMyAdmin de faire import et de l'importer.
fDJUaF.png

III - La base du design
Donc voila le design que moi j'ai adopté, avec le nom des items important.
Nouvelle commande :
0575091c459804c5cd94ce8329413c93.png

TextBox du numéro de commande : textEdit1
TextBox du jeu : textEdit6
TextBox du mail du compte : textEdit2
TextBox du mot de passe du compte : textEdit3
TextBox moyen de contact : textEdit4
TextBox contact : textEdit5
ComboBox du statut : comboBoxEdit1
listBox non visible : listBox1
dateTimePicker planqué mais visible ! : dateTimePicker1

Modification de commande :
782c784ef6bd7a348db098ca15ffb5b3.png

ListBox : listBoxControl1
Textbox du rechercher : textEdit7
TextBox du jeu : textEdit8
TextBox du mail du compte : textEdit12
TextBox du mot de passe du compte : textEdit11
TextBox moyen de contact : textEdit10
TextBox contact : textEdit9
ComboBox du statut : comboBoxEdit2

Base de donnée ( simple ) :
70925c9c69c4b2a2658e224c226f3e83.png

textBox serveur : textEdit13
textBox database : textEdit14
textBox user : textEdit15
textBox pass : textEdit16
textBox table : textEdit17
CheckBox MultiBase : checkEdit1
listBox multibase : listBoxControl2
textBox serveur multibase : textEdit27
textBox database multibase : textEdit26
textBox user multibase : textEdit25
textBox pass multibase : textEdit24
textBox table multibase : textEdit23
label / de serveur : serveur
label / de database : labelControl24
label / de user : labelControl25
label / de pass : labelControl26
label / de table : labelControl33

Base de donnée ( multiple ) :
e9e151ab16b933d8e3e6f986f31bb423.png

textBox serveur : textEdit22
textBox database : textEdit21
textBox user : textEdit20
textBox pass : textEdit19
textBox table : textEdit18

Donc maintenant à vous de faire votre design en modifiant le nom de vos items ou en modifiant mon code.
DV6tw4.png

IV - Base de donnée
Je vais donc vous balancez les codes pour chaque items, mais avant il vous faut faire deux trois trucs.
Pour commencer dans les paramètres d'application faites comme moi ici :
9860cf2c4d33bce59c4fcf82cce7bc71.png

Ensuite vous ajoutez la référence que je vous ai fournis et on déclare sont utilisation.
Code:
using MySql.Data.MySqlClient;

Voila donc maintenant je vous met purement et simplement du code qui sera souvent le même seul la commande SQL change ..
Au tout début de votre programme vous mettez :
Code:
        string key = "AZERTYUIOPQSDFGHJKLMWXCVBN0123456789";
Ce code sont les caractères qui pourront être dans le numéro de commande.
3e99d69e6fa78db6cc2c6b0df5948188.png


Donc à l'ouverture de la form vous mettez :
Code:
            textEdit22.Text = CommandGestion.Properties.Settings.Default.Mserver;
            textEdit21.Text = CommandGestion.Properties.Settings.Default.Mdata;
            textEdit20.Text = CommandGestion.Properties.Settings.Default.Muser;
            textEdit19.Text = CommandGestion.Properties.Settings.Default.Mpass;
            textEdit18.Text = CommandGestion.Properties.Settings.Default.Mtab;
            textEdit13.Text = CommandGestion.Properties.Settings.Default.Userver;
            textEdit14.Text = CommandGestion.Properties.Settings.Default.Udata;
            textEdit15.Text = CommandGestion.Properties.Settings.Default.Uuser;
            textEdit16.Text = CommandGestion.Properties.Settings.Default.Upass;
            textEdit17.Text = CommandGestion.Properties.Settings.Default.Utab;

            if (CommandGestion.Properties.Settings.Default.check == "Oui")
            {

                checkEdit1.Checked = true;
            }
            else
            {
                checkEdit1.Checked = false;
            }

Dans le bouton de sauvegarde de la base de donnée simple :
Code:
            CommandGestion.Properties.Settings.Default.Userver = textEdit13.Text;
            CommandGestion.Properties.Settings.Default.Udata = textEdit14.Text;
            CommandGestion.Properties.Settings.Default.Uuser = textEdit15.Text;
            CommandGestion.Properties.Settings.Default.Upass = textEdit16.Text;
            CommandGestion.Properties.Settings.Default.Utab = textEdit17.Text;
            CommandGestion.Properties.Settings.Default.Save();
            MessageBox.Show("Base de donnée sauvegardé avec succès !");

Dans celui du multiple :
Code:
            CommandGestion.Properties.Settings.Default.Mserver = textEdit22.Text;
            CommandGestion.Properties.Settings.Default.Mdata = textEdit21.Text;
            CommandGestion.Properties.Settings.Default.Muser = textEdit20.Text;
            CommandGestion.Properties.Settings.Default.Mpass = textEdit19.Text;
            CommandGestion.Properties.Settings.Default.Mtab = textEdit18.Text;
            CommandGestion.Properties.Settings.Default.Save();
            MessageBox.Show("Base de donnée sauvegardé avec succès !");

Ensuite dans la checkBox multibase :
Code:
            if (checkEdit1.Checked == true)
            {
                groupControl4.Visible = true;
                groupControl3.Visible = false;
                CommandGestion.Properties.Settings.Default.check = "Oui";
                CommandGestion.Properties.Settings.Default.Save();

                textEdit8.Text = "";
                textEdit9.Text = "";
                textEdit10.Text = "";
                textEdit11.Text = "";
                textEdit12.Text = "";
                comboBoxEdit2.Text = "";
                listBoxControl1.Items.Clear();
                labelControl24.Text = "/";
                labelControl25.Text = "/";
                labelControl26.Text = "/";
                labelControl33.Text = "/";
            }
            else
            {
                groupControl3.Visible = true;
                groupControl4.Visible = false;
                CommandGestion.Properties.Settings.Default.check = "Non";
                CommandGestion.Properties.Settings.Default.Save();

                textEdit27.Text = "";
                textEdit26.Text = "";
                textEdit25.Text = "";
                textEdit24.Text = "";
                textEdit23.Text = "";
                listBoxControl2.Items.Clear();
                serveur.Text = "/";
                labelControl24.Text = "/";
                labelControl25.Text = "/";
                labelControl26.Text = "/";
                labelControl33.Text = "/";
                textEdit8.Text = "";
                textEdit9.Text = "";
                textEdit10.Text = "";
                textEdit11.Text = "";
                textEdit12.Text = "";
                comboBoxEdit2.Text = "";
                listBoxControl1.Items.Clear();
            }

Dans le bouton refresh :
Code:
            string sDatabaseS = "server=" + CommandGestion.Properties.Settings.Default.Sserver + ";database=" + CommandGestion.Properties.Settings.Default.Sdata + "; userid=" + CommandGestion.Properties.Settings.Default.Suser + "; password=" + CommandGestion.Properties.Settings.Default.Spass;
            string sDatabaseU = "server=" + CommandGestion.Properties.Settings.Default.Userver + ";database=" + CommandGestion.Properties.Settings.Default.Udata + "; userid=" + CommandGestion.Properties.Settings.Default.Uuser + "; password=" + CommandGestion.Properties.Settings.Default.Upass;
            string sDatabaseM = "server=" + CommandGestion.Properties.Settings.Default.Mserver + ";database=" + CommandGestion.Properties.Settings.Default.Mdata + "; userid=" + CommandGestion.Properties.Settings.Default.Muser + "; password=" + CommandGestion.Properties.Settings.Default.Mpass;
            if (checkEdit1.Checked == true)
            {
                listBoxControl2.Items.Clear();
                string myConnection = sDatabaseM;
                MySqlConnection myConn = new MySqlConnection(myConnection);
                myConn.Open();
                MySqlCommand Sql = new MySqlCommand("select `database` from " + CommandGestion.Properties.Settings.Default.Mtab, myConn);
                MySqlDataReader dr;
                dr = Sql.ExecuteReader();
                while (dr.Read())
                {
                    listBoxControl2.Items.Add(dr["database"].ToString());
                }
            }
            else
            {
                MessageBox.Show("Cette fonction n'est disponible que quand en mode MultiBase");
            }

Dans le bouton sélectionner :
Code:
            string sDatabaseS = "server=" + CommandGestion.Properties.Settings.Default.Sserver + ";database=" + CommandGestion.Properties.Settings.Default.Sdata + "; userid=" + CommandGestion.Properties.Settings.Default.Suser + "; password=" + CommandGestion.Properties.Settings.Default.Spass;
            string sDatabaseU = "server=" + CommandGestion.Properties.Settings.Default.Userver + ";database=" + CommandGestion.Properties.Settings.Default.Udata + "; userid=" + CommandGestion.Properties.Settings.Default.Uuser + "; password=" + CommandGestion.Properties.Settings.Default.Upass;
            string sDatabaseM = "server=" + CommandGestion.Properties.Settings.Default.Mserver + ";database=" + CommandGestion.Properties.Settings.Default.Mdata + "; userid=" + CommandGestion.Properties.Settings.Default.Muser + "; password=" + CommandGestion.Properties.Settings.Default.Mpass;
            if (checkEdit1.Checked == true)
            {
                string myConnection = sDatabaseM;
                MySqlConnection myConn = new MySqlConnection(myConnection);
                myConn.Open();
                MySqlCommand Sql = new MySqlCommand("SELECT `id`, `server`, `database`, `user`, `password`, `table` FROM `" + CommandGestion.Properties.Settings.Default.Mtab + "` WHERE `database` = '" + listBoxControl2.SelectedItem + "'", myConn);
                MySqlDataReader dr;
                dr = Sql.ExecuteReader();
                while (dr.Read())
                {
                    serveur.Text = (dr["server"].ToString());
                    labelControl24.Text = (dr["database"].ToString());
                    labelControl25.Text = (dr["user"].ToString());
                    labelControl26.Text = (dr["password"].ToString());
                    labelControl33.Text = (dr["table"].ToString());
                }
                CommandGestion.Properties.Settings.Default.Sserver = serveur.Text;
                CommandGestion.Properties.Settings.Default.Sdata = labelControl24.Text;
                CommandGestion.Properties.Settings.Default.Suser = labelControl25.Text;
                CommandGestion.Properties.Settings.Default.Spass = labelControl26.Text;
                CommandGestion.Properties.Settings.Default.Stab = labelControl33.Text;
                CommandGestion.Properties.Settings.Default.Save();
            }
            else
            {
                MessageBox.Show("Cette fonction n'est disponible que quand en mode MultiBase");
            }

Pour finir dans le bouton ajouter
Code:
            string sDatabaseS = "server=" + CommandGestion.Properties.Settings.Default.Sserver + ";database=" + CommandGestion.Properties.Settings.Default.Sdata + "; userid=" + CommandGestion.Properties.Settings.Default.Suser + "; password=" + CommandGestion.Properties.Settings.Default.Spass;
            string sDatabaseU = "server=" + CommandGestion.Properties.Settings.Default.Userver + ";database=" + CommandGestion.Properties.Settings.Default.Udata + "; userid=" + CommandGestion.Properties.Settings.Default.Uuser + "; password=" + CommandGestion.Properties.Settings.Default.Upass;
            string sDatabaseM = "server=" + CommandGestion.Properties.Settings.Default.Mserver + ";database=" + CommandGestion.Properties.Settings.Default.Mdata + "; userid=" + CommandGestion.Properties.Settings.Default.Muser + "; password=" + CommandGestion.Properties.Settings.Default.Mpass;
            if (checkEdit1.Checked == true)
            {
                    string myConnection2 = sDatabaseM;
                    MySqlConnection myConn2 = new MySqlConnection(myConnection2);
                    MySqlCommand SelectCommand = new MySqlCommand("INSERT INTO `" + CommandGestion.Properties.Settings.Default.Mtab + "`(`server`, `database`, `user`, `password`, `table`) VALUES('" + textEdit27.Text + "', '" + textEdit26.Text + "', '" + textEdit25.Text + "', '" + textEdit24.Text + "', '" + textEdit23.Text + "')", myConn2);
                    MySqlDataReader myReader;
                    myConn2.Open();
                    myReader = SelectCommand.ExecuteReader();

                string myConnection = sDatabaseM;
                MySqlConnection myConn = new MySqlConnection(myConnection);
                myConn.Open();
                MySqlCommand Sql = new MySqlCommand("select `database` from " + CommandGestion.Properties.Settings.Default.Mtab, myConn);
                MySqlDataReader dr;
                dr = Sql.ExecuteReader();
                while (dr.Read())
                {
                    listBoxControl2.Items.Add(dr["database"].ToString());
                }
                listBoxControl2.Items.Clear();
                textEdit27.Text = "";
                textEdit26.Text = "";
                textEdit25.Text = "";
                textEdit24.Text = "";
                textEdit23.Text = "";
            }
            else
            {
                MessageBox.Show("Cette fonction n'est disponible que quand en mode MultiBase");
            }
DV6tw4.png

V - Nouvelle commande
Donc ici il y a deux petits codes.
Le premier pour le bouton générer qui génère le numéro de commande.
Code:
            Random random = new Random();
            textEdit1.Text = "";
            for (int i = 0; i < 15; i++)
            {
                textEdit1.Text += key[random.Next(0, key.Length)];
            }

Le " 15 " étant le nombre de caractères qu'il y aura.
Ensuite le bouton qui sert à créer la commande :
Code:
            string sDatabaseS = "server=" + CommandGestion.Properties.Settings.Default.Sserver + ";database=" + CommandGestion.Properties.Settings.Default.Sdata + "; userid=" + CommandGestion.Properties.Settings.Default.Suser + "; password=" + CommandGestion.Properties.Settings.Default.Spass;
            string sDatabaseU = "server=" + CommandGestion.Properties.Settings.Default.Userver + ";database=" + CommandGestion.Properties.Settings.Default.Udata + "; userid=" + CommandGestion.Properties.Settings.Default.Uuser + "; password=" + CommandGestion.Properties.Settings.Default.Upass;
            string sDatabaseM = "server=" + CommandGestion.Properties.Settings.Default.Mserver + ";database=" + CommandGestion.Properties.Settings.Default.Mdata + "; userid=" + CommandGestion.Properties.Settings.Default.Muser + "; password=" + CommandGestion.Properties.Settings.Default.Mpass;
            if (CommandGestion.Properties.Settings.Default.check == "Oui")
            {
                if (CommandGestion.Properties.Settings.Default.Mtab == "")
                {
                    MessageBox.Show("Formulaire MultiBase non rempli");
                }
                else
                {
                    listBox1.Items.Clear();
                    string myConnection = sDatabaseS;
                    MySqlConnection myConn = new MySqlConnection(myConnection);
                    myConn.Open();
                    MySqlCommand Sql = new MySqlCommand("select number from " + CommandGestion.Properties.Settings.Default.Stab, myConn);
                    MySqlDataReader dr;
                    dr = Sql.ExecuteReader();
                    while (dr.Read())
                    {
                        listBox1.Items.Add(dr["number"].ToString());
                    }
                }
            }
            else
            {
                if (CommandGestion.Properties.Settings.Default.Mtab == "")
                {
                    MessageBox.Show("Formulaire de base non rempli");
                }
                else
                {
                    listBox1.Items.Clear();
                    string myConnection = sDatabaseU;
                    MySqlConnection myConn = new MySqlConnection(myConnection);
                    myConn.Open();
                    MySqlCommand Sql = new MySqlCommand("select number from " + CommandGestion.Properties.Settings.Default.Utab, myConn);
                    MySqlDataReader dr;
                    dr = Sql.ExecuteReader();
                    while (dr.Read())
                    {
                        listBox1.Items.Add(dr["number"].ToString());
                    }
                }
            }
            if (listBox1.Items.Contains(textEdit1.Text))
            {
                MessageBox.Show("Une commande avec ce numéro de commande existe déjà.", "Erreur");
            }
            else
            {
                if (CommandGestion.Properties.Settings.Default.check == "Oui")
                {
                    if (CommandGestion.Properties.Settings.Default.Mtab == "")
                    {
                        MessageBox.Show("Formulaire MultiBase non rempli");
                    }
                    else
                    {
                        string myConnection2 = sDatabaseS;
                        MySqlConnection myConn2 = new MySqlConnection(myConnection2);
                        MySqlCommand SelectCommand = new MySqlCommand("INSERT INTO `" + CommandGestion.Properties.Settings.Default.Stab + "`(`number`, `jeu`, `mail`, `pass`, `contactm`, `contact`, `date`, `statut`) VALUES('" + textEdit1.Text + "', '" + textEdit6.Text + "', '" + textEdit2.Text + "', '" + textEdit3.Text + "', '" + textEdit4.Text + "', '" + textEdit5.Text + "', '" + dateTimePicker1.Text + "', '" + comboBoxEdit1.Text + "')", myConn2);
                        MySqlDataReader myReader;
                        myConn2.Open();
                        myReader = SelectCommand.ExecuteReader();
                        MessageBox.Show("Commande créer avec succès");

                        textEdit1.Text = "";
                        textEdit2.Text = "";
                        textEdit3.Text = "";
                        textEdit4.Text = "";
                        textEdit5.Text = "";
                        textEdit6.Text = "";
                        comboBoxEdit1.Text = "";
                    }
                }
                else
                {
                    string myConnection2 = sDatabaseU;
                    MySqlConnection myConn2 = new MySqlConnection(myConnection2);
                    MySqlCommand SelectCommand = new MySqlCommand("INSERT INTO `" + CommandGestion.Properties.Settings.Default.Utab + "`(`number`, `jeu`, `mail`, `pass`, `contactm`, `contact`, `date`, `statut`) VALUES('" + textEdit1.Text + "', '" + textEdit6.Text + "', '" + textEdit2.Text + "', '" + textEdit3.Text + "', '" + textEdit4.Text + "', '" + textEdit5.Text + "', '" + dateTimePicker1.Text + "', '" + comboBoxEdit1.Text + "')", myConn2);
                    MySqlDataReader myReader;
                    myConn2.Open();
                    myReader = SelectCommand.ExecuteReader();
                    MessageBox.Show("Commande créer avec succès");

                    textEdit1.Text = "";
                    textEdit2.Text = "";
                    textEdit3.Text = "";
                    textEdit4.Text = "";
                    textEdit5.Text = "";
                    textEdit6.Text = "";
                    comboBoxEdit1.Text = "";
                }
            }
DV6tw4.png

VI - Modification, suppression

Donc la dernière partie, donc en premier le bouton Rafraîchir :
Code:
            string sDatabaseS = "server=" + CommandGestion.Properties.Settings.Default.Sserver + ";database=" + CommandGestion.Properties.Settings.Default.Sdata + "; userid=" + CommandGestion.Properties.Settings.Default.Suser + "; password=" + CommandGestion.Properties.Settings.Default.Spass;
            string sDatabaseU = "server=" + CommandGestion.Properties.Settings.Default.Userver + ";database=" + CommandGestion.Properties.Settings.Default.Udata + "; userid=" + CommandGestion.Properties.Settings.Default.Uuser + "; password=" + CommandGestion.Properties.Settings.Default.Upass;
            string sDatabaseM = "server=" + CommandGestion.Properties.Settings.Default.Mserver + ";database=" + CommandGestion.Properties.Settings.Default.Mdata + "; userid=" + CommandGestion.Properties.Settings.Default.Muser + "; password=" + CommandGestion.Properties.Settings.Default.Mpass;
            textEdit8.Text = "";
            textEdit9.Text = "";
            textEdit10.Text = "";
            textEdit11.Text = "";
            textEdit12.Text = "";
            comboBoxEdit2.Text = "";
            listBoxControl1.Items.Clear();

            if (CommandGestion.Properties.Settings.Default.check == "Oui")
            {
                if (CommandGestion.Properties.Settings.Default.Mtab == "")
                {
                    MessageBox.Show("Formulaire MultiBase non rempli");
                }
                else
                {
                    listBoxControl1.Items.Clear();
                    string myConnection = sDatabaseS;
                    MySqlConnection myConn = new MySqlConnection(myConnection);
                    myConn.Open();
                    MySqlCommand Sql = new MySqlCommand("select number from " + CommandGestion.Properties.Settings.Default.Stab, myConn);
                    MySqlDataReader dr;
                    dr = Sql.ExecuteReader();
                    while (dr.Read())
                    {
                        listBoxControl1.Items.Add(dr["number"].ToString());
                    }
                }
            }
            else
            {
                if (CommandGestion.Properties.Settings.Default.Mtab == "")
                {
                    MessageBox.Show("Formulaire de base non rempli");
                }
                else
                {
                    listBoxControl1.Items.Clear();
                    string myConnection = sDatabaseU;
                    MySqlConnection myConn = new MySqlConnection(myConnection);
                    myConn.Open();
                    MySqlCommand Sql = new MySqlCommand("select number from " + CommandGestion.Properties.Settings.Default.Utab, myConn);
                    MySqlDataReader dr;
                    dr = Sql.ExecuteReader();
                    while (dr.Read())
                    {
                        listBoxControl1.Items.Add(dr["number"].ToString());
                    }
                }
            }

Le bouton sélectionner :
Code:
            string sDatabaseS = "server=" + CommandGestion.Properties.Settings.Default.Sserver + ";database=" + CommandGestion.Properties.Settings.Default.Sdata + "; userid=" + CommandGestion.Properties.Settings.Default.Suser + "; password=" + CommandGestion.Properties.Settings.Default.Spass;
            string sDatabaseU = "server=" + CommandGestion.Properties.Settings.Default.Userver + ";database=" + CommandGestion.Properties.Settings.Default.Udata + "; userid=" + CommandGestion.Properties.Settings.Default.Uuser + "; password=" + CommandGestion.Properties.Settings.Default.Upass;
            string sDatabaseM = "server=" + CommandGestion.Properties.Settings.Default.Mserver + ";database=" + CommandGestion.Properties.Settings.Default.Mdata + "; userid=" + CommandGestion.Properties.Settings.Default.Muser + "; password=" + CommandGestion.Properties.Settings.Default.Mpass;

            if (CommandGestion.Properties.Settings.Default.check == "Oui")
            {
                if (CommandGestion.Properties.Settings.Default.Mtab == "")
                {
                    MessageBox.Show("Formulaire MultiBase non rempli");
                }
                else
                {
                    string myConnection = sDatabaseS;
                    MySqlConnection myConn = new MySqlConnection(myConnection);
                    myConn.Open();
                    MySqlCommand Sql = new MySqlCommand("SELECT jeu, mail, pass, contactm, contact, statut FROM " + CommandGestion.Properties.Settings.Default.Stab + " WHERE number='" + listBoxControl1.SelectedItem + "'", myConn);
                    MySqlDataReader dr;
                    dr = Sql.ExecuteReader();
                    while (dr.Read())
                    {
                        textEdit8.Text = (dr["jeu"].ToString());
                        textEdit12.Text = (dr["mail"].ToString());
                        textEdit11.Text = (dr["pass"].ToString());
                        textEdit10.Text = (dr["contactm"].ToString());
                        textEdit9.Text = (dr["contact"].ToString());
                        comboBoxEdit2.Text = (dr["statut"].ToString());
                    }
                }
            }
            else
            {
                if (CommandGestion.Properties.Settings.Default.Mtab == "")
                {
                    MessageBox.Show("Formulaire de base non rempli");
                }
                else
                {
                    string myConnection = sDatabaseU;
                    MySqlConnection myConn = new MySqlConnection(myConnection);
                    myConn.Open();
                    MySqlCommand Sql = new MySqlCommand("SELECT jeu, mail, pass, contactm, contact, statut FROM " + CommandGestion.Properties.Settings.Default.Utab + " WHERE number='" + listBoxControl1.SelectedItem + "'", myConn);
                    MySqlDataReader dr;
                    dr = Sql.ExecuteReader();
                    while (dr.Read())
                    {
                        textEdit8.Text = (dr["jeu"].ToString());
                        textEdit12.Text = (dr["mail"].ToString());
                        textEdit11.Text = (dr["pass"].ToString());
                        textEdit10.Text = (dr["contactm"].ToString());
                        textEdit9.Text = (dr["contact"].ToString());
                        comboBoxEdit2.Text = (dr["statut"].ToString());
                    }
                }
            }

Le bouton rechercher :
Code:
           string sDatabaseS = "server=" + CommandGestion.Properties.Settings.Default.Sserver + ";database=" + CommandGestion.Properties.Settings.Default.Sdata + "; userid=" + CommandGestion.Properties.Settings.Default.Suser + "; password=" + CommandGestion.Properties.Settings.Default.Spass;
            string sDatabaseU = "server=" + CommandGestion.Properties.Settings.Default.Userver + ";database=" + CommandGestion.Properties.Settings.Default.Udata + "; userid=" + CommandGestion.Properties.Settings.Default.Uuser + "; password=" + CommandGestion.Properties.Settings.Default.Upass;
            string sDatabaseM = "server=" + CommandGestion.Properties.Settings.Default.Mserver + ";database=" + CommandGestion.Properties.Settings.Default.Mdata + "; userid=" + CommandGestion.Properties.Settings.Default.Muser + "; password=" + CommandGestion.Properties.Settings.Default.Mpass;
            if (CommandGestion.Properties.Settings.Default.check == "Oui")
            {
                if (CommandGestion.Properties.Settings.Default.Mtab == "")
                {
                    MessageBox.Show("Formulaire MultiBase non rempli");
                }
                else
                {
                    if (listBoxControl1.Items.Contains(textEdit7.Text))
                    {
                        listBoxControl1.SelectedIndex = listBoxControl1.FindString(textEdit7.Text);
                        string myConnection = sDatabaseS;
                        MySqlConnection myConn = new MySqlConnection(myConnection);
                        myConn.Open();
                        MySqlCommand Sql = new MySqlCommand("SELECT jeu, mail, pass, contactm, contact, statut FROM " + CommandGestion.Properties.Settings.Default.Stab + " WHERE number='" + listBoxControl1.SelectedItem + "'", myConn);
                        MySqlDataReader dr;
                        dr = Sql.ExecuteReader();
                        while (dr.Read())
                        {
                            textEdit8.Text = (dr["jeu"].ToString());
                            textEdit12.Text = (dr["mail"].ToString());
                            textEdit11.Text = (dr["pass"].ToString());
                            textEdit10.Text = (dr["contactm"].ToString());
                            textEdit9.Text = (dr["contact"].ToString());
                            comboBoxEdit2.Text = (dr["statut"].ToString());
                        }
                    }
                    else
                    {
                        MessageBox.Show("Commande non trouvée, avez vous bien actualiser la liste ?");
                    }
                }
            }
            else
            {
                if (CommandGestion.Properties.Settings.Default.Mtab == "")
                {
                    MessageBox.Show("Formulaire de base non rempli");
                }
                else
                {
                    if (listBoxControl1.Items.Contains(textEdit7.Text))
                    {
                        listBoxControl1.SelectedIndex = listBoxControl1.FindString(textEdit7.Text);
                        string myConnection = sDatabaseU;
                        MySqlConnection myConn = new MySqlConnection(myConnection);
                        myConn.Open();
                        MySqlCommand Sql = new MySqlCommand("SELECT jeu, mail, pass, contactm, contact, statut FROM " + CommandGestion.Properties.Settings.Default.Utab + " WHERE number='" + listBoxControl1.SelectedItem + "'", myConn);
                        MySqlDataReader dr;
                        dr = Sql.ExecuteReader();
                        while (dr.Read())
                        {
                            textEdit8.Text = (dr["jeu"].ToString());
                            textEdit12.Text = (dr["mail"].ToString());
                            textEdit11.Text = (dr["pass"].ToString());
                            textEdit10.Text = (dr["contactm"].ToString());
                            textEdit9.Text = (dr["contact"].ToString());
                            comboBoxEdit2.Text = (dr["statut"].ToString());
                        }
                    }
                    else
                    {
                        MessageBox.Show("Commande non trouvée, avez vous bien actualiser la liste ?");
                    }
                }
            }

Le bouton modifier :
Code:
           string sDatabaseS = "server=" + CommandGestion.Properties.Settings.Default.Sserver + ";database=" + CommandGestion.Properties.Settings.Default.Sdata + "; userid=" + CommandGestion.Properties.Settings.Default.Suser + "; password=" + CommandGestion.Properties.Settings.Default.Spass;
            string sDatabaseU = "server=" + CommandGestion.Properties.Settings.Default.Userver + ";database=" + CommandGestion.Properties.Settings.Default.Udata + "; userid=" + CommandGestion.Properties.Settings.Default.Uuser + "; password=" + CommandGestion.Properties.Settings.Default.Upass;
            string sDatabaseM = "server=" + CommandGestion.Properties.Settings.Default.Mserver + ";database=" + CommandGestion.Properties.Settings.Default.Mdata + "; userid=" + CommandGestion.Properties.Settings.Default.Muser + "; password=" + CommandGestion.Properties.Settings.Default.Mpass;
            if (CommandGestion.Properties.Settings.Default.check == "Oui")
            {
                if (CommandGestion.Properties.Settings.Default.Mtab == "")
                {
                    MessageBox.Show("Formulaire MultiBase non rempli");
                }
                else
                {
                    string myConnection = sDatabaseS;
                    MySqlConnection myConn = new MySqlConnection(myConnection);
                    MySqlCommand SelectCommand = new MySqlCommand("UPDATE " + CommandGestion.Properties.Settings.Default.Stab + " SET jeu = ' " + textEdit8.Text + " ', mail = ' " + textEdit12.Text + " ', pass = ' " + textEdit11.Text + " ', contactm = ' " + textEdit10.Text + " ', contact = ' " + textEdit9.Text + "'" + ", statut= ' " + comboBoxEdit2.Text + " ' WHERE number = '" + listBoxControl1.SelectedItem + "'", myConn);
                    MySqlDataReader myReader;
                    myConn.Open();
                    myReader = SelectCommand.ExecuteReader();
                    MessageBox.Show("Commande modifier avec succès.");
                }
            }
            else
            {

                if (CommandGestion.Properties.Settings.Default.Mtab == "")
                {
                    MessageBox.Show("Formulaire de base non rempli");
                }
                else
                {
                    string myConnection = sDatabaseU;
                    MySqlConnection myConn = new MySqlConnection(myConnection);
                    MySqlCommand SelectCommand = new MySqlCommand("UPDATE " + CommandGestion.Properties.Settings.Default.Utab + " SET jeu = ' " + textEdit8.Text + " ', mail = ' " + textEdit12.Text + " ', pass = ' " + textEdit11.Text + " ', contactm = ' " + textEdit10.Text + " ', contact = ' " + textEdit9.Text + "'" + ", statut= ' " + comboBoxEdit2.Text + " ' WHERE number = '" + listBoxControl1.SelectedItem + "'", myConn);
                    MySqlDataReader myReader;
                    myConn.Open();
                    myReader = SelectCommand.ExecuteReader();
                    MessageBox.Show("Commande modifier avec succès.");
                }
            }

Pour finir le bouton supprimer :
Code:
            string sDatabaseS = "server=" + CommandGestion.Properties.Settings.Default.Sserver + ";database=" + CommandGestion.Properties.Settings.Default.Sdata + "; userid=" + CommandGestion.Properties.Settings.Default.Suser + "; password=" + CommandGestion.Properties.Settings.Default.Spass;
            string sDatabaseU = "server=" + CommandGestion.Properties.Settings.Default.Userver + ";database=" + CommandGestion.Properties.Settings.Default.Udata + "; userid=" + CommandGestion.Properties.Settings.Default.Uuser + "; password=" + CommandGestion.Properties.Settings.Default.Upass;
            string sDatabaseM = "server=" + CommandGestion.Properties.Settings.Default.Mserver + ";database=" + CommandGestion.Properties.Settings.Default.Mdata + "; userid=" + CommandGestion.Properties.Settings.Default.Muser + "; password=" + CommandGestion.Properties.Settings.Default.Mpass;
            if (CommandGestion.Properties.Settings.Default.check == "Oui")
            {
                if (CommandGestion.Properties.Settings.Default.Mtab == "")
                {
                    MessageBox.Show("Formulaire MultiBase non rempli");
                }
                else
                {
                    string myConnection = sDatabaseS;
                    MySqlConnection myConn = new MySqlConnection(myConnection);
                    MySqlCommand SelectCommand = new MySqlCommand("DELETE FROM " + CommandGestion.Properties.Settings.Default.Stab + " WHERE number='" + listBoxControl1.SelectedItem + "'", myConn);
                    MySqlDataReader myReader;
                    myConn.Open();
                    myReader = SelectCommand.ExecuteReader();
                    myConn.Close();
                    MessageBox.Show("Commande supprimer avec succès.");


                    listBoxControl1.Items.Clear();
                    string myConnection2 = sDatabaseS;
                    MySqlConnection myConn2 = new MySqlConnection(myConnection2);
                    myConn2.Open();
                    MySqlCommand Sql = new MySqlCommand("select number from " + CommandGestion.Properties.Settings.Default.Stab, myConn2);
                    MySqlDataReader dr;
                    dr = Sql.ExecuteReader();
                    while (dr.Read())
                    {
                        listBoxControl1.Items.Add(dr["number"].ToString());
                    }
                    textEdit8.Text = "";
                    textEdit9.Text = "";
                    textEdit10.Text = "";
                    textEdit11.Text = "";
                    textEdit12.Text = "";
                    comboBoxEdit2.Text = "";
                }
            }
            else
            {
                if (CommandGestion.Properties.Settings.Default.Mtab == "")
                {
                    MessageBox.Show("Formulaire de base non rempli");
                }
                else
                {
                    string myConnection = sDatabaseU;
                    MySqlConnection myConn = new MySqlConnection(myConnection);
                    MySqlCommand SelectCommand = new MySqlCommand("DELETE FROM " + CommandGestion.Properties.Settings.Default.Utab + " WHERE number='" + listBoxControl1.SelectedItem + "'", myConn);
                    MySqlDataReader myReader;
                    myConn.Open();
                    myReader = SelectCommand.ExecuteReader();
                    myConn.Close();
                    MessageBox.Show("Commande supprimer avec succès.");


                    listBoxControl1.Items.Clear();
                    string myConnection2 = sDatabaseU;
                    MySqlConnection myConn2 = new MySqlConnection(myConnection2);
                    myConn2.Open();
                    MySqlCommand Sql = new MySqlCommand("select number from " + CommandGestion.Properties.Settings.Default.Utab, myConn2);
                    MySqlDataReader dr;
                    dr = Sql.ExecuteReader();
                    while (dr.Read())
                    {
                        listBoxControl1.Items.Add(dr["number"].ToString());
                    }
                    textEdit8.Text = "";
                    textEdit9.Text = "";
                    textEdit10.Text = "";
                    textEdit11.Text = "";
                    textEdit12.Text = "";
                    comboBoxEdit2.Text = "";
                }
            }
dTgb84.png

Je ne suis pas ici pour vous apprendre à coder mais pour vous fournir mon travail afin que vous le modifier à votre guise.
Merci à @Baptiste pour m'avoir aidé sur un petit point.
Malgré tout je suis disponible en privé pour vous aidé un peu et vous expliqué.​
 
Topic beau et bien rédigée, malheuresement je n'apelle pas vraiment sa un tuto, c'est plutôt un mode d'emplois car tu n'explique rien ^^'
 
Topic beau et bien rédigée, malheuresement je n'apelle pas vraiment sa un tuto, c'est plutôt un mode d'emplois car tu n'explique rien ^^'

Je ne suis pas ici pour vous apprendre à coder mais pour vous fournir mon travail afin que vous le modifier à votre guise.

C'est à l'utilisateur de modifier à sa guise étant donné que c'est censé être unique à chaque personne. De plus c'est tout le temps le même code seul la commande SQL change :)
 
pas obligatoire l'utilisation du SQL ;) http://reality-gaming.fr/threads/release-agenda-de-commande-1-02-by-monsteurkill.387912/
 
Statut
N'est pas ouverte pour d'autres réponses.
Retour
Haut