diff --git a/src/ManageParticipantsControl.cs b/src/ManageParticipantsControl.cs index b4651c71a72b562c9b4c21e94a2c60e9a79b63fb..24982d6d0ee1baa53fb661d82decb1ec38f73096 100644 --- a/src/ManageParticipantsControl.cs +++ b/src/ManageParticipantsControl.cs @@ -34,18 +34,11 @@ namespace TournamentManager.src private void btnRemove_Click(object sender, EventArgs e) { - if (SelectedItemIsNull(out var selected, ParticipantError)) - return; - - cbParticipants.Items.Remove(selected); - - OnParticipantsModified(new ParticipantsModifiedEventArgs( - selected.ToString(), - OperationType.Remove)); - - cbParticipants.ResetText(); + ManageButtonClick(); } + + private void btnEdit_Click(object sender, EventArgs e) { if (SelectedItemIsNull(out var selected, ParticipantError)) @@ -59,6 +52,21 @@ namespace TournamentManager.src } #region helperFunctions + + private void ManageButtonClick() + { + if (SelectedItemIsNull(out var selected, ParticipantError)) + return; + + cbParticipants.Items.Remove(selected); + + OnParticipantsModified(new ParticipantsModifiedEventArgs( + selected.ToString(), + OperationType.Remove)); + + cbParticipants.ResetText(); + } + private bool SelectedItemIsNull(out object selected, string errorMessage) { if ((selected = cbParticipants.SelectedItem) == null) diff --git a/src/ManageTournamentForm.cs b/src/ManageTournamentForm.cs index 9a023f15d16168d2a933a68187554ab25e5193d6..05a65640943fb2cb5de1805dc76620fe713de53f 100644 --- a/src/ManageTournamentForm.cs +++ b/src/ManageTournamentForm.cs @@ -9,7 +9,8 @@ namespace TournamentManager { public partial class ManageTournamentForm : Form { - private const string ParticipantError = "Participant with this name is already signed in competition"; + private const string RemoveParticipantError = "Participant with this name is already signed in competition"; + private const string EditParticipantError = "Participant with this name is already signed in competition"; private const string ErrorCaption = "Error"; private readonly ObservableCollection<Participant> _participants = new (); @@ -31,7 +32,7 @@ namespace TournamentManager x.FirstName.Equals(enterantCntrl.NewParticipant.FirstName) && x.Surname.Equals(enterantCntrl.NewParticipant.Surname))) { - MessageBox.Show(ParticipantError, ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + MessageBox.Show(RemoveParticipantError, ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } _participants.Add(enterantCntrl.NewParticipant); @@ -65,6 +66,7 @@ namespace TournamentManager if (e.Type != OperationType.Edit) return; + //TODO: some functionality }