Example #1
0
        private void EditApp(IAppointment app)
        {   // this is also somewhat familiar... The difference here is that
            // the appointment has already been created, I just want to change
            // the values a little
            string[] description = app.DisplayableDescription.Split('-');

            bool recuring = false;

            if (description.Length == 3)
            {
                recuring = true;
            }

            Appointment appoint = ConvertCurrent(app);
            int         _occ    = appoint.Occurances;

            if (!Outdated(app.Start))
            {
                AppointmentForm appointment = new AppointmentForm(recuring, app, _occ);
                DialogResult    dr          = appointment.ShowDialog();
                {
                    if (dr == DialogResult.OK)
                    {
                        string   desc  = appointment.GetDesc;
                        DateTime start = appointment.GetStart;
                        int      len   = appointment.GetLen;
                        bool     rec   = CheckRecurs(desc);

                        int occ = 1;
                        if (rec)
                        {
                            occ = appointment.GetOcc;
                        }

                        Appointment newApp = new Appointment(start, len, desc, rec, occ);
                        // the difference here is that it goes out with the old and in with the new
                        _Appointments.Remove(app);
                        _Appointments.Add(newApp);

                        if (!_Appointments.Save())
                        {
                            MessageBox.Show("The appointment Could not be saved," +
                                            "Please ensure that all fields are filled",
                                            "Saving To File", MessageBoxButtons.OK,
                                            MessageBoxIcon.Error);
                        }
                        ResetView();
                    }
                }
            }
        }
Example #2
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Raised by selecting Delete on the content menu


            _Appointments.Remove(_SelectedAppointment);
            RefreshAppointments();
            _Appointments.Save();
        }
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Raised by selecting Edit on the content menu

            // TODO - You need to complete this method.
            // _SelectedAppointment is set to the instance of the appointment to be edited
            if (((Appointment)_SelectedAppointment).TypeRecurring == 0)
            {
                AppointmentSingle eappForm = new AppointmentSingle(_SelectedAppointment, 0, monthCalendar.SelectionStart);
                eappForm.ShowDialog(); // Single Appointment
                if (_SelectedAppointment.Start != eappForm._SelectedAppointment.Start ||
                    _SelectedAppointment.Length != eappForm._SelectedAppointment.Length ||
                    _SelectedAppointment.DisplayableDescription != eappForm._SelectedAppointment.DisplayableDescription ||
                    ((Appointment)_SelectedAppointment).TypeRecurring != ((Appointment)eappForm._SelectedAppointment).TypeRecurring ||
                    ((Appointment)_SelectedAppointment).Times != ((Appointment)eappForm._SelectedAppointment).Times)
                { // If objects are different, we should update table and Save new edited appointment
                    _Appointments.Remove(_SelectedAppointment);
                    _Appointments.Add(eappForm._SelectedAppointment);
                    GetAppointmentsOnSelectedDate(monthCalendar.SelectionRange.Start);
                    // Force repaint of daily view panel
                    panelDailyView.Invalidate();
                    _Appointments.Save();
                }
            }
            else
            {
                AppointmentRec eappForm = new AppointmentRec(_SelectedAppointment, 0, monthCalendar.SelectionStart);
                eappForm.ShowDialog(); // Recurring Appointment
                if (_SelectedAppointment.Start != eappForm._SelectedAppointment.Start ||
                    _SelectedAppointment.Length != eappForm._SelectedAppointment.Length ||
                    _SelectedAppointment.DisplayableDescription != eappForm._SelectedAppointment.DisplayableDescription ||
                    ((Appointment)_SelectedAppointment).TypeRecurring != ((Appointment)eappForm._SelectedAppointment).TypeRecurring ||
                    ((Appointment)_SelectedAppointment).Times != ((Appointment)eappForm._SelectedAppointment).Times)
                { // If objects are different, we should update table and Save new edited appointment
                    _Appointments.Remove(_SelectedAppointment);
                    _Appointments.Add(eappForm._SelectedAppointment);
                    GetAppointmentsOnSelectedDate(monthCalendar.SelectionRange.Start);
                    // Force repaint of daily view panel
                    panelDailyView.Invalidate();
                    _Appointments.Save();
                }
            }
        }
Example #4
0
 private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (_SelectedAppointment.GetType() == typeof(RecurringAppointment))
     {
         DialogResult dialogResult = MessageBox.Show("Delete all recurring appointments?", "Delete Recurring", MessageBoxButtons.YesNo);
         if (dialogResult == DialogResult.No)
         {
             RecurringAppointment comparison = (RecurringAppointment)_SelectedAppointment;
             comparison.OccuringDates.Remove(monthCalendar.SelectionRange.Start.Date);
         }
         else if (dialogResult == DialogResult.Yes)
         {
             _Appointments.Remove(_SelectedAppointment);
         }
     }
     else
     {
         _Appointments.Remove(_SelectedAppointment);
     }
     _SelectedAppointment = null;
     GetAppointmentsOnSelectedDate(monthCalendar.SelectionRange.Start);
     panelDailyView.Invalidate();
 }
Example #5
0
        private void panelDailyView_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            IAppointment appointment = CheckForAppointment(e);

            if (appointment != null)
            {
                _SelectedAppointment = appointment;
                if (_SelectedAppointment is RecurringAppointment)
                {
                    RecurringAppointment     app  = _SelectedAppointment as RecurringAppointment;
                    RecurringAppointmentForm form = new RecurringAppointmentForm(monthCalendar.SelectionRange.Start, app);
                    form.ShowDialog();
                    _Appointments.Remove(_SelectedAppointment);
                    _TodaysAppointments.Remove(_SelectedAppointment);
                    if (form.ReccuringApp == null)
                    {
                        return;
                    }
                    if (_Appointments.Count > 0)
                    {
                        foreach (IAppointment otherappointment in _Appointments)
                        {
                            if (form.ReccuringApp.OccursOnTime(otherappointment.Start, otherappointment.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();
                    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 otherappointment in _Appointments)
                        {
                            if (form.App.OccursOnTime(otherappointment.Start, otherappointment.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;
                }
            }
        }