diff options
-rw-r--r-- | Aktywator/ChooseTournament.cs | 23 | ||||
-rw-r--r-- | Aktywator/MySQLTournament.cs | 17 | ||||
-rw-r--r-- | Aktywator/Resources/BuildDate.txt | 2 |
3 files changed, 29 insertions, 13 deletions
diff --git a/Aktywator/ChooseTournament.cs b/Aktywator/ChooseTournament.cs index 734b191..2a7316f 100644 --- a/Aktywator/ChooseTournament.cs +++ b/Aktywator/ChooseTournament.cs @@ -8,9 +8,16 @@ using System.Windows.Forms; namespace Aktywator { + public struct TournamentListItem + { + public int Type; + public string Name; + public string Label; + } + public partial class ChooseTournament : Form { - private MySQLTournament[] turns; + private TournamentListItem[] turns; public MySQLTournament chosenTournament; public ChooseTournament() @@ -20,13 +27,13 @@ namespace Aktywator private void ChooseTournament_Load(object sender, EventArgs e) { - List<MySQLTournament> list = MySQLTournament.getTournaments(); - turns = new MySQLTournament[list.Count]; + List<TournamentListItem> list = MySQLTournament.getTournaments(); + turns = new TournamentListItem[list.Count]; int c = 0; - foreach (MySQLTournament t in list) + foreach (TournamentListItem t in list) { turns[c++] = t; - listBox.Items.Add(t.ToString()); + listBox.Items.Add(t.Label); } } @@ -34,13 +41,13 @@ namespace Aktywator { if (listBox.SelectedIndex >= 0) { - switch (turns[listBox.SelectedIndex].type) + switch (turns[listBox.SelectedIndex].Type) { case Tournament.TYPE_PARY: - chosenTournament = new ParyTournament(turns[listBox.SelectedIndex].name); + chosenTournament = new ParyTournament(turns[listBox.SelectedIndex].Name); break; case Tournament.TYPE_TEAMY: - chosenTournament = new TeamyTournament(turns[listBox.SelectedIndex].name); + chosenTournament = new TeamyTournament(turns[listBox.SelectedIndex].Name); break; } Close(); diff --git a/Aktywator/MySQLTournament.cs b/Aktywator/MySQLTournament.cs index f745a91..3bc9acc 100644 --- a/Aktywator/MySQLTournament.cs +++ b/Aktywator/MySQLTournament.cs @@ -21,19 +21,28 @@ namespace Aktywator mysql = new MySQL(name); } + public static string getLabel(string name, int type) + { + return name + " [" + (type == Tournament.TYPE_PARY ? 'P' : 'T') + "]"; + } + public override string ToString() { - return this.name + " [" + (this.type == Tournament.TYPE_PARY ? 'P' : 'T') + "]"; + return MySQLTournament.getLabel(this.name, this.type); } - public static List<MySQLTournament> getTournaments() + public static List<TournamentListItem> getTournaments() { - List<MySQLTournament> list = new List<MySQLTournament>(); + List<TournamentListItem> list = new List<TournamentListItem>(); MySQL c = new MySQL(""); data dbs = c.select("SELECT TABLE_SCHEMA, COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_NAME = 'admin' AND COLUMN_NAME IN ('dnazwa', 'teamcnt') ORDER BY TABLE_SCHEMA;"); while (dbs.Read()) { - list.Add(new MySQLTournament(dbs.GetString(0), "dnazwa".Equals(dbs.GetString(1)) ? Tournament.TYPE_PARY : Tournament.TYPE_TEAMY)); + TournamentListItem item = new TournamentListItem(); + item.Name = dbs.GetString(0); + item.Type = "dnazwa".Equals(dbs.GetString(1)) ? Tournament.TYPE_PARY : Tournament.TYPE_TEAMY; + item.Label = MySQLTournament.getLabel(item.Name, item.Type); + list.Add(item); } dbs.Close(); return list; diff --git a/Aktywator/Resources/BuildDate.txt b/Aktywator/Resources/BuildDate.txt index 4accc51..6b9b605 100644 --- a/Aktywator/Resources/BuildDate.txt +++ b/Aktywator/Resources/BuildDate.txt @@ -1 +1 @@ -2017-11-18 +2017-11-20 |