private void EnvoiClick(object sender, RoutedEventArgs e)
        {
            if (TextFirstName.Text != null && TextLastName != null && TextAddress.Text != null &&
                TextCity.Text != null)
            {
                string fonction  = TextAddress.Text;
                string matricule = TextCity.Text;
                string prenom    = TextFirstName.Text;
                string nom       = TextLastName.Text;
                string sexeString;
                if (sexe.Text == "male")
                {
                    sexeString = "M";
                }
                else if (sexe.Text == "femelle")
                {
                    sexeString = "F";
                }
                else
                {
                    sexeString = "A";
                }
                bool flagMatricule = true;

                for (int i = 0; i < Administration.listePersonnel.Count; i++)
                {
                    if (matricule == Convert.ToString(Administration.listePersonnel[i].Matricule))
                    {
                        flagMatricule = false;
                    }
                }

                if (flagMatricule)
                {
                    if (exactitude.IsChecked == true)
                    {
                        try
                        {
                            try
                            {
                                string          connectionString = "SERVER=35.195.241.250; PORT=3306; DATABASE=zombillenium; UID=root; PASSWORD=abcd1234;";
                                MySqlConnection connection       = new MySqlConnection(connectionString);
                                connection.Open();
                                MySqlCommand command = connection.CreateCommand();
                                command.CommandText = "INSERT INTO zombillenium.personnel (fonction, matricule, nom, prenom, sexe) VALUES ('" + fonction + "','" + matricule + "','" + nom + "','" + prenom + "','" + sexeString + "');";

                                MySqlDataReader reader;
                                reader = command.ExecuteReader();

                                if (reader.Read())
                                {
                                    affichage.Text = reader.GetString(0);
                                }
                                else
                                {
                                    affichage.Text = "Personnel ajouté";
                                }


                                connection.Close();
                            }
                            catch
                            {
                                affichage.Text = "Non ajouté à la base de données";
                            }

                            TypeSexe      typeSe       = (TypeSexe)sexe.SelectedItem;
                            int           matriculeInt = Convert.ToInt32(TextCity.Text);
                            Grade         typeGrade    = (Grade)listeGrades.SelectedItem;
                            string        pouvoirs     = listePouvoirs.Text;
                            List <string> pouvoirsList = new List <string>();
                            pouvoirsList = pouvoirs.Split(';').ToList();
                            int cagnotteInt = 0;
                            try { cagnotteInt = Convert.ToInt32(cagnotte.Text); } catch { }

                            List <Attraction> affectationListe = new List <Attraction>();
                            for (int i = 0; i < Administration.listeAttractions.Count; i++)
                            {
                                if (affectation.Text == Administration.listeAttractions[i].Nom)
                                {
                                    if (affectation.Text != "néant")
                                    {
                                        affectationListe.Add(Administration.listeAttractions[i]);
                                        break;
                                    }
                                }
                            }

                            int forceInt = 0;
                            try { forceInt = Convert.ToInt32(nbForce.Value); } catch { }

                            double cruauteDouble = 0;
                            try { cruauteDouble = Convert.ToDouble(nbCruaute.Value); } catch { }

                            double luminDouble = 0;
                            try { luminDouble = Convert.ToDouble(nbLumin.Value); } catch { }

                            int decompInt = 0;
                            try { decompInt = Convert.ToInt32(nbDecomp.Value); } catch { }

                            CouleurZ typeTeint = (CouleurZ)teint.SelectedItem;

                            List <Personnel> list1 = new List <Personnel>();

                            if (affectationListe.Count == 0)
                            {
                                if (typePersonnel.Text == "Sorcier")
                                {
                                    Sorcier perso1 = new Sorcier(pouvoirsList, typeGrade, matriculeInt, nom, prenom, typeSe, fonction);
                                    list1.Add(perso1);
                                }
                                else
                                {
                                    if (typeMonstre.Text == "Demon")
                                    {
                                        Demon perso1 = new Demon(forceInt, Administration.listeAttractions[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                        list1.Add(perso1);
                                    }
                                    else if (typeMonstre.Text == "Fantome")
                                    {
                                        Fantome perso1 = new Fantome(Administration.listeAttractions[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                        list1.Add(perso1);
                                    }
                                    else if (typeMonstre.Text == "LoupGarou")
                                    {
                                        LoupGarou perso1 = new LoupGarou(cruauteDouble, Administration.listeAttractions[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                        list1.Add(perso1);
                                    }
                                    else if (typeMonstre.Text == "Vampire")
                                    {
                                        Vampire perso1 = new Vampire(luminDouble, Administration.listeAttractions[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                        list1.Add(perso1);
                                    }
                                    else if (typeMonstre.Text == "Zombie")
                                    {
                                        Zombie perso1 = new Zombie(decompInt, typeTeint, Administration.listeAttractions[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                        list1.Add(perso1);
                                    }
                                    else
                                    {
                                        Monstre perso1 = new Monstre(true, Administration.listeAttractions[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                        list1.Add(perso1);
                                    }
                                }
                            }
                            else
                            {
                                if (typeMonstre.Text == "Demon")
                                {
                                    Demon perso1 = new Demon(forceInt, affectationListe[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                    list1.Add(perso1);
                                }
                                else if (typeMonstre.Text == "Fantome")
                                {
                                    Fantome perso1 = new Fantome(affectationListe[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                    list1.Add(perso1);
                                }
                                else if (typeMonstre.Text == "LoupGarou")
                                {
                                    LoupGarou perso1 = new LoupGarou(cruauteDouble, affectationListe[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                    list1.Add(perso1);
                                }
                                else if (typeMonstre.Text == "Vampire")
                                {
                                    Vampire perso1 = new Vampire(luminDouble, affectationListe[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                    list1.Add(perso1);
                                }
                                else if (typeMonstre.Text == "Zombie")
                                {
                                    Zombie perso1 = new Zombie(decompInt, typeTeint, affectationListe[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                    list1.Add(perso1);
                                }
                                else
                                {
                                    Monstre perso1 = new Monstre(true, affectationListe[0], cagnotteInt, matriculeInt, nom, prenom, typeSe, fonction);
                                    list1.Add(perso1);
                                }
                            }
                            Administration.listePersonnel.Add(list1[0]);
                            if (affichage.Text != "Non ajouté à la base de données")
                            {
                                affichage.Text = "Personnel ajouté";
                            }
                            else
                            {
                                affichage.Text = "Personnel ajouté au programme, mais pas à la base de données MySQL.";
                            }
                        }

                        catch
                        {
                            MessageBoxResult result = MessageBox.Show("Type de valeur d'entrée incorrect: vérifier les informations saisies.", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                    else
                    {
                        affichage.Text = "Merci de confirmer l'exactitude des informations en cochant la case.";
                    }
                }
                else
                {
                    affichage.Text = "Ce matricule existe déjà. Merci de le changer.";
                }
            }
            else
            {
                affichage.Text = "Veuillez vérifier les informations saisies.";
            }
        }
 private void DG1_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     objEmpToEdit = DG1.SelectedItem as LoupGarou;
 }