예제 #1
0
        private void createTournamentButton_Click(object sender, EventArgs e)
        {
            // Validate the data in the form
            if (ValidationHelper.ValidateTournamentForm(out string errorMessage, tournamentNameValue.Text, _selectedEntries))
            {
                // Create the TournamentModel
                TournamentModel tournament = new TournamentModel
                {
                    TournamentName    = tournamentNameValue.Text,
                    TournamentEntries = _selectedEntries,
                    CurrentRound      = 0
                };

                // Wire up matchups
                TournamentLogic.CreateRounds(tournament);

                // Create Tournament entry
                // Create all TournamentEntries
                GlobalConfig.Connection.CreateTournament(tournament);

                // Handle bye matchups
                TournamentLogic.HandleByeMatchups(tournament);

                // Open the TournamentViewerForm and close this form
                TournamentViewerForm form = new TournamentViewerForm(tournament);
                form.Show();
                Close();
            }
            else
            {
                // Show error message
                MessageBox.Show($"The following errors exist in the form:\n{ errorMessage }", "Creation error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
 private void loadTournamentButton_Click(object sender, EventArgs e)
 {
     if (loadTournamentDropDown.SelectedItem != null)
     {
         int                  tournamentId       = ((TournamentPreviewModel)loadTournamentDropDown.SelectedItem).id;
         TournamentModel      selectedTournament = GlobalConfig.Connection.LoadTournamentModel(tournamentId);
         TournamentViewerForm form = new TournamentViewerForm(selectedTournament);
         form.Show();
     }
 }