private void ModifierEvent(object sender, MouseButtonEventArgs e)
        {
            if (TextboxTitre.Text == "")
            {
                TextboxTitre.Focus();
            }
            else if (TextBoxLieu.Text == "")
            {
                TextBoxLieu.Focus();
            }
            else if (debutDatePicker.SelectedDate == null || finDatePicker.SelectedDate == null || Heure.SelectedTime == null)
            {
                MessageBox.Show("Veuillez choisir la date exacte");
                return;
            }
            else if ((ComboBoxPriorite.SelectedIndex != 0) && (ComboBoxPriorite.SelectedIndex != 1) && (ComboBoxPriorite.SelectedIndex != 2))
            {
                MessageBox.Show("Veuillez choisir la priorité");
            }
            else
            {
                DateTime dt = debutDatePicker.SelectedDate.Value;
                DateTime tm = Heure.SelectedTime.Value;
                t.DateDebut   = new DateTime(dt.Year, dt.Month, dt.Day, tm.Hour, tm.Minute, tm.Second);
                t.DateFin     = finDatePicker.SelectedDate.Value;
                t.Title       = TextboxTitre.Text;
                t.Description = TextBoxDescription.Text;
                switch (ComboBoxPriorite.SelectedIndex)
                {
                case 0:
                    t.Priority = "Urgente";
                    break;

                case 1:
                    t.Priority = "Normale";
                    break;

                case 2:
                    t.Priority = "Basse";
                    break;
                }
                t.activite = (string)((ComboBoxItem)ComboBoxActivities.SelectedItem).DataContext;
                t.Alarms   = new List <Notif>();
                foreach (Notif n in NotificationDict.Values)
                {
                    t.Alarms.Add(n);
                }
                DataSupervisor.ds.MonthData.StoreData();
                MainWindow.UpdateFields();
                this.Close();
            }
        }
Example #2
0
        private void AddEvent(object sender, MouseButtonEventArgs e)
        {
            if (TextboxTitre.Text == "")
            {
                TextboxTitre.Focus();
            }
            else if (TextBoxLieu.Text == "")
            {
                TextBoxLieu.Focus();
            }
            else if (debutDatePicker.SelectedDate == null || finDatePicker.SelectedDate == null || Heure.SelectedTime == null)
            {
                MessageBox.Show("Veuillez choisir la date exacte");
                return;
            }
            else if ((ComboBoxPriorite.SelectedIndex != 0) && (ComboBoxPriorite.SelectedIndex != 1) && (ComboBoxPriorite.SelectedIndex != 2))
            {
                MessageBox.Show("Veuillez choisir la priorité");
            }
            else if (((string)((ComboBoxItem)ComboBoxActivities.SelectedItem).DataContext) == "Activité scolaire" && DataSupervisor.ds.user.JoursFeries.Keys.Contains(debutDatePicker.SelectedDate.Value))
            {
                MessageBox.Show("Le jour choisit est ferie");
            }
            else
            {
                Evenement ev = new Evenement();
                DateTime  d  = new DateTime(debutDatePicker.SelectedDate.Value.Year, debutDatePicker.SelectedDate.Value.Month, debutDatePicker.SelectedDate.Value.Day, Heure.SelectedTime.Value.Hour, Heure.SelectedTime.Value.Minute, Heure.SelectedTime.Value.Second);
                ev.DateDebut   = d;
                ev.DateFin     = finDatePicker.SelectedDate.Value;
                ev.Title       = TextboxTitre.Text;
                ev.Description = TextBoxDescription.Text;
                ev.place       = TextBoxLieu.Text;
                switch (cpt_files)
                {
                case 1:
                    ev.Fichiers.Add((String)File1.Content);
                    break;

                case 2:
                    ev.Fichiers.Add((String)File1.ContentStringFormat);
                    ev.Fichiers.Add((String)File2.ContentStringFormat);
                    break;

                case 3:
                    ev.Fichiers.Add((String)File1.ContentStringFormat);
                    ev.Fichiers.Add((String)File2.ContentStringFormat);
                    ev.Fichiers.Add((String)File3.ContentStringFormat);
                    break;

                default:
                    break;
                }
                switch (ComboBoxPriorite.SelectedIndex)
                {
                case 0:
                    ev.Priority = "Urgente";
                    break;

                case 1:
                    ev.Priority = "Normale";
                    break;

                case 2:
                    ev.Priority = "Basse";
                    break;
                }
                ev.activite = (string)((ComboBoxItem)ComboBoxActivities.SelectedItem).DataContext;
                ev.Alarms   = new List <Notif>();
                foreach (Notif n in NotificationDict.Values)
                {
                    ev.Alarms.Add(n);
                }
                DataSupervisor.ds.AddEvenement(ev);
                windowParent.Close();
            }
        }