From 8589ba0d8313888da251fe45b6c313dd3280deee Mon Sep 17 00:00:00 2001 From: Michal Cikatricis <xcikatr@mail.muni.cz> Date: Fri, 28 May 2021 12:58:12 +0200 Subject: [PATCH] some small change --- src/ManageParticipantsControl.cs | 28 ++++++++++++++++++---------- src/ManageTournamentForm.cs | 6 ++++-- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/ManageParticipantsControl.cs b/src/ManageParticipantsControl.cs index b4651c7..24982d6 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 9a023f1..05a6564 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 } -- GitLab