Beispiel #1
0
        /// <summary>
        /// Called when user wants to load a tournament.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void loadTournamentButton_Click(object sender, EventArgs e)
        {
            //Get the tournament to be loaded
            Tournament           tournament = (Tournament)loadTournamentComboBox.SelectedItem;
            TournamentViewerForm form;

            //If tournament is selected
            if (tournament != null)
            {
                form = new TournamentViewerForm(tournament);
                form.Show();
            }
            else
            {
                MessageBox.Show("Please Select a Tournament to be opened.", "Select a Tournament", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #2
0
        /// <summary>
        /// This method is called when user clicks on the create tournament button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void createTournamentButton_Click(object sender, EventArgs e)
        {
            //Check if user has entered valid data
            if (isTournamnetValid())
            {
                //Create the tournament
                Tournament tournament = new Tournament();
                tournament.EntryFee       = double.Parse(entryFeeValue.Text);
                tournament.TournamentName = tournamentNameValue.Text;
                tournament.Prizes         = selectedPrizes;
                tournament.Teams          = selectedTeams;

                //Create the rounds for the tournament
                Logic.createRounds(tournament);

                //After rounds are created, upload the tournament to the database
                DataConfig.connection.CreateTournament(tournament);

                //Notify tournament members by email about their matchups in rounds
                Logic.alertUsersToNewRound(tournament);

                //Notify the requestor that tournament has been created
                tournamentRequestor.tournamentCreated(tournament);

                MessageBox.Show($"Tournament {tournament.TournamentName} has been Created Successfully", "Tournament Created", MessageBoxButtons.OK, MessageBoxIcon.Information);

                //Open the tournament viewer form
                TournamentViewerForm form = new TournamentViewerForm(tournament);
                form.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("There are some invalid fields. Please Check fields again" +
                                "\nNote: 1) Teams cannot be less than two.\n" +
                                "2) Fee cannot be less than zero.", "Fileds missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }