From c826889695c08a76c0e4c4f5d8ae126a3eb09ab6 Mon Sep 17 00:00:00 2001 From: emkael Date: Sun, 30 Jul 2017 00:51:34 +0200 Subject: Tournament info code refactored for incoming generalization --- Aktywator/MainForm.cs | 54 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 22 deletions(-) (limited to 'Aktywator/MainForm.cs') diff --git a/Aktywator/MainForm.cs b/Aktywator/MainForm.cs index 24f300c..55e2f53 100644 --- a/Aktywator/MainForm.cs +++ b/Aktywator/MainForm.cs @@ -171,29 +171,8 @@ namespace Aktywator choose.ShowDialog(); if (choose.chosenTournament != null) { - if ((tournament != null) && (tournament.mysql != null)) - tournament.mysql.close(); - tournament = choose.chosenTournament; - tournament.mysql.connect(); - - lTournament.Text = tournament.name; - lType.Text = tournament.type == 1 ? "Pary" : "Teamy"; - lSections.Text = tournament.getSectionsNum(); - lTables.Text = tournament.getTablesNum(); - bSync.Enabled = true; - bAutoSync.Enabled = true; - eInterval.Enabled = true; - if (tournament.type == 2) - { - lSkok.Visible = true; - lNazwyTeamow.Visible = true; - } - else - { - lSkok.Visible = false; - lNazwyTeamow.Visible = false; - } + updateTournamentInfo(tournament); } } catch (Exception ee) @@ -202,6 +181,37 @@ namespace Aktywator } } + private void updateTournamentInfo(Tournament tournament) + { + if (tournament != null) + { + tournament.setup(); + + lTournament.Text = tournament.getName(); + lType.Text = tournament.getTypeLabel(); + lSections.Text = tournament.getSectionsNum(); + lTables.Text = tournament.getTablesNum(); + bSync.Enabled = true; + bAutoSync.Enabled = true; + eInterval.Enabled = true; + if (tournament.type == Tournament.TYPE_TEAMY) + { + lSkok.Visible = true; + lNazwyTeamow.Visible = true; + } + else + { + lSkok.Visible = false; + lNazwyTeamow.Visible = false; + } + } + else + { + lSkok.Visible = false; + lNazwyTeamow.Visible = false; + } + } + private void bSync_Click(object sender, EventArgs e) { try -- cgit v1.2.3