示例#1
0
        private void NewRecurringAppointment()
        {
            if (monthCalendar.SelectionRange.Start.Date < System.DateTime.Now.Date)
            {
                MessageBox.Show("Cannot add past appointments to the callendar", "Invalid date", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            RecurringAppointmentForm form = new RecurringAppointmentForm(monthCalendar.SelectionRange.Start.Date);

            form.ShowDialog();
            if (form.ReccuringApp == null)
            {
                return;
            }
            if (_Appointments.Count > 0)
            {
                foreach (IAppointment app in _Appointments)
                {
                    if (form.ReccuringApp.OccursOnTime(app.Start, app.Length))
                    {
                        MessageBox.Show("Date and Time already used at " + app.Start.ToLongDateString(),
                                        "Cannot add current recurring appointment",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Warning);
                        return;
                    }
                }
            }
            _Appointments.Add(form.ReccuringApp);
            _TodaysAppointments.Add(form.ReccuringApp);
            panelDailyView.Invalidate();
        }
示例#2
0
 private void NewRecurringEntry()
 {
     using (RecurringAppointmentForm newAppointmentForm = new RecurringAppointmentForm(monthCalendar.SelectionRange.Start))
     {
         if (newAppointmentForm.ShowDialog() == DialogResult.OK)
         {
             // Add the entry that was created in the dialog, refresh the entries on selected date list.
             // Save all entries.
             // Invaidate the daily view in case the entry that was added was for the day being viewed.
             _calendarEntries.Add(newAppointmentForm.Entry);
             RefreshDailyView();
         }
     }
 }
示例#3
0
 private void editEntry(ICalendarEntry entry)
 {
     if (entry.GetType() == typeof(RecurringCalendarEntry))
     {
         using (RecurringAppointmentForm newAppointmentForm = new RecurringAppointmentForm((RecurringCalendarEntry)entry))
         {
             if (newAppointmentForm.ShowDialog() == DialogResult.OK)
             {
                 RefreshDailyView();
             }
         }
     }
     else if (entry.GetType() == typeof(SingleCalendarEntry))
     {
         using (SingleAppointmentForm newAppointmentForm = new SingleAppointmentForm((SingleCalendarEntry)entry))
         {
             if (newAppointmentForm.ShowDialog() == DialogResult.OK)
             {
                 RefreshDailyView();
             }
         }
     }
 }
示例#4
0
 private void editToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (_SelectedAppointment is RecurringAppointment)
     {
         RecurringAppointment     app  = _SelectedAppointment as RecurringAppointment;
         RecurringAppointmentForm form = new RecurringAppointmentForm(monthCalendar.SelectionRange.Start, app);
         form.ShowDialog();
         _Appointments.Remove(app);
         _TodaysAppointments.Remove(app);
         if (form.ReccuringApp == null)
         {
             return;
         }
         if (_Appointments.Count > 0)
         {
             foreach (IAppointment appointment in _Appointments)
             {
                 if (form.ReccuringApp.OccursOnTime(appointment.Start, appointment.Length))
                 {
                     MessageBox.Show("Date and Time already used at" + appointment.Start.ToLongDateString(),
                                     "Cannot add current appointment",
                                     MessageBoxButtons.OK,
                                     MessageBoxIcon.Warning);
                     return;
                 }
             }
         }
         _Appointments.Add(form.ReccuringApp);
         _TodaysAppointments.Add(form.ReccuringApp);
         panelDailyView.Invalidate();
         return;
     }
     if (_SelectedAppointment is Appointment)
     {
         Appointment     app  = _SelectedAppointment as Appointment;
         AppointmentForm form = new AppointmentForm(monthCalendar.SelectionRange.Start, app);
         form.ShowDialog();
         if (form.App == null)
         {
             return;
         }
         if (_Appointments.Count > 0)
         {
             foreach (IAppointment appointment in _Appointments)
             {
                 if (form.App.OccursOnTime(appointment.Start, appointment.Length))
                 {
                     MessageBox.Show("Date and Time already used",
                                     "Cannot add current appointment",
                                     MessageBoxButtons.OK,
                                     MessageBoxIcon.Warning);
                     return;
                 }
             }
         }
         _Appointments.Remove(app);
         _TodaysAppointments.Remove(app);
         _Appointments.Add(form.App);
         _TodaysAppointments.Add(form.App);
         panelDailyView.Invalidate();
         return;
     }
 }