private void scoreButton_Click(object sender, EventArgs e)
        {
            MatchUpModel m            = (MatchUpModel)matchuplistBox1.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(scoreTeamOneValue.Text, out teamOneScore);

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

                        if (scoreValid)
                        {
                            m.Entries[1].Score = teamTwoScore;
                        }
                        else
                        {
                            MessageBox.Show("Please enter valid score for team 2");
                            return;
                        }
                    }
                }
            }
            TournamentLogic.UpdateTournamentResult(tournament);
            LoadMatchups((MatchUpModel)matchuplistBox1.SelectedItem);
            GlobalConfig.Connection.UpdateMatchup(m);
        }
        private void scoreButton_Click(object sender, EventArgs e)
        {
            if (!IsValidData())
            {
                return;
            }

            MatchUpModel m = (MatchUpModel)matchupListBox.SelectedItem;

            m.Entries[0].Score = double.Parse(teamOneScoreValue.Text);
            m.Entries[1].Score = double.Parse(teamTwoScoreValue.Text);

            try
            {
                TournamentLogic.UpdateTournamentResult(tournament);
            }
            catch (Exception err)
            {
                MessageBox.Show($"The app had the following error:{err.Message}");
                return;
            }

            LoadMatchUps();
        }
Ejemplo n.º 3
0
        private void scoreButton_Click(object sender, EventArgs e)
        {
            string errorMessage = ValidateData();

            if (errorMessage.Length > 0)
            {
                MessageBox.Show($"Error message: {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)
                        {
                            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[0].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 1");
                                return;
                            }
                        }
                    }
                }

                try
                {
                    TournamentLogic.UpdateTournamentResult(_tournament);
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"The Application had the following error: {ex.Message}");
                }
                LoadMatchups();
                GlobalConfig.Connection.UpdateMatchup(m);
            }
        }
Ejemplo n.º 4
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;
                        }
                    }
                }
            }

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

            LoadMatchups((int)roundDropDown.SelectedItem);
        }