Пример #1
0
        private void btnSupprimer_Click(object sender, RoutedEventArgs e)
        {
            tblParent p = (tblParent)dgParents.SelectedItem;

            myBDD.tblParents.Remove(p);
            try
            {
                myBDD.SaveChanges();
                majDG();
                reinitialiser();
            }
            catch (Exception)
            {
                MessageBox.Show("Erreur suppression parent", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #2
0
        private void dgParents_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (dgParents.SelectedIndex == -1)
            {
                return;
            }

            tblParent p = (tblParent)dgParents.SelectedItem;

            txtNomParent.Text    = p.nom;
            txtPrenomParent.Text = p.prenom;
            txtAdresse.Text      = p.adresse;
            txtVille.Text        = p.ville;
            txtProvince.Text     = p.province;
            txtCP.Text           = p.codePostal;
            txtTelephone.Text    = p.telephone;

            btnAjouter.IsEnabled   = false;
            btnModifier.IsEnabled  = true;
            btnSupprimer.IsEnabled = true;
            btnReini.IsEnabled     = true;
        }
Пример #3
0
        private void btnAjouter_Click(object sender, RoutedEventArgs e)
        {
            if (txtNomParent.Text.Trim() == "" ||
                txtPrenomParent.Text.Trim() == "" ||
                txtAdresse.Text.Trim() == "" ||
                txtVille.Text.Trim() == "" ||
                txtProvince.Text.Trim() == "" ||
                txtCP.Text.Trim() == "" ||
                txtTelephone.Text.Trim() == ""
                )
            {
                MessageBox.Show("Tous les champs doivent etre renseignés", "Champs vides", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            tblParent p = new tblParent();

            p.nom        = txtNomParent.Text;
            p.prenom     = txtPrenomParent.Text;
            p.adresse    = txtAdresse.Text;
            p.ville      = txtVille.Text;
            p.province   = txtProvince.Text;
            p.codePostal = txtCP.Text;
            p.telephone  = txtTelephone.Text;

            myBDD.tblParents.Add(p);
            try
            {
                myBDD.SaveChanges();
                majDG();
                reinitialiser();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erreur enregistrement parent", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }