Esempio n. 1
0
        public static Role unRole(string libelle)
        {
            Role            r = null;
            MySqlDataReader reader;

            open();
            MySqlCommand requete = new MySqlCommand();

            requete.Connection  = conn;
            requete.CommandText = ("SELECT * FROM(role r INNER JOIN profil_role pr ON r.idRole = pr.FK_idRole) INNER JOIN profil p ON pr.FK_idProfil = p.idProfil WHERE libelle = @libelle");
            requete.Parameters.AddWithValue("@libelle", libelle);
            requete.ExecuteNonQuery();
            reader = requete.ExecuteReader();
            while (reader.Read())
            {
                r = new Role(reader.GetInt32("idRole"), reader.GetString("libelle"));
                Profil p = new Profil(reader.GetInt32("idProfil"), reader.GetString("nom"), reader.GetString("prenom"), reader.GetString("mail"), reader.GetString("pseudo"), reader.GetString("mdp"), reader.GetDateTime("DateNaissance"));
                r.getProfils().Add(p);
                p.getRoles().Add(r);
            }
            reader.Close();
            return(r);
        }
        private void btnConnexion_Click(object sender, RoutedEventArgs e)
        {
            menuItemRecruteur.Visibility  = Visibility.Collapsed;
            menuItemEntraineur.Visibility = Visibility.Collapsed;
            menuItemJoueur.Visibility     = Visibility.Collapsed;
            lblCache.Visibility           = Visibility.Visible;


            Profil p = AdoProfil.unProfil(tbxPseudo.Text, pbxMdp.Password);

            if (p != null)
            {
                lblNom.Content           = "Bienvenue" + " " + p.getNom() + " " + p.getPrenom();
                menu.Visibility          = Visibility.Visible;
                gridConnexion.Visibility = Visibility.Hidden;

                foreach (Role r in p.getRoles())
                {
                    if (r.getLibelle().Equals("Admin"))
                    {
                        menuItemRecruteur.Visibility = Visibility.Visible;
                    }
                    if (r.getLibelle().Equals("Educateur"))
                    {
                        menuItemEntraineur.Visibility = Visibility.Visible;
                    }
                    if (r.getLibelle().Equals("Joueur"))
                    {
                        menuItemJoueur.Visibility = Visibility.Visible;
                    }
                }
            }
            else
            {
                MessageBox.Show("Pseudo ou mot de passe incorrect");
            }
        }