Example #1
0
        private void BtnSupprimerPersonne_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult messageBoxResult = MessageBox.Show($"Voulez vous vraiment supprimer {(listePersonne.SelectedItem as Personne).Nom} ?", "Supprimer motard ?", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (messageBoxResult == MessageBoxResult.No)
            {
                return;
            }
            Personne unMotard = listePersonne.SelectedItem as Personne;

            DAL.DeletePerson(unMotard.Id);
            listePersonne.ItemsSource = DAL.GetPersonMoto();

            if (listePersonne.Items.Count > 0)
            {
                listePersonne.SelectedIndex = 0;
            }
            else
            {
                listeMoto.Items.Clear();
            }
        }
Example #2
0
        public static List <Cotisation> GetCotisation(Personne motard)
        {
            List <Cotisation> Cotisations = new List <Cotisation>();
            string            sqlQuery    = ($"SELECT * FROM cotisations WHERE personne_id = {motard.Id} ORDER BY annee;");

            SqlCommand    command    = new SqlCommand(sqlQuery, connection);
            SqlDataReader dataReader = command.ExecuteReader();

            if (dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    Cotisation newCotiz = new Cotisation();
                    newCotiz.Annee    = Convert.ToInt32(dataReader["annee"]);
                    newCotiz.Montant  = Convert.ToDouble(dataReader["montant"]);
                    newCotiz.MotardId = Convert.ToInt32(dataReader["personne_id"]);
                    newCotiz.Id       = Convert.ToInt32(dataReader["id"]);
                    Cotisations.Add(newCotiz);
                }
            }
            dataReader.Close();
            command.Dispose();
            return(Cotisations);
        }
 public CotisationsWindow(Personne motard)
 {
     InitializeComponent();
     Motard = motard;
     labelMotard.Content = motard.Nom;
 }
Example #4
0
 public UpdatePersonWindow(Personne selectedPersonne)
 {
     InitializeComponent();
     SelectedPersonne          = selectedPersonne;
     txtbUpdatePersonName.Text = SelectedPersonne.Nom;
 }