private void edit_Click(object sender, RoutedEventArgs e) //user clicks to edit an assignment { MessageBox.Show("Save changes once they have been made."); if (viewAssignmentList.SelectedItems.Count == 0) { MessageBox.Show("No assignment selected."); return; } Assignment homework = (Assignment)viewAssignmentList.SelectedItems[0]; MyAssignments.Remove(homework); viewAssignmentList.Items.Remove(homework); Classbox.Text = homework.ClassName; Assigntitle.Text = homework.AssignName; notes.Text = homework.Notes; string date = homework.DueDate; string month = ""; string year = ""; string day = ""; int count = 0; foreach (char c in date) { if (count < 2) { month += c; } if (count > 2 && count < 5) { day += c; } if (count > 5) { year += c; } count++; } monthbox.Text = month; daybox.Text = day; yearbox.Text = year; addassign.Content = "Save Changes"; }
private void complete_Click(object sender, RoutedEventArgs e) //user clicks to mark assignments as complete { if (viewAssignmentList.SelectedItems.Count == 0) { MessageBox.Show("No assignment selected."); return; } Assignment homework = (Assignment)viewAssignmentList.SelectedItems[0]; MyAssignments.Remove(homework); viewAssignmentList.Items.Remove(homework); viewCompletedAssignments.Items.Add(homework); Completed.Add(homework); save_completed(); save_to_file(); }
private void delete_Click(object sender, RoutedEventArgs e) //user clicks to delete an assignment { if (viewAssignmentList.SelectedItems.Count == 0) { MessageBox.Show("No assignment selected."); return; } Assignment homework = (Assignment)viewAssignmentList.SelectedItems[0]; MessageBoxResult result = MessageBox.Show("Are you sure you want to delete " + homework.AssignName + " from you assignments?", "Important Message", MessageBoxButton.OKCancel); if (result == MessageBoxResult.Cancel) { return; } MyAssignments.Remove(homework); viewAssignmentList.Items.Remove(homework); save_to_file(); }