Example #1
0
        private void b_continue_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!tournament.IsFinished)
                {
                    tbl_chance_team1.Text = "Gewinnchance: \n" +
                                            (tournament.CurrentMatch.GetWinExpectationThatTeamAWins()).ToString() +
                                            " %";
                    tbl_chance_team2.Text = "Gewinnchance: \n" +
                                            (tournament.CurrentMatch.GetWinExpectationThatTeamBWins()).ToString() +
                                            " %";
                    tournament.SetGoalForCurrentSet(teams.ElementAt(0), Int32.Parse(tb_team1.Text), teams.ElementAt(1),
                                                    Int32.Parse(tb_team2.Text));
                    tb_team1.Clear();
                    tb_team2.Clear();

                    if (countSet == ApplicationState.GetValue <TournamentPers>("CurrentTournament").AmountSets)
                    {
                        countMatch++;
                        l_title.Content = "Spiel " + countMatch.ToString();
                        countSet        = 0;
                    }

                    teams = tournament.CurrentMatch.GetTeams();

                    if (!String.IsNullOrEmpty(tbl_team1.Text) && !String.IsNullOrEmpty(tbl_team2.Text))
                    {
                        tbl_team1.Text = teams.ElementAt(0).ToString();
                        tbl_team2.Text = teams.ElementAt(1).ToString();

                        countSet++;
                        tbl_nr_set.Text = "Satz: " + countSet.ToString();
                        ApplicationState.SetValue("MatchWinner", tournament.CurrentMatch.Winner);
                    }
                    else
                    {
                        MessageBox.Show("Bitte Tore eintragen", "KICKERCUP", MessageBoxButton.OK,
                                        MessageBoxImage.Error);
                    }
                }

                if (tournament.IsFinished)
                {
                    TMPersistenz.SaveFinishedTournamendToDB(tournament,
                                                            ApplicationState.GetValue <Client>("LoggedOnUser").Username);

                    if (tournament.IsRanked)
                    {
                        //Rankings des Turniers in der Datenbank abspeichern
                        TMPersistenz.SaveRankingsToDB(tournament);
                    }

                    Finished_Tournament ft = new Finished_Tournament();
                    ft.DataChanged += Finished_Tournament_DataChanged;
                    ft.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }