private void DeleteAppointmentButtonClick(object sender, EventArgs e) { Appointment appointmentToDelete = Calendar.GetAppointmentFromId(selectedAppointmentId); Calendar.DeleteAppointment(ref appointmentToDelete); mainWindow.DrawMonthCalendar(); mainWindow.DrawWeekCalendar(); this.Close(); }
private void EditAppointmentLoad(object sender, EventArgs e) { Appointment appointmentToEdit = Calendar.GetAppointmentFromId(selectedAppointmentId); titleTextBox.Text = appointmentToEdit.Title; descriptionTextBox.Text = appointmentToEdit.Description; startTimePicker.Value = DateTime.Today.Add(appointmentToEdit.StartTime); endTimePicker.Value = DateTime.Today.Add(appointmentToEdit.EndTime); datePicker.Value = appointmentToEdit.Date; InitializeUsersListBox(); SelectInvitedUsers(); }
private void SelectInvitedUsers() { Appointment appointmentToEdit = Calendar.GetAppointmentFromId(selectedAppointmentId); List <string> invitedUsersUsernames = appointmentToEdit.InvitedUsers.Select(user => user.UserName).ToList(); for (int currentIndex = 0; currentIndex < usersListBox.Items.Count; currentIndex++) { if (invitedUsersUsernames.Contains(usersListBox.Items[currentIndex].ToString())) { usersListBox.SetSelected(currentIndex, true); } } }
private void AppointmentsDataGridCellClick(object sender, DataGridViewCellEventArgs e) { DataGridViewRow selectedRow = appointmentsDataGrid.SelectedRows[Constants.MonthCalendarSelectorIndex]; int selectedId = Convert.ToInt32(selectedRow.Cells[0].Value); Appointment selectedAppointment = Calendar.GetAppointmentFromId(selectedId); if (Calendar.CurrentUser.UserName == selectedAppointment.Owner.UserName) { EditAppointment editAppointmentForm = new EditAppointment(this, selectedId); editAppointmentForm.Show(); } else { MessageBox.Show(Constants.NotYourAppointmentMessage); } }
private void EditAppointmentButtonClickUpdateAppointment(object sender, EventArgs e) { Appointment appointmentToEdit = Calendar.GetAppointmentFromId(selectedAppointmentId); appointmentToEdit.Title = titleTextBox.Text; appointmentToEdit.Description = descriptionTextBox.Text; appointmentToEdit.Date = datePicker.Value; appointmentToEdit.StartTime = startTimePicker.Value.TimeOfDay; appointmentToEdit.EndTime = endTimePicker.Value.TimeOfDay; List <User> invitedUsers = new List <User> { }; List <string> selectedUsers = usersListBox.SelectedItems.Cast <string>().ToList(); foreach (string username in selectedUsers) { invitedUsers.Add(Calendar.Users.Find(user => user.UserName == username)); } appointmentToEdit.InvitedUsers = invitedUsers; Calendar.SerializeAppointments(); mainWindow.DrawMonthCalendar(); this.Close(); }