public static void create(Profil profil) { try { open(); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = conn; cmd.CommandText = "INSERT INTO profil(nom,prenom,mail,pseudo,mdp,date_naiss,score,numLicence) VALUES(@nom,@prenom,@mail,@pseudo,@mdp,@date_naiss,@score,@numLicence)"; cmd.Prepare(); cmd.Parameters.AddWithValue("@nom", profil.getNom()); cmd.Parameters.AddWithValue("@prenom", profil.getPrenom()); cmd.Parameters.AddWithValue("@mail", profil.getMail()); cmd.Parameters.AddWithValue("@pseudo", profil.getPseudo()); cmd.Parameters.AddWithValue("@mdp", Encrypt(profil.getMdp())); cmd.Parameters.AddWithValue("@date_naiss", profil.getDateNaiss()); cmd.Parameters.AddWithValue("@score", profil.getScore()); cmd.Parameters.AddWithValue("@numLicence", profil.getNumLicence()); cmd.ExecuteNonQuery(); Console.WriteLine("profil créé"); close(); } catch (MySqlException ex) { Console.WriteLine(ex.Message); } }
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"); } }