示例#1
0
        private void scoreButton_Click(object sender, EventArgs e)
        {
            string errorMessage = ValidateData();

            if (errorMessage != string.Empty)
            {
                MessageBox.Show($"Input Error: {errorMessage}");
                return;
            }

            MatchupModel m            = (MatchupModel)matchupListbox.SelectedItem;
            double       teamOneScore = 0;
            double       teamTwoScore = 0;

            for (int i = 0; i < m.Entries.Count; i++)
            {
                if (i == 0)
                {
                    if (m.Entries[i].TeamCompeting != null)
                    {
                        if (double.TryParse(teamOneScoreValue.Text, out teamOneScore))
                        {
                            m.Entries[i].Score = teamOneScore;
                        }
                        else
                        {
                            MessageBox.Show($"Please enter a valid score for team {i}");
                            return;
                        }
                    }
                }
                else
                {
                    if (m.Entries[i].TeamCompeting != null)
                    {
                        if (double.TryParse(teamTwoScoreValue.Text, out teamTwoScore))
                        {
                            m.Entries[i].Score = teamTwoScore;
                        }
                        else
                        {
                            MessageBox.Show($"Please enter a valid score for team {i}");
                            return;
                        }
                    }
                }
            }

            try
            {
                TournamentLogic.UpdateTournamentResults(tournament);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"The application had the following error: {ex.Message}");
                return;
            }

            LoadMatchups((int)roundDropdown.SelectedItem);
        }
        private void ScoreButton_Click(object sender, EventArgs e)
        {
            string errorMsg = ValidateScores();

            if (errorMsg.Length > 0)
            {
                MessageBox.Show(errorMsg, "Error: Invalid Score");
                return;
            }

            MatchupModel m = (MatchupModel)matchupListBox.SelectedItem;

            if (m.Entries[0].TeamCompeting != null)
            {
                m.Entries[0].Score = double.Parse(scoreOneValue.Text);
            }
            if (m.Entries.Count > 1 && m.Entries[1].TeamCompeting != null)
            {
                m.Entries[1].Score = double.Parse(scoreTwoValue.Text);
            }

            try
            {
                TournamentLogic.UpdateTournamentResults(tm, m);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error: { ex.Message }");
                return;
            }

            LoadMatchups(TournamentLogic.GetCurrentRound(tm));
            roundDropDown.SelectedItem = TournamentLogic.GetCurrentRound(tm);
        }
示例#3
0
        private void scoreButton_Click(object sender, EventArgs e)
        {
            MatchupModel m = (MatchupModel)matchupListBox.SelectedItem;

            if (m != null)
            {
                for (int i = 0; i < m.Entries.Count; i++)
                {
                    if (i == 0)
                    {
                        if (m.Entries[0].TeamCompeting != null)
                        {
                            bool scoreValid = double.TryParse(teamOneScoreValue.Text, out double teamOneScore);

                            if (scoreValid)
                            {
                                m.Entries[0].Score = teamOneScore;
                            }
                            else
                            {
                                MessageBox.Show("Please enter a valid score for the team 1.");
                                return;
                            }
                        }
                    }

                    if (i == 1)
                    {
                        if (m.Entries[1].TeamCompeting != null)
                        {
                            bool scoreValid = double.TryParse(teamTwoScoreValue.Text, out double teamTwoScore);

                            if (scoreValid)
                            {
                                m.Entries[1].Score = teamTwoScore;
                            }
                            else
                            {
                                MessageBox.Show("Please enter a valid score for the team 2.");
                                return;
                            }
                        }
                    }
                }
            }

            TournamentLogic.UpdateTournamentResults(tournament);

            LoadMatchups((int)roundDropdown.SelectedItem);
        }
示例#4
0
        private void SetMatch()
        {
            var m            = (MatchupModel)matchupListBox.SelectedItem;
            var teamOneScore = 0.0;
            var teamTwoScore = 0.0;


            if (m == null)
            {
                return;
            }

            for (int i = 0; i < m.Entries.Count; i++)
            {
                if (i == 0)
                {
                    if (m.Entries[0].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamOneScoreValue.Text, out teamOneScore);
                        if (scoreValid)
                        {
                            m.Entries[0].Score = teamOneScore;
                        }
                        else
                        {
                            MessageBox.Show("Invalid Score for team 1.");
                            return;
                        }
                    }
                }

                if (i == 1)
                {
                    if (m.Entries[1].TeamCompeting != null)
                    {
                        var scoreValid = double.TryParse(teamTwoScoreValue.Text, out teamTwoScore);
                        if (scoreValid)
                        {
                            m.Entries[1].Score = teamTwoScore;
                        }
                        else
                        {
                            MessageBox.Show("Invalid Score for team 2.");
                            return;
                        }
                    }
                }
            }
            TournamentLogic.UpdateTournamentResults(tournament);
        }
示例#5
0
        private void createTournamentButton_Click(object sender, EventArgs e)
        {
            // Validate data
            decimal fee = 0;

            bool feeAcceptable = decimal.TryParse(entryFeeValue.Text, out fee);

            if (!feeAcceptable)
            {
                MessageBox.Show("You need to enter a valid Entry fee", "Invalid Fee",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            // Create our tournament model

            TournamentModel tm = new TournamentModel();

            tm.TournamentName = tournamentNameValue.Text;
            tm.EntryFee       = fee;

            tm.Prizes       = selectedPrizes;
            tm.EnteredTeams = selectedTeams;

            // TODO Wire our match ups

            TournamentLogic.CreateRounds(tm);

            // Create Tournaments Entry

            // Create all of the of the prizes entries

            // Create all of team entries

            // Create our matchings

            GlobalConfig.Connection.CreateTournament(tm);

            tm.AlertUsersToNewRound();

            TournamentLogic.UpdateTournamentResults(tm);

            TournamentViewerForm frm = new TournamentViewerForm(tm);

            frm.Show();
            // this.Close();
        }
示例#6
0
        private void BtnScore_Click(object sender, EventArgs e)
        {
            MatchupModel m = (MatchupModel)lbMatchup.SelectedItem;

            if (m != null)
            {
                for (int i = 0; i < m.Entries.Count; i++)
                {
                    bool scoreValid;
                    if (m.Entries[i].TeamCompeting != null)
                    {
                        if (i == 0)
                        {
                            scoreValid = double.TryParse(tbTeamOneScore.Text, out double score);
                            if (scoreValid)
                            {
                                m.Entries[i].Score = score;
                            }
                            else
                            {
                                MessageBox.Show($"Please enter a valid score for team {i + 1}");
                                return;
                            }
                        }
                        if (i == 1)
                        {
                            scoreValid = double.TryParse(tbTeamTwoScore.Text, out double score);
                            if (scoreValid)
                            {
                                m.Entries[i].Score = score;
                            }
                            else
                            {
                                MessageBox.Show($"Please enter a valid score for team {i + 1}");
                                return;
                            }
                        }
                    }
                }

                // Highscore wins
                TournamentLogic.UpdateTournamentResults(tournament);
            }



            LoadMatchups();
        }
示例#7
0
        private void scoreButton_Click(object sender, EventArgs e)
        {
            if (!IsValidData())
            {
                MessageBox.Show("You need to enter valid data before we can score this matchup");
                return;
            }
            MatchupModel m            = (MatchupModel)matchupListBox.SelectedItem;
            double       teamOneScore = 0;
            double       teamTwoScore = 0;

            for (int i = 0; i < m.Entries.Count; i++)
            {
                if (i == 0)
                {
                    if (m.Entries[0].TeamCompeting != null)
                    {
                        teamOneName.Text = m.Entries[0].TeamCompeting.TeamName;


                        bool scoreValid = double.TryParse(teamOneScoreValue.Text, out teamOneScore);

                        if (scoreValid)
                        {
                            m.Entries[0].Score = teamOneScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for team 1.");
                            return;
                        }
                    }
                }

                if (i == 1)
                {
                    if (m.Entries[1].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamTwoScoreValue.Text, out teamTwoScore);
                        if (scoreValid)
                        {
                            m.Entries[1].Score = teamTwoScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for team 2.");
                            return;
                        }
                    }
                }
            }

            if (teamOneScore > teamTwoScore)
            {
                // Team one wins
                m.Winner = m.Entries[0].TeamCompeting;
            }
            else if (teamTwoScore > teamOneScore)
            {
                m.Winner = m.Entries[1].TeamCompeting;
            }
            else
            {
                MessageBox.Show("I do not handle tie games.");
            }

            foreach (List <MatchupModel> round in tournament.Rounds)
            {
                foreach (MatchupModel rm in round)
                {
                    foreach (MatchupEntryModel me in rm.Entries)
                    {
                        if (me.ParentMatchup != null)
                        {
                            if (me.ParentMatchup.Id == m.Id)
                            {
                                me.TeamCompeting = m.Winner;
                            }
                        }
                    }
                }
            }

            try
            {
                TournamentLogic.UpdateTournamentResults(tournament);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"The application had the following error: {ex.Message}");
                return;
            }

            LoadMatchups((int)roundDropDown.SelectedItem);
        }
示例#8
0
        private void scoreButton_Click(object sender, EventArgs e)
        {
            string errorMessage = ValidateData();

            if (errorMessage.Length > 0)  //method to scheck data
            {
                MessageBox.Show($"Input Error: {errorMessage}");
                return; //Выйти из метода, так как дальнейшее его продолжние не имеет смысла
            }

            //определяем кого мы выбрали в блоке метчей.
            MatchupModel m            = (MatchupModel)matchupListBox.SelectedItem;
            double       teamOneScore = 0;
            double       teamTwoScore = 0;

            for (int i = 0; i < m.Entries.Count; i++)
            {
                if (i == 0)
                {
                    if (m.Entries[0].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamOneScoreValue.Text, out teamOneScore);
                        if (scoreValid)
                        {
                            m.Entries[0].Score = teamOneScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for team 1.");
                            return;
                        }
                    }
                }

                if (i == 1)
                {
                    if (m.Entries[1].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamTwoScoreValue.Text, out teamTwoScore);
                        if (scoreValid)
                        {
                            m.Entries[1].Score = teamTwoScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for team 2.");
                            return;
                        }
                    }
                }
            }

            //Error might be thrown here. In case if the score is the same for both teams - its wrong!!!
            try
            {
                TournamentLogic.UpdateTournamentResults(tournament);
            }
            catch (Exception ex) //lets give a name to an exception. Ex is the name.
            {
                MessageBox.Show($"The application had the following error: {ex.Message}");
                return;
            }


            //Если ввели score для команды. т.е. повявился победитель - список должен обновиться. (если нажата кнопка unplayed only)
            //Выводим на дисплей данное состояние, так как метч второго раунда еще не сформирован
            //Мы загружаем метчи без изменения того метча, в котором определили победителя, так как иначе у нас winner будет не null и этот метч больше не отобразится.
            LoadMatchups((int)roundDropDown.SelectedItem);
        }
        private void scoreButton_Click(object sender, EventArgs e)
        {
            MatchupModel m = (MatchupModel)matchupListBox.SelectedItem;

            double teamOneScore = 0;
            double teamTwoScore = 0;

            for (int i = 0; i < m.Entries.Count; i++)
            {
                if (i == 0)
                {
                    if (m.Entries[0].TeamCompeting != null)
                    {
                        //teamOneLabel.Text = m.Entries[0].TeamCompeting.TeamName;
                        bool scoreValid = double.TryParse(teamOneScoreTextBox.Text, out teamOneScore);

                        if (scoreValid)
                        {
                            m.Entries[0].Score = double.Parse(teamOneScoreTextBox.Text);
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for team 1.");
                            return;
                        }
                    }
                }
                if (i == 1)
                {
                    if (m.Entries[1].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamTwoScoreTextBox.Text, out teamTwoScore);


                        if (scoreValid)
                        {
                            m.Entries[1].Score = teamTwoScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for team 2.");
                            return;
                        }
                    }
                }
            }

            try
            {
                TournamentLogic.UpdateTournamentResults(tournament);
            }
            catch (Exception ex)
            {
                MessageBox.Show("The following error occured: " + ex);
            }


            LoadMatchups((int)roundComboBox.SelectedItem);



            //GlobalConfig.Connection.UpdateRounds();
        }
示例#10
0
        private void scoreButton_Click(object sender, EventArgs e)
        {
            string errorMessage = ValidateData();

            if (errorMessage.Length > 0)
            {
                MessageBox.Show($"Input Error: {errorMessage}");
                return;
            }

            MatchupModel m            = (MatchupModel)matchupListBox.SelectedItem;
            double       teamOneScore = 0;
            double       teamTwoScore = 0;

            for (int i = 0; i < m.Entries.Count; i++)
            {
                if (i == 0)
                {
                    if (m.Entries[0].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamOneScoreValue.Text, out teamOneScore);

                        if (scoreValid)
                        {
                            m.Entries[0].Score = teamOneScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for team 1.");
                            return;
                        }
                    }
                }

                if (i == 1)
                {
                    if (m.Entries[1].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamTwoScoreValue.Text, out teamTwoScore);

                        if (scoreValid)
                        {
                            m.Entries[1].Score = teamTwoScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for team 2.");
                            return;
                        }
                        teamTwoName.Text       = m.Entries[1].TeamCompeting.TeamName;
                        teamTwoScoreValue.Text = m.Entries[1].Score.ToString();
                    }
                }
            }

            try
            {
                TournamentLogic.UpdateTournamentResults(tournament);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"The application had the following error: {ex.Message}");
                return;
            }
            LoadMatchups();
        }
示例#11
0
        private void scoreButton_Click(object sender, EventArgs e)
        {
            string errorMessage = ValidateData();

            if (errorMessage.Length > 0)
            {
                MessageBox.Show($"Input error: {errorMessage}", "Input Error");
                return;
            }

            Matchup match        = (Matchup)matchupListBox.SelectedItem;
            double  teamOneScore = 0;
            double  teamTwoScore = 0;

            for (int i = 0; i < match.Entries.Count; i++)
            {
                if (i == 0)
                {
                    if (match.Entries[0].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamOneScoreValue.Text, out teamOneScore);
                        if (scoreValid)
                        {
                            match.Entries[0].Score = teamOneScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter valid score");
                            return;
                        }
                    }
                }

                if (i == 1)
                {
                    if (match.Entries[0].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamTwoScoreValue.Text, out teamTwoScore);
                        if (scoreValid)
                        {
                            match.Entries[1].Score = teamTwoScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter valid score");
                            return;
                        }
                    }
                }
            }

            //try
            //{
            TournamentLogic.UpdateTournamentResults(tournament);
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show($"The application had the following error: { ex.Message }");
            //}

            LoadMatchups((int)roundDropDown.SelectedItem);
        }
示例#12
0
        private void ScoreButton_Click(object sender, EventArgs e)
        {
            string errorMesseage = ValidateDada();

            if (errorMesseage.Length > 0)
            {
                MessageBox.Show($"error{errorMesseage}");
                return;
            }
            var    m            = MatchUpListBox.SelectedItem as MatchUpModel;
            double teamOneScore = 0;
            double teamTwoScore = 0;

            for (int i = 0; i < m.Entries.Count; i++)
            {
                if (i == 0)
                {
                    if (m.Entries[0].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(TeamOneTextBox.Text, out teamOneScore);
                        if (scoreValid)
                        {
                            m.Entries[0].Score = teamOneScore;
                        }
                        else
                        {
                            MessageBox.Show("please enter vaild score for team 1");
                            return;
                        }
                    }
                }
                if (i == 1)
                {
                    if (m.Entries[1].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(TeamTowTextBox.Text, out teamTwoScore);
                        if (scoreValid)
                        {
                            m.Entries[1].Score = teamTwoScore;
                        }
                        else
                        {
                            MessageBox.Show("please enter vaild score for team 2");
                            return;
                        }
                    }
                }
            }

            try
            {
                TournamentLogic.UpdateTournamentResults(tournament);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"the app had the fallowing error :{ex.Message}");
                return;
            }



            LoadMatchups((int)RoundDropBox.SelectedItem);

            GlobalConfig.Connaction.UpadateMatchup(m);
        }
        /// <summary>
        /// Score the current matchup.
        /// </summary>
        /// <param name="sender">The object that initiated the event.</param>
        /// <param name="e">The arguments of the event.</param>
        private void Scorebtn_Click(object sender, EventArgs e)
        {
            string error = this.IsValidData();

            if (error.Length > 0)
            {
                MessageBox.Show($"Input error: { error }");
                return;
            }

            MatchupModel m = (MatchupModel)this.Matchuplbox.SelectedItem;

            double teamOneScore = 0;
            double teamTwoScore = 0;

            for (int i = 0; i < m.Entries.Count; i++)
            {
                if (i == 0)
                {
                    if (m.Entries[0].TeamCompeting != null)
                    {
                        bool ScoreValid = double.TryParse(this.TeamOneScoreValuetbox.Text, out teamOneScore);

                        if (ScoreValid)
                        {
                            m.Entries[0].Score = teamOneScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for team one.");
                            return;
                        }
                    }
                }

                if (i == 1)
                {
                    if (m.Entries[1].TeamCompeting != null)
                    {
                        bool ScoreValid = double.TryParse(this.TeamTwoScoreValuetbox.Text, out teamTwoScore);

                        if (ScoreValid)
                        {
                            m.Entries[1].Score = teamTwoScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for team two.");
                            return;
                        }
                    }
                }
            }

            try
            {
                TournamentLogic.UpdateTournamentResults(this.tournament);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Application Error: { ex.Message }");
                return;
            }
            this.LoadMatchups((int)this.RoundDropDowncbox.SelectedItem);
        }
示例#14
0
        private void createTournamentButton_Click(object sender, EventArgs e)
        {
            //Validate Data
            decimal fee           = 0;
            bool    feeAcceptable = decimal.TryParse(entryFeeValue.Text, out fee);

            if (tournamentNameValue.Text == "")
            {
                MessageBox.Show("Enter a valid tournament name.",
                                "Invalid Fee",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            if (!feeAcceptable)
            {
                MessageBox.Show("Enter a valid Entry Fee",
                                "Invalid Fee",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            if (fee <= 0)
            {
                MessageBox.Show("Fee must be greater than $0.",
                                "Invalid Fee",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            if (tournamentTeamsListBox.Items.Count == 0)
            {
                MessageBox.Show("Please assign team(s) to the tournament.",
                                "Invalid Fee",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            //if (prizeListBox.Items.Count == 0)
            //{
            //    MessageBox.Show("Please assign a prize to the tournament.",
            //         "Invalid Fee",
            //         MessageBoxButtons.OK,
            //         MessageBoxIcon.Error);
            //    return;
            //}


            // Create our tournament model based on the entries in the form.
            TournamentModel tm = new TournamentModel();

            tm.TournamentName = tournamentNameValue.Text;
            tm.EntryFee       = fee;
            tm.Prizes         = selectedPrizes;
            tm.EntreredTeams  = selectedTeams;

            // Wire our matchups
            TournamentLogic.CreateRounds(tm);

            // Create Tournament entry
            // Create all of the Prize entreis
            // Create all of the team entries
            GlobalConfig.Connection.CreateTournament(tm);

            // Email Users from the first round
            tm.AlertUsersToNewRound();

            TournamentLogic.UpdateTournamentResults(tm);

            MessageBox.Show("Tournament Created. Closing window.");
            this.Close();

            TournamentViewerForm frm = new TournamentViewerForm(tm);

            frm.Show();
        }
示例#15
0
        private void scoreButton_Click(object sender, EventArgs e)
        {
            string errorMessage = ValidateScores();

            if (errorMessage.Length > 0)
            {
                MessageBox.Show($"Input Error: {errorMessage}");
                return;
            }

            MatchupModel m            = (MatchupModel)matchupListBox.SelectedItem;
            double       teamOneScore = 0;
            double       teamTwoScore = 0;

            List <MatchupEntryModel> sortedList = m.Entries.OrderByDescending(x => x.TeamCompeting != null
                                                                              ? x.TeamCompeting.Id
                                                                              : 0).ToList();

            for (int i = 0; i < sortedList.Count(); i++)
            {
                if (i == 0)
                {
                    if (m.Entries[0].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamOneScoreTextBox.Text, out teamOneScore);

                        if (scoreValid)
                        {
                            sortedList[0].Score = teamOneScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for team 1.");
                            return;
                        }
                    }
                }

                if (i == 1)
                {
                    if (m.Entries[1].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamTwoScoreTextBox.Text, out teamTwoScore);

                        if (scoreValid)
                        {
                            sortedList[1].Score = teamTwoScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for team 2.");
                            return;
                        }
                    }
                }
            }

            try
            {
                TournamentLogic.UpdateTournamentResults(tournament);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"The application had the following error: {ex.Message}");
                return;
            }

            LoadMatchups((int)roundComboBox.SelectedItem);
        }
示例#16
0
        private void scoreButton_Click(object sender, EventArgs e)
        {
            MatchUpModel m = (MatchUpModel)matchupListBox.SelectedItem;
            double       teamOneScore = 0, teamTwoScore = 0;

            if (!IsValidData())
            {
                MessageBox.Show("You need to enter valid data before we can score this match up.");
                return;
            }

            for (int i = 0; i < m.Entries.Count; i++)
            {
                if (i == 0)
                {
                    if (m.Entries[0].TeamCompeting != null)
                    {
                        teamOneNameLabel.Text = m.Entries[0].TeamCompeting.TeamName;
                        bool scoreValid = double.TryParse(teamOneScoreValueTextBox.Text, out teamOneScore);

                        if (scoreValid)
                        {
                            m.Entries[0].Score = teamOneScore;
                        }
                        else
                        {
                            Helper.ShowMessage("Please enter the valid score value for team one", true);
                            return;
                        }
                    }
                }


                if (i == 1)
                {
                    if (m.Entries[1].TeamCompeting != null)
                    {
                        teamTwoNameLabel.Text = m.Entries[1].TeamCompeting.TeamName;
                        bool scoreValid = double.TryParse(teamTwoScoreValueTextBox.Text, out teamTwoScore);

                        if (scoreValid)
                        {
                            m.Entries[1].Score = teamTwoScore;
                        }
                        else
                        {
                            Helper.ShowMessage("Please enter the valid score value for team two", true);
                            return;
                        }
                    }
                }
            }

            try
            {
                TournamentLogic.UpdateTournamentResults(this._loadedTournament);
            }
            catch (Exception exception)
            {
                MessageBox.Show($@"The application had the following error: {exception.Message}");
                return;
            }

            this.LoadMatchUps((int)roundDropDown.SelectedItem);
        }
示例#17
0
        private void scoreButton_Click(object sender, EventArgs e)
        {
            string errorMessage = ValidedData();

            if (errorMessage.Length > 0)
            {
                MessageBox.Show($"Input Error: { errorMessage }");
                return;
            }

            MatchupModel m            = (MatchupModel)matchupListbox.SelectedItem;
            double       teamOneScore = 0;
            double       teamTwoScore = 0;

            for (int i = 0; i < m.Entries.Count; i++)
            {
                // Team one
                if (i == 0)
                {
                    if (m.Entries[0].TeamCompeting != null)
                    {
                        // When ever you use a gived information, you need to check it first.

                        bool scoreValid = double.TryParse(teamOneScoreValue.Text, out teamOneScore);

                        if (scoreValid)
                        {
                            m.Entries[0].Score = teamOneScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for team 1.");
                            return;
                        }
                    }
                }

                // Team two
                if (i == 1)
                {
                    if (m.Entries[1].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamTwoScoreValue.Text, out teamTwoScore);
                        if (scoreValid)
                        {
                            m.Entries[1].Score = teamTwoScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for team 2.");
                            return;
                        }
                    }
                }
            }

            try
            {
                TournamentLogic.UpdateTournamentResults(tournament);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"The application had the folling error : { ex.Message }");
                return;
            }

            LoadMatchups((int)roundDropDown.SelectedItem);
        }
示例#18
0
        private void    scoreButton_Click(object sender, EventArgs e)
        {
            string errorMessage = ValidateData();

            if (errorMessage.Length > 0)
            {
                MessageBox.Show($"Desila se sledeca greska: { errorMessage }");
                return;
            }

            MatchupModel m            = (MatchupModel)matchupListBox.SelectedItem;
            double       teamOneScore = 0;
            double       teamTwoScore = 0;

            for (int i = 0; i < m.Entries.Count; i++)
            {
                if (i == 0)
                {
                    if (m.Entries[0].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamOneScoreTextbox.Text, out teamOneScore);

                        if (scoreValid)
                        {
                            m.Entries[0].Score = teamOneScore;
                        }
                        else
                        {
                            MessageBox.Show("Unesite pravilno polje rezultata tima 1!");
                            return;
                        }
                    }
                }

                if (i == 1)
                {
                    if (m.Entries[1].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamTwoScoreTextbox.Text, out teamTwoScore);

                        if (scoreValid)
                        {
                            m.Entries[1].Score = teamTwoScore;
                        }
                        else
                        {
                            MessageBox.Show("Unesite pravilno polje rezultata tima 2!");
                            return;
                        }
                    }
                }
            }

            try
            {
                TournamentLogic.UpdateTournamentResults(tournament);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Desila se sledeca greska: { ex.Message }");
                return;
            }

            LoadMatchups((int)roundDropDown.SelectedItem);
        }
示例#19
0
        private void scoreButton_Click(object sender, EventArgs e)
        {
            string errorMessage = ValidData();

            if (errorMessage.Length > 0)
            {
                MessageBox.Show(errorMessage);
                return;
            }

            MatchupModel m            = (MatchupModel)matchupListBox.SelectedItem;
            double       teamOneScore = 0;
            double       teamTwoScore = 0;

            if (m != null) // <= added code line
            {
                for (int i = 0; i < m.Entries.Count; i++)
                {
                    if (i == 0)
                    {
                        if (m.Entries[0].TeamCompeting != null)
                        {
                            bool scoreValid = double.TryParse(TeamOneScoreTextBox.Text, out teamOneScore);

                            if (scoreValid)
                            {
                                m.Entries[0].Score = teamOneScore;
                            }
                            else
                            {
                                MessageBox.Show("Enter a valid score for team 1;");
                                return;
                            }
                        }
                    }

                    if (i == 1)
                    {
                        if (m.Entries[1].TeamCompeting != null)
                        {
                            bool scoreValid = double.TryParse(TeamTwoScoreTextBox.Text, out teamTwoScore);

                            if (scoreValid)
                            {
                                m.Entries[1].Score = teamTwoScore;
                            }
                            else
                            {
                                MessageBox.Show("Enter a valid score for team 2;");
                                return;
                            }
                        }
                    }
                }


                try
                {
                    TournamentLogic.UpdateTournamentResults(tournament);
                }
                catch (Exception ex)
                {
                    //throw;
                    MessageBox.Show($"The application had the following error: {ex.Message}");
                    return;
                }
            } // <=



            LoadMatchups();
        }
示例#20
0
        private void scoreButton_Click(object sender, EventArgs e)
        {
            string errorMessage = ValidateData();

            if (errorMessage.Length > 0)
            {
                MessageBox.Show($"Input error : {errorMessage}");
                return;
            }

            MatchupModel m = (MatchupModel)matchupListBox.SelectedItem;

            double teamOneScore = 0;
            double teamTwoScore = 0;

            for (int i = 0; i < m.Entry.Count; i++)
            {
                // loop through team one.
                if (i == 0)
                {
                    if (m.Entry[0].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamOneScoreValue.Text, out teamOneScore);

                        if (scoreValid)
                        {
                            m.Entry[0].Score = teamOneScore;
                        }
                        else
                        {
                            // return is incorrect information is supplied.
                            MessageBox.Show("Please enter a valid score for team 1");
                            return;
                        }
                    }
                }

                // loop through team two.
                if (i == 1)
                {
                    if (m.Entry[1].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamTwoScoreValue.Text, out teamTwoScore);

                        if (scoreValid)
                        {
                            m.Entry[1].Score = teamTwoScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for team 2");
                            return;
                        }
                    }
                }
            }

            try
            {
                TournamentLogic.UpdateTournamentResults(tournament);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"The application had the following error: {ex.Message}");
                return;
            }

            // refrehes list when score button is clicked and checkbox is checked to auto refresh and remove it from the list.
            LoadMatchups((int)roundDropDown.SelectedItem);
        }
示例#21
0
        private void scoreButton_Click(object sender, EventArgs e)
        {
            string error = ValidateData();

            if (error.Length > 0)
            {
                MessageBox.Show($"Input error: {error}");
                return;
            }

            Matchup m            = matchupListBox.SelectedItem as Matchup;
            double  teamOneScore = 0;
            double  teamTwoScore = 0;


            for (int i = 0; i < m.Entrys.Count; i++)
            {
                if (i == 0)
                {
                    if (m.Entrys[0].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamOneScoreValue.Text, out teamOneScore);
                        if (scoreValid)
                        {
                            m.Entrys[0].Score = teamOneScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for team one!");
                            return;
                        }
                    }
                }

                if (i == 1)
                {
                    if (m.Entrys[1].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamTwoScoreValue.Text, out teamTwoScore);
                        if (scoreValid)
                        {
                            m.Entrys[1].Score = teamTwoScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter a valid score for team two!");
                            return;
                        }
                    }
                }
            }

            try
            {
                TournamentLogic.UpdateTournamentResults(Tournament);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"The application had the following error: {ex.Message}");
                return;
            }
            LoadMatchups((int)RoundDropdown.SelectedItem);
        }
示例#22
0
        private void scoreButton_Click(object sender, EventArgs e)
        {
            string errorMessage = ValidateData();

            if (errorMessage.Length > 0)
            {
                MessageBox.Show($"{ errorMessage }");
                return;
            }
            MatchupModel m            = (MatchupModel)matchupListBox.SelectedItem;
            double       teamOneScore = 0;
            double       teamTwoScore = 0;


            for (int i = 0; i < m.Entries.Count; i++)
            {
                if (i == 0)
                {
                    if (m.Entries[0].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamOneScoreValue.Text, out teamOneScore);
                        if (scoreValid)
                        {
                            m.Entries[0].Score = teamOneScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter the correct score for Team 1");
                            return;
                        }
                    }
                }

                if (i == 1)
                {
                    if (m.Entries[1].TeamCompeting != null)
                    {
                        bool scoreValid = double.TryParse(teamTwoScoreValue.Text, out teamTwoScore);
                        if (scoreValid)
                        {
                            m.Entries[1].Score = teamTwoScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter the correct score for Team 2");
                            return;
                        }
                    }
                }
            }


            if (teamOneScore > teamTwoScore)
            {
                m.Winner = m.Entries[0].TeamCompeting;
            }
            else if (teamOneScore < teamTwoScore)
            {
                m.Winner = m.Entries[1].TeamCompeting;
            }
            else
            {
                MessageBox.Show("Sorry, but we don't handle tied games");
            }

            foreach (List <MatchupModel> round in tournament.Rounds)
            {
                foreach (MatchupModel roundMatchup in round)
                {
                    foreach (MatchupEntryModel me in roundMatchup.Entries)
                    {
                        if (me.ParentMatchup != null)
                        {
                            if (me.ParentMatchup.Id == m.Id)
                            {
                                me.TeamCompeting = m.Winner;
                                GlobalConfig.Connection.UpdateMatchup(roundMatchup);
                            }
                        }
                    }
                }
            }

            try
            {
                TournamentLogic.UpdateTournamentResults(tournament);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"The application had the following error: { ex.Message}");
                return;
            }

            LoadMatchups((int)roundDropDown.SelectedItem);
        }