Пример #1
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");
            }
        }