Example #1
0
        private void BtSaveClick(object sender, EventArgs e)
        {
            var appointment = new Appointment
                                  {
                                      DateTimeStart = dtpAppointmentDateStart.Value.Date,
                                      TimeStart = dtpAppointmentTimeStart.Value,
                                      TimeEnd = dtpAppointmentTimeEnd.Value,
                                      Subject = tbSubject.Text,
                                      ReminderTime = dtpReminderTime.Value,
                                      Notes = {NoteText = rtbNotes.Text},
                                      Location =
                                          {
                                              Street = tbStreet.Text,
                                              PostNumber = tbPostnumber.Text,
                                              City = tbCity.Text,
                                              Country = tbCountry.Text
                                          },
                                      TypeOfAppointment = (Appointment.AppointmentType) cbAppoinmentType.SelectedItem,
                                      Company = (Customer) cbCompany.SelectedItem,
                                      TypeOfReminder = (Appointment.ReminderType) cbReminderType.SelectedItem,
                                      ReminderDate = dtpReminderDate.Value.Date,
                                  };

            appointment.ReminderTime = dtpReminderTime.Value;
            if (CheckDateTimeCollision(appointment.TimeStart, appointment.TimeEnd, appointment.DateTimeStart))
            {
                if (tbSubject.Text == "")
                {
                    errorProvider1.SetError(tbSubject, "Please enter subject");
                }

                else
                {
                    errorProvider1.Clear();
                    Controller.AddAppointment(appointment);
                    ClearAppointmentBoxes();
                }
            }

            else
            {
                errorProvider1.SetError(dtpAppointmentDateStart, "Not available date or time, check calendar");
            }

            FileManager.SaveFileAsXml();
        }
Example #2
0
 private void OnEventAdded(Appointment appointment)
 {
     var source = new BindingSource
                      {
                          DataSource =
                              Controller.AllAppointments.ToList().Where(
                                  apointment => apointment.DateTimeStart.Date >= DateTime.Now.Date).ToList()
                      };
     lbEvents.DataSource = source;
 }
Example #3
0
        private void GetAppointmentDetails()
        {
            if (dgvViewAppoinments.SelectedRows.Count > 0)
            {
                _appointmentToEdit =
                    Controller.AllAppointments.Where(
                        appointment =>
                        appointment.Subject == (string) dgvViewAppoinments.SelectedRows[0].Cells["Subject"].Value).First
                        ();

                lbViewAppointmentStartDate.Text = _appointmentToEdit.DateTimeStart.ToShortDateString();
                lbViewAppointmentStartTime.Text = _appointmentToEdit.TimeStart.ToShortTimeString();
                lbViewAppointmentEndTime.Text = _appointmentToEdit.TimeEnd.ToShortTimeString();
                lbViewAppointmentSubject.Text = _appointmentToEdit.Subject;
                rtxbViewAppointmentNote.Text = _appointmentToEdit.Notes.NoteText;
                lbViewAppointmentStreet.Text = _appointmentToEdit.Location.Street;
                lbViewAppointmentCity.Text = _appointmentToEdit.Location.PostNumber;
                lbViewAppointmentCity.Text = _appointmentToEdit.Location.City;
                lbViewAppointmentCountry.Text = _appointmentToEdit.Location.Country;
                lbViewAppointmentType.Text = _appointmentToEdit.TypeOfAppointment.ToString();
                lbViewAppointmentCompany.Text = _appointmentToEdit.Company.ToString();
                lbViewAppointmentReminderType.Text = _appointmentToEdit.TypeOfReminder.ToString();
                lbViewAppointmentReminderDate.Text = _appointmentToEdit.ReminderDate.ToShortDateString();
                lbViewAppointmentReminderTime.Text = _appointmentToEdit.ReminderTime.ToShortTimeString();
                lbViewAppointmentContacts.DataSource = new BindingSource
                                                           {DataSource = _appointmentToEdit.Company.Contacts.ToList()};
            }
        }
Example #4
0
        private void GetSelectedAppointment()
        {
            if (dgvViewAppoinments.SelectedRows.Count > 0)
            {
                _appointmentToEdit =
                    Controller.AllAppointments.Where(
                        appointment =>
                        appointment.Subject == (string) dgvViewAppoinments.SelectedRows[0].Cells["Subject"].Value).First
                        ();

                dtpAppointmentDateStart.Value = _appointmentToEdit.DateTimeStart;
                dtpAppointmentTimeStart.Value = _appointmentToEdit.TimeStart;
                dtpAppointmentTimeStart.Value = _appointmentToEdit.TimeEnd;
                tbSubject.Text = _appointmentToEdit.Subject;
                rtbNotes.Text = _appointmentToEdit.Notes.NoteText;
                dtpReminderTime.Value = _appointmentToEdit.ReminderTime;
                tbStreet.Text = _appointmentToEdit.Location.Street;
                tbPostnumber.Text = _appointmentToEdit.Location.PostNumber;
                tbCity.Text = _appointmentToEdit.Location.City;
                tbCountry.Text = _appointmentToEdit.Location.Country;
                cbAppoinmentType.SelectedItem = _appointmentToEdit.TypeOfAppointment;
                cbCompany.SelectedItem = _appointmentToEdit.Company;
                cbReminderType.SelectedItem = _appointmentToEdit.TypeOfReminder;
                dtpReminderDate.Value = _appointmentToEdit.ReminderDate;
                dtpReminderTime.Value = _appointmentToEdit.ReminderTime;
            }
        }
 public static void AddAppointment(Appointment appointment)
 {
     AllAppointments.Add(appointment);
     if (EventAdded != null)
         EventAdded(appointment);
 }