Exemple #1
0
        private void SelectSession(object sender, RoutedEventArgs e)
        {
            try
            {
                LBSession.Items.Clear();
                TBNbPlace.Clear();
                TBDuree.Clear();
                DPSession.Text = "";


                var req = from f in db.Formations
                          join s in db.Sessions
                          on f.idFormation equals s.idFormation
                          where f.nom == LBFormation.SelectedItem.ToString()
                          select s.nom;

                foreach (var item in req)
                {
                    LBSession.Items.Add(item);
                }
            }
            catch (Exception)
            {
            }
        }
Exemple #2
0
        private void btnAjoutSess_Click(object sender, RoutedEventArgs e)
        {
            if (LBFormation.SelectedIndex >= 0)
            {
                var req = from f in db.Formations
                          where f.nom == LBFormation.SelectedItem.ToString()
                          select f.idFormation;

                var session = new Session()
                {
                    nom         = TBoxAjoutSess.Text,
                    date        = Convert.ToDateTime(DPAjoutSession.Text),
                    duree       = int.Parse(TBoxAjoutDuree.Text),
                    nbPlace     = int.Parse(TBoxAjoutNbPlace.Text),
                    idFormation = req.First()
                };


                db.Sessions.Add(session);
                db.SaveChanges();

                try
                {
                    LBSession.Items.Clear();
                    TBNbPlace.Clear();
                    TBDuree.Clear();
                    DPSession.Text = "";


                    var req2 = from f in db.Formations
                               join s in db.Sessions
                               on f.idFormation equals s.idFormation
                               where f.nom == LBFormation.SelectedItem.ToString()
                               select s.nom;

                    foreach (var item in req2)
                    {
                        LBSession.Items.Add(item);
                    }
                }catch (Exception) {}
            }
            else
            {
                MessageBox.Show("Veuillez Selectionner une Formation");
            }
        }
Exemple #3
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            if (LBSession.SelectedIndex >= 0)
            {
                MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Etes-vous sûr de vouloir supprimer cette session ?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo);
                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    var delete = db.Sessions.First(s => s.nom == LBSession.SelectedItem.ToString());

                    db.Sessions.Remove(delete);

                    db.SaveChanges();

                    LBSession.Items.Clear();
                    TBNbPlace.Clear();
                    TBDuree.Clear();
                    DPSession.Text = "";

                    var req = from f in db.Formations
                              join s in db.Sessions
                              on f.idFormation equals s.idFormation
                              where f.nom == LBFormation.SelectedItem.ToString()
                              select s.nom;


                    foreach (var item in req)
                    {
                        LBSession.Items.Add(item);
                    }
                }
            }
            else
            {
                MessageBox.Show("Veuillez selectionner une session pour pouvoir la supprimer");
            }
        }