Exemple #1
0
 private void NewSingleEntry()
 {
     using (SingleAppointmentForm newAppointmentForm = new SingleAppointmentForm(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();
         }
     }
 }
Exemple #2
0
        private void NewSingleEntry()
        {
            if (monthCalendar.SelectionRange.Start.Date < System.DateTime.Now.Date)
            {
                MessageBox.Show("Error adding past appointments to the callendar", "Invalid date", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            AppointmentFrontEnd form = new AppointmentFrontEnd(monthCalendar.SelectionRange.Start);

            form.ShowDialog();

            if (form.Appointment == null)
            {
                return;
            }
            if (_todaysEntries.Count > 0)
            {
                foreach (ICalendarEntry s_appointment in _calendarEntries)
                {
                    // Case handler for overriding appointments
                    // that have the same time or date
                    // even a passed appointment
                    if (form.Appointment.ConflictExceptionHandler(s_appointment.Start, s_appointment.Length))
                    {
                        MessageBox.Show("There is an another appointment at current time ",
                                        "Error adding current appointment",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Warning);
                        return;
                    }
                }
            }
            //Saving the appointment via StreamReader
            // in a txt file
            _calendarEntries.Add(form.Appointment);
            _todaysEntries.Add(form.Appointment);
            SaveCalendarEntries();
        }