public void SupprimerAdherentSucces() { serviceAdherents.Supprimer(adherent.Id); using (ISession session = sessionFactory.OpenSession()) { Adherent ad = session.Get <Adherent>(adherent.Id); Assert.IsNull(ad); } }
private void buttonSupprimerAdherent_Click(object sender, EventArgs e) { if (listBoxAdherents.Items.Count == 0) { return; } int idxAdherent = listBoxAdherents.SelectedIndex; Adherent adherent = serviceAdherents.ObtenirListe()[idxAdherent]; DialogResult res = MessageBox.Show(adherent.ToString(), "Valider suppression?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { try { serviceAdherents.Supprimer(adherent.Id); ActualiserAdherents(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Suppression échoué", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void buttonSupprimerAdherent_Click(object sender, EventArgs e) { string selectedTxt = listBoxAdherents.SelectedItem as string; Adherent adherent = adherents .Find(a => a.ToString() == selectedTxt); if (adherent != null) { if (MessageBox.Show("Etes-vous certain de supprimer :" + adherent.Nom + " ?", "Suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { try { serviceAdherents.Supprimer(adherent); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erreur suppression", MessageBoxButtons.OK, MessageBoxIcon.Error); } Actualiser(); } } else { MessageBox.Show("Vous devez selectionner un adhérent", "Erreur : Absence de selection d'un adhérent", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }