private void btnAddStaff_Click(object sender, RoutedEventArgs e) { Medecin M = new Medecin(); M.Nom = txtNom.Text; M.Prenom = txtPrenom.Text; M.Specialite = txtSpecialite.Text; try { if (valida()) { MainWindow.bdHospital.Medecins.Add(M); MainWindow.bdHospital.SaveChanges(); MessageBox.Show("Medecin ajouté", "Succes", MessageBoxButton.OK, MessageBoxImage.Information); txtNom.Text = String.Empty; txtPrenom.Text = String.Empty; txtSpecialite.Text = String.Empty; } else { MessageBox.Show("Tous les champs sont requis", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Erreur", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void cbIdMedecin_SelectionChanged(object sender, SelectionChangedEventArgs e) { Medecin M = ((Medecin)cbIdMedecin.SelectedItem); labInfoNom.Content = M.Nom.ToString(); labInfoPrenom.Content = M.Prenom.ToString(); labInfoSpecialite.Content = M.Specialite.ToString(); }
private void cbIdMedecin_SelectionChanged(object sender, SelectionChangedEventArgs e) { Medecin M = ((Medecin)cbIdMedecin.SelectedItem); txtNom.Text = M.Nom.ToString(); txtPrenom.Text = M.Prenom.ToString(); txtSpecialite.Text = M.Specialite.ToString(); }
private void btnAddStaff_Click(object sender, RoutedEventArgs e) { Medecin M = cbIdMedecin.SelectedItem as Medecin; M.Nom = txtNom.Text; M.Prenom = txtPrenom.Text; M.Specialite = txtSpecialite.Text; try { MainWindow.bdHospital.SaveChanges(); MessageBox.Show("Modification Fait!", "Ajoute Succes", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Erreur", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnDeleteStaff_Click(object sender, RoutedEventArgs e) { Medecin M = ((Medecin)cbIdMedecin.SelectedItem); try { MessageBoxResult res = MessageBox.Show("Vous etes sur de supprimer le medecin ?", "Attention", MessageBoxButton.YesNo, MessageBoxImage.Question); if (res == MessageBoxResult.Yes) { MainWindow.bdHospital.Medecins.Remove(M); MessageBox.Show("Modification Fait!", "Ajoute Succes", MessageBoxButton.OK, MessageBoxImage.Information); MainWindow.bdHospital.SaveChanges(); refresh(); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Erreur", MessageBoxButton.OK, MessageBoxImage.Error); } }