private void valid_alert_event(alerte_class alerte)
        {
            methodes meth = new methodes();

            if (addev == null)
            {
                /* if (evenements == null)
                 * {
                 *
                 *  page.Show(); page.set_alarm(alerte); this.Close();
                 * }
                 * else
                 * {*/
                alerte.setidalerte((eve.get_alerte()).getidalerte());
                alerte.setidutilis(eve.getIdUtilis());
                alerte.setidévèn(eve.getId());
                eve.set_alerte(alerte);
                (eve.get_alerte()).Modifier_aler_even_bdd((eve.get_alerte()).getidalerte(), (eve.get_alerte()));
                meth.supprimer_alerte_planifiée(eve.getDesig());
                meth.Creer_tache_planif(alerte, eve.getDesig(), eve.getDate(), "e");

                evenements.clear_listbox();
                evenements.afficher(evenements.get_list());
                this.Close();
                //}
            }
            else
            {
                if (eve.getId() > 0)
                {
                    alerte.setidalerte((eve.get_alerte()).getidalerte());
                    alerte.setidévèn(eve.getId());
                    addev.set_alarm_event(alerte);
                    addev.Show();
                }
                else
                {
                    addev.Show(); addev.set_alarm_event(alerte); this.Close();
                }
                this.Close();
            }
        }
        private void Enregistrer_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(designation.Text) || string.IsNullOrEmpty(Lieu.Text) || string.IsNullOrEmpty(date.Text) || string.IsNullOrEmpty(debut.Text) || string.IsNullOrEmpty(fin.Text))
            {
                er.Visibility = System.Windows.Visibility.Visible;
            }

            else
            {
                DateTime d = Convert.ToDateTime(date.Text + " " + debut.Text);
                DateTime f = Convert.ToDateTime(date.Text + " " + fin.Text);
                if (f < d)
                {
                    erreur.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    methodes m = new methodes();

                    if (eve == null)
                    {      // adition d un nouveau evenement
                        if (m.Exist(d, f, id_user))
                        {
                            System.Windows.MessageBox.Show("occupé");
                        }
                        else
                        {
                            int id_new_event = m.save_event(designation.Text, d, f, Lieu.Text, this.id_user);
                            new_eve.update_event(designation.Text, Lieu.Text, d, f);;
                            new_eve.setId(id_new_event);

                            alerte_class alert = new_eve.get_alerte();

                            if (alert != null)
                            {
                                alert.setidévèn(id_new_event);
                                alert.inserer_alerte_even(alert);
                                m.Creer_tache_planif(alert, new_eve.getDesig(), new_eve.getDate(), "e");
                            }
                            foreach (document doc in list)
                            {
                                m.inserer_document_toevent(doc.getTitre(), doc.getEmplac(), id_user, id_new_event);
                            }
                            page.add_tolist(new_eve);
                            page.clear_listbox();
                            page.afficher(page.get_list());
                            Close();
                        }
                    }
                    else
                    {
                        if (m.Exist_modif_event(d, f, eve.getId(), eve.getId()))
                        {
                            throw new Exception();
                        }
                        else
                        {
                            string olddesignation = eve.getDesig();
                            eve.update_event(designation.Text, Lieu.Text, d, f);
                            m.modifier_evenement(eve);
                            if (eve.get_alerte() != null)
                            {
                                m.modifier_tache_planifiée(eve.get_alerte(), designation.Text, eve.getDate(), olddesignation, "e");
                                (eve.get_alerte()).setidutilis(eve.getIdUtilis());
                                (eve.get_alerte()).Modifier_aler_even_bdd((eve.get_alerte()).getidalerte(), (eve.get_alerte()));
                            }
                            page.clear_listbox();
                            page.afficher(page.get_list());
                            Close();
                        }
                    }
                }
            }
        }