private void dgv_SelectionChanged(object sender, EventArgs e) { try { if (dgv.RowCount > 0) { etudiant = ((clsetudiant)dgv.SelectedRows[0].DataBoundItem); cboPersonne.Text = clsMetier.GetInstance().getClspersonne(etudiant.Id_personne).Nom_complet; cboInscription.Text = clsMetier.GetInstance().getClsinscription1(etudiant.Id_inscription).Designation_complete; txtMatricule.Text = clsMetier.GetInstance().getClsetudiant(etudiant.IdEtudiant).Matricule; cmdModifier.Enabled = true; cmdSupprimer.Enabled = true; } } catch (Exception) { MessageBox.Show("Erreur lors de l'affichage des information de l'étudiant", "Affichage informations de l'étudiant", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } if (dgv.RowCount > 0) { try { photo = clsMetier.GetInstance().getClsphoto(etudiant.IdPers); pbPhoto.Image = (new clsDoTraitement()).getImageFromByte(photo.Photo); } catch (Exception) { pbPhoto.Image = null; } } }
private void cmdSupprimer_Click(object sender, EventArgs e) { try { DialogResult result = MessageBox.Show("Voulez - vous vraiment supprimer cet enregistrement ?", "Suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { etudiant = ((clsetudiant)dgv.SelectedRows[0].DataBoundItem); photo = clsMetier.GetInstance().getClsphoto(etudiant.IdPers); if (dgv.RowCount > 0) { new clsetudiant().delete(etudiant); photo.delete(photo); personne.delete((clspersonne)etudiant); MessageBox.Show("Suppression éffectuée", "Suppression", MessageBoxButtons.OK, MessageBoxIcon.Information); refresh(); } } } catch (Exception ex) { MessageBox.Show("Echec de la suppression " + ex.Message, "Suppression", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }