Exemple #1
0
        private void scoreButton_Click(object sender, System.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("Score should be number");
                            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("Score should be number");
                            return;
                        }
                    }
                }
            }

            try
            {
                TournamentLogic.UpdateResults(tournament);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show($"The app had the following error: { ex.Message }");
                return;
            }
            LoadMatchups((int)roundDropDown.SelectedItem);
        }