/// <summary> /// Méthode de connexion /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnLogin_Click(object sender, RoutedEventArgs e) { // Déclaration et attribution des variables string password = passwordboxLoginPassword.Password.ToString(); string mail = textboxLoginMail.Text; // Execution de la requete afin de récuperer id de utilisateur si il existe string login = Users.Login(mail, password); // Si requete ne renvoie pas null ou rien if (!String.IsNullOrEmpty(login)) { // On stock le login dans une attribut de la classe Users Users.IdUserConnected = int.Parse(login); textblockErrorLogin.Text = "Identifiants réussi"; // Instanciation de la fênetre profil profil profilWindow = new profil(); // Affichage de la fênetre profil profilWindow.Show(); // Fermeture de la fênetre actuelle this.Close(); } else { textblockErrorLogin.Text = "Identifiants incorrect"; } }
public void InsertProfil(profilDB profl) { using (DataAccesDataContext dbContext = new DataAccesDataContext()) { profil profil = new profil { code_profil = profl.code, description_profil = profl.libelle }; dbContext.profil.InsertOnSubmit(profil); dbContext.SubmitChanges(); } }
private void btnAjouter_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(textLibelle.Text)) { MessageBox.Show("le libellé est obligatoires", "Message Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { profil profil = new profil() { libelle = textLibelle.Text.Trim(), }; if (metier.CreerProfil(profil)) { MessageBox.Show("Classe créer avec succès", "Message Information", MessageBoxButtons.OK, MessageBoxIcon.Information); textLibelle.Clear(); LoadDataGridView(); } } }
public bool CreerProfil(profil profil) { ctx.profil.Add(profil); return(ctx.SaveChanges() != 0); }