/// <summary> /// Adds the entry. /// </summary> /// <param name="entry">The entry.</param> private void AddEntry(Entry entry = null) { AddEditEntry newEntry; if (entry == null) { newEntry = new AddEditEntry(controller); } else { newEntry = new AddEditEntry(entry, controller); } if (newEntry.ShowDialog() == true) { try { controller.Manager.AddEntry(newEntry.Entry); } catch (InvalidEntryTimeException) { MessageBox.Show("There is already an entry that occurs at that time", "Invalid Time", MessageBoxButton.OK, MessageBoxImage.Error); AddEntry(newEntry.Entry); return; } catch (EntriesNotInSameMonthException) { MessageBox.Show("All entries must be in the same month", "Invalid month", MessageBoxButton.OK, MessageBoxImage.Error); AddEntry(newEntry.Entry); return; } UpdateGUI(); } }
/// <summary> /// Handles the Click event of the mnuEditEntry control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param> private void MnuEditEntry_Click(object sender, RoutedEventArgs e) { AddEditEntry editEntry = new AddEditEntry((Entry)dataGrid.SelectedItem, controller); try { if (editEntry.ShowDialog() == false) { return; } } catch (InvalidPhaseCodeException) { MessageBox.Show("Invalid phase code entered", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); MnuEditEntry_Click(sender, e); return; } try { controller.Manager.EditEntry(editEntry.Entry); } catch (EntriesNotInSameMonthException) { MessageBox.Show("All entries must be in the same month", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); MnuEditEntry_Click(sender, e); return; } catch (InvalidEntryTimeException) { MessageBox.Show("There is already an entry with that start time", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); MnuEditEntry_Click(sender, e); return; } UpdateGUI(); }