private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Raised by selecting Delete on the content menu

            // TODO - You need to complete this method
            // _SelectedAppointment is set to the instance of the appointment to be deleted
            if (_Appointments.Contains(_SelectedAppointment))
            {
                _Appointments.Remove(_SelectedAppointment);
                GetAppointmentsOnSelectedDate(monthCalendar.SelectionRange.Start);
                // Force repaint of daily view panel
                panelDailyView.Invalidate();
                _Appointments.Save();
            }
        }
Exemplo n.º 2
0
        //A lot of this would have been copied, so I thought it prudent to put it in it's own method.
        private bool AddEdit(IAppointment apt)
        {
            //We have to ensure that it's a new appointment before changing the start time.
            if (apt.Start < DateTime.Now && !_Appointments.Contains(apt))
            {
                //Set the Datetime as Now (This will be fixed in the class to be a 30min interval).
                ((Appointment)apt).Start = DateTime.Now;
                //Alert User that you can't add an appointment before the selected date
                //Alternately
            }

            AppointmentForm editForm;

            if (apt.GetType() == typeof(RecurringAppointment))
            {
                editForm = new RecurringForm();
            }
            else
            {
                editForm = new AppointmentForm();
            }
            //Necessary to determine the appropriate times that aren't overlapped.
            //Used to edit the Datasource of Length and StartTime
            //editForm.Apts = _Appointments;
            editForm.Apt = apt;

            if (editForm.ShowDialog() == DialogResult.OK)
            {
                editForm.Close();
                return(true);
            }
            else
            {
                editForm.Close();
                return(false);
            }
        }