private void editTeamButton_Click(object sender, EventArgs e)
        {
            ISession session = DatabaseManager.Instance.OpenSession();
            IList<Object> teams = session.QueryOver<Object>("Team").List();
            SelectionForm selection = new SelectionForm(teams);
            selection.ShowDialog();

            // Get selection result
            Team team = (Team)selection.getSelection();

            if (team != null)
            {
                TeamForm teamForm = new TeamForm(team.Id);
                teamForm.ShowDialog();
            }
        }
        private void editAssociationButton_Click(object sender, EventArgs e)
        {
            ISession session = DatabaseManager.Instance.OpenSession();
            IList<Object> associations = session.QueryOver<Object>("Association").List();
            SelectionForm selection = new SelectionForm(associations);
            selection.ShowDialog();

            // Get selection result
            Association association = (Association)selection.getSelection();

            if (association != null)
            {
                AssociationForm associationForm = new AssociationForm(association.Id);
                associationForm.ShowDialog();
            }
        }
        private void resultButton_Click(object sender, EventArgs e)
        {
            ISession session = DatabaseManager.Instance.OpenSession();
            IList<Object> matches = session.QueryOver<Object>("Match").List();
            SelectionForm selection = new SelectionForm(matches);
            selection.ShowDialog();

            // Get selection result
            Match match = (Match) selection.getSelection();

            if (match != null)
            {
                MatchForm matchForm = new MatchForm(match.Id);
                matchForm.ShowDialog();
            }
            session.Close();
        }
        private void addTeamButton_Click(object sender, EventArgs e)
        {
            ISession session = DatabaseManager.Instance.OpenSession();
            IList<Object> teams = session.CreateCriteria<Team>().Add(Restrictions.IsEmpty("Tournaments")).List<Object>();
            SelectionForm selection = new SelectionForm(teams);
            selection.ShowDialog();

            // Get selection result
            Team team = (Team)selection.getSelection();

            Tournament tournament = session.Load<Tournament>(tournamentId);

            if (team != null)
            {
                tournament.Teams.Add(team);
                session.Flush();
            }
            session.Close();
        }
        private void addAssociationButton_Click(object sender, EventArgs e)
        {
            ISession session = DatabaseManager.Instance.OpenSession();
            IList<Object> associations = session.CreateCriteria<Association>().Add(Restrictions.IsEmpty("Tournaments")).List<Object>();
            SelectionForm selection = new SelectionForm(associations);
            selection.ShowDialog();

            // Get selection result
            Association association = (Association) selection.getSelection();

            Tournament tournament = session.Load<Tournament>(tournamentId);

            if(association != null)
            {
                tournament.Associations.Add(association);
                session.Flush();
            }
            session.Close();
        }
        private void removeTeamButton_Click(object sender, EventArgs e)
        {
            ISession session = DatabaseManager.Instance.OpenSession();
            Tournament tournament = session.Load<Tournament>(tournamentId);
            SelectionForm selection = new SelectionForm(tournament.Teams);
            selection.ShowDialog();

            // Get selection result
            Team team = (Team)selection.getSelection();

            if (team != null)
            {
                tournament.Teams.Remove(team);
                session.Flush();
            }
            session.Close();
        }
        private void removeAssociationsButton_Click(object sender, EventArgs e)
        {
            ISession session = DatabaseManager.Instance.OpenSession();

            Tournament tournament = session.Load<Tournament>(tournamentId);

            SelectionForm selection = new SelectionForm(tournament.Associations);
            selection.ShowDialog();

            // Get selection result
            Association association = (Association) selection.getSelection();

            if (association != null)
            {
                tournament.Associations.Remove(association);
                session.Flush();
            }
            session.Close();
        }
        private void loadTournamentButton_Click(object sender, EventArgs e)
        {
            ISession session = DatabaseManager.Instance.OpenSession();
            IList<Object> tournaments = session.QueryOver<Object>("Tournament").List();
            SelectionForm selection = new SelectionForm(tournaments);
            selection.ShowDialog();

            // Get selection result
            Tournament tournament = (Tournament) selection.getSelection();

            session.Close();

            if (tournament != null)
            {
                Form tournamentSetupForm = new TournamentSetupForm(tournament.Id);
                tournamentSetupForm.Show();
                Close();
            }
        }