private void buttonAdd_Click(object sender, EventArgs e)
        {
            try
            {
                string   matchupId    = textBoxId.Text;
                int      matchupRound = int.Parse(textBoxRound.Text);
                DateTime matchupDate  = dateTimePickerMatchup.Value;

                Matchups mat = new Matchups(matchupId, matchupRound, matchupDate);
                Matchups.AddMatchup(mat);

                Teams team1 = (Teams)comboBoxTeam1.SelectedItem;
                Teams team2 = (Teams)comboBoxTeam2.SelectedItem;


                double team1AddScore = double.Parse(textBoxScore1.Text);
                double team2AddScore = double.Parse(textBoxScore2.Text);

                MatchupEntries.Add(mat, team1, team1AddScore);
                MatchupEntries.Add(mat, team2, team2AddScore);

                team1.AddScore(team1AddScore);
                team2.AddScore(team2AddScore);

                MessageBox.Show("Matchup has been Saved", "Information");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Matchups cannot be saved. Error Message: " + ex.Message, "Error");
            }
        }
Example #2
0
        private void ButtonEdit_Click(object sender, EventArgs e)
        {
            try
            {
                string   matchupId    = textBoxId.Text;
                int      matchupRound = int.Parse(textBoxRound.Text);
                DateTime matchupDate  = dateTimePickerMatchup.Value;

                Matchups matchup = new Matchups(matchupId, matchupRound, matchupDate);
                Matchups.EditMatchup(matchup);

                Teams team1 = (Teams)comboBoxTeam1.SelectedItem;
                Teams team2 = (Teams)comboBoxTeam2.SelectedItem;

                double team1NewEntryScore = double.Parse(textBoxScore1.Text);
                double team2NewEntryScore = double.Parse(textBoxScore2.Text);

                MatchupEntries.Edit(matchup, team1, team1NewEntryScore);
                MatchupEntries.Edit(matchup, team2, team2NewEntryScore);

                double oldTeam1EntryScore = FormMatch.selectedMatchupEntry1.Score;
                double oldTeam2EntryScore = FormMatch.selectedMatchupEntry2.Score;

                team1.SubstractScore(oldTeam1EntryScore);
                team2.SubstractScore(oldTeam2EntryScore);

                team1.AddScore(team1NewEntryScore);
                team2.AddScore(team2NewEntryScore);

                MessageBox.Show("Matchup has been Saved", "Information");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Fail to edit matchup, " + ex.Message, "Error");
            }
        }