private void LoadMatchup(UtakmicaModel m) { for (int i = 0; i < m.Entries.Count; i++) { if (i == 0) { if (m.Entries[0].TeamCompeting != null) { labelTim1.Text = m.Entries[0].TeamCompeting.TeamName; textBoxRezultat1.Text = m.Entries[0].Score.ToString(); labelTim2.Text = "<bye>"; textBoxRezultat2.Text = "0"; } else { labelTim1.Text = "Not Yet Set"; textBoxRezultat1.Text = ""; } } if (i == 1) { if (m.Entries[1].TeamCompeting != null) { labelTim2.Text = m.Entries[1].TeamCompeting.TeamName; textBoxRezultat2.Text = m.Entries[1].Score.ToString(); } else { labelTim2.Text = "Not Yet Set"; textBoxRezultat2.Text = ""; } } } }
private void buttonScore_Click(object sender, EventArgs e) { string errorMessage = ValidData(); if (errorMessage.Length > 0) { MessageBox.Show($"Imput error:{errorMessage}"); return; } UtakmicaModel m = (UtakmicaModel)listBoxMatchups.SelectedItem; double teamOneScore = 0; double teamTwoScore = 0; for (int i = 0; i < m.Entries.Count; i++) { if (i == 0) { if (m.Entries[0].TeamCompeting.TeamName != null) { bool scoreValid = double.TryParse(textBoxRezultat1.Text, out teamOneScore); if (scoreValid) { m.Entries[0].Score = double.Parse(textBoxRezultat1.Text); } else { MessageBox.Show("Pelase enter a valid score for team 1"); return; } } } if (i == 1) { if (m.Entries[1].TeamCompeting.TeamName != null) { bool scoreValid = double.TryParse(textBoxRezultat2.Text, out teamTwoScore); if (scoreValid) { m.Entries[1].Score = double.Parse(textBoxRezultat2.Text); } else { MessageBox.Show("Pelase enter a valid score for team 2"); return; } } } } try { TournamentLogic.UpdateTournamentResults(tournament); } catch (Exception ex) { MessageBox.Show($"Aplication has the following error:{ex.Message}"); } LoadMatchups((int)comboBoxRunde.SelectedItem); }