summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Aktywator/Aktywator.csproj3
-rw-r--r--Aktywator/Bws.cs4
-rw-r--r--Aktywator/ChooseTournament.cs10
-rw-r--r--Aktywator/MainForm.cs7
-rw-r--r--Aktywator/MySQLTournament.cs65
-rw-r--r--Aktywator/ParyTournament.cs30
-rw-r--r--Aktywator/TeamyTournament.cs30
-rw-r--r--Aktywator/Tournament.cs36
8 files changed, 136 insertions, 49 deletions
diff --git a/Aktywator/Aktywator.csproj b/Aktywator/Aktywator.csproj
index 97fa090..e1b78f1 100644
--- a/Aktywator/Aktywator.csproj
+++ b/Aktywator/Aktywator.csproj
@@ -99,6 +99,7 @@
<Compile Include="MysqlSettings.Designer.cs">
<DependentUpon>MysqlSettings.cs</DependentUpon>
</Compile>
+ <Compile Include="ParyTournament.cs" />
<Compile Include="PBN.cs" />
<Compile Include="PBNBoard.cs" />
<Compile Include="PBNFile.cs" />
@@ -108,6 +109,8 @@
<Compile Include="Settings.cs" />
<Compile Include="Sql.cs" />
<Compile Include="MySQLTournament.cs" />
+ <Compile Include="TeamyTournament.cs" />
+ <Compile Include="Tournament.cs" />
<EmbeddedResource Include="ChooseTournament.resx">
<DependentUpon>ChooseTournament.cs</DependentUpon>
</EmbeddedResource>
diff --git a/Aktywator/Bws.cs b/Aktywator/Bws.cs
index 24e707c..41717b2 100644
--- a/Aktywator/Bws.cs
+++ b/Aktywator/Bws.cs
@@ -344,7 +344,7 @@ namespace Aktywator
else return 0;
}
- public void syncNames(MySQLTournament tournament, bool interactive, string startRounds)
+ public void syncNames(Tournament tournament, bool interactive, string startRounds)
{
int count = 0, countNew = 0, SKOK_STOLOW = 100;
data d;
@@ -394,7 +394,7 @@ namespace Aktywator
query.Append(ew);
query.Append(" UNION ALL SELECT ' '; ");
}
- mydata n = tournament.mysql.select(query.ToString());
+ mydata n = ((MySQLTournament)tournament).mysql.select(query.ToString());
DialogResult dr = DialogResult.None;
diff --git a/Aktywator/ChooseTournament.cs b/Aktywator/ChooseTournament.cs
index 155624b..734b191 100644
--- a/Aktywator/ChooseTournament.cs
+++ b/Aktywator/ChooseTournament.cs
@@ -34,7 +34,15 @@ namespace Aktywator
{
if (listBox.SelectedIndex >= 0)
{
- chosenTournament = turns[listBox.SelectedIndex];
+ switch (turns[listBox.SelectedIndex].type)
+ {
+ case Tournament.TYPE_PARY:
+ chosenTournament = new ParyTournament(turns[listBox.SelectedIndex].name);
+ break;
+ case Tournament.TYPE_TEAMY:
+ chosenTournament = new TeamyTournament(turns[listBox.SelectedIndex].name);
+ break;
+ }
Close();
}
}
diff --git a/Aktywator/MainForm.cs b/Aktywator/MainForm.cs
index 96d965b..e2e87db 100644
--- a/Aktywator/MainForm.cs
+++ b/Aktywator/MainForm.cs
@@ -15,7 +15,7 @@ namespace Aktywator
public string date = "28.06.2017";
private Bws bws;
- private MySQLTournament tournament;
+ private Tournament tournament;
public MainForm()
{
@@ -181,7 +181,7 @@ namespace Aktywator
}
}
- private void updateTournamentInfo(MySQLTournament tournament)
+ private void updateTournamentInfo(Tournament tournament)
{
if (tournament != null)
{
@@ -194,7 +194,7 @@ namespace Aktywator
bSync.Enabled = true;
bAutoSync.Enabled = true;
eInterval.Enabled = true;
- if (tournament.type == MySQLTournament.TYPE_TEAMY)
+ if (tournament.GetType().Equals(typeof(TeamyTournament)))
{
lSkok.Visible = true;
lNazwyTeamow.Visible = true;
@@ -209,6 +209,7 @@ namespace Aktywator
{
lSkok.Visible = false;
lNazwyTeamow.Visible = false;
+
}
}
diff --git a/Aktywator/MySQLTournament.cs b/Aktywator/MySQLTournament.cs
index 54f3f7b..ff3258a 100644
--- a/Aktywator/MySQLTournament.cs
+++ b/Aktywator/MySQLTournament.cs
@@ -6,24 +6,8 @@ using data = MySql.Data.MySqlClient.MySqlDataReader;
namespace Aktywator
{
- public class MySQLTournament
+ public class MySQLTournament : Tournament
{
- public const int TYPE_PARY = 1;
- public const int TYPE_TEAMY = 2;
- public const int TYPE_UNKNOWN = 0;
-
- private string _name;
- public string name
- {
- get { return _name; }
- }
-
- private int _type; // 0-unknown, 1-Pary, 2-Teamy
- public int type
- {
- get { return _type; }
- }
-
public MySQL mysql;
public MySQLTournament(string name)
@@ -38,17 +22,17 @@ namespace Aktywator
if ((mysql.selectOne("SHOW TABLES LIKE 'admin'") == "admin")
&& (mysql.selectOne("SHOW FIELDS IN admin LIKE 'dnazwa'") == "dnazwa")
&& (mysql.selectOne("SHOW TABLES LIKE 'zawodnicy'") == "zawodnicy"))
- _type = MySQLTournament.TYPE_PARY;
+ _type = Tournament.TYPE_PARY;
else if ((mysql.selectOne("SHOW TABLES LIKE 'admin'") == "admin")
&& (mysql.selectOne("SHOW FIELDS IN admin LIKE 'teamcnt'") == "teamcnt")
&& (mysql.selectOne("SHOW TABLES LIKE 'players'") == "players"))
- _type = MySQLTournament.TYPE_TEAMY;
- else _type = MySQLTournament.TYPE_UNKNOWN;
+ _type = Tournament.TYPE_TEAMY;
+ else _type = Tournament.TYPE_UNKNOWN;
}
public override string ToString()
{
- return this.name + " [" + (this.type == MySQLTournament.TYPE_PARY ? 'P' : 'T') + "]";
+ return this.name + " [" + (this.type == Tournament.TYPE_PARY ? 'P' : 'T') + "]";
}
public static List<MySQLTournament> getTournaments()
@@ -59,31 +43,14 @@ namespace Aktywator
while (dbs.Read())
{
MySQLTournament t = new MySQLTournament(dbs.GetString(0));
- if (t.type > MySQLTournament.TYPE_UNKNOWN)
+ if (t.type > Tournament.TYPE_UNKNOWN)
list.Add(t);
t.mysql.close();
}
return list;
}
- public string getSectionsNum()
- {
- if (type == MySQLTournament.TYPE_PARY)
- return mysql.selectOne("SELECT COUNT(DISTINCT seknum) FROM sektory;");
- else
- return "1";
- }
-
- public string getTablesNum()
- {
- if (type == MySQLTournament.TYPE_PARY)
- return mysql.selectOne("SELECT COUNT(*) FROM sektory;");
- else
- return mysql.selectOne("SELECT teamcnt FROM admin;");
- }
-
-
- internal void setup()
+ override internal void setup()
{
if (this.mysql != null)
{
@@ -92,14 +59,26 @@ namespace Aktywator
}
}
- internal string getName()
+ override internal string getName()
{
return this.name;
}
- internal string getTypeLabel()
+ override public string getSectionsNum()
+ {
+ throw new NotImplementedException("Don't call this method on generic class instance");
+ }
+
+ override public string getTablesNum()
{
- return this._type == MySQLTournament.TYPE_PARY ? "Pary" : "Teamy";
+ throw new NotImplementedException("Don't call this method on generic class instance");
}
+
+ override internal string getTypeLabel()
+ {
+ throw new NotImplementedException("Don't call this method on generic class instance");
+ }
+
}
}
+
diff --git a/Aktywator/ParyTournament.cs b/Aktywator/ParyTournament.cs
new file mode 100644
index 0000000..8d80d9f
--- /dev/null
+++ b/Aktywator/ParyTournament.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Aktywator
+{
+ class ParyTournament: MySQLTournament
+ {
+ public ParyTournament(string name)
+ : base(name)
+ {
+ }
+
+ override internal string getTypeLabel()
+ {
+ return "Pary";
+ }
+
+ override public string getSectionsNum()
+ {
+ return this.mysql.selectOne("SELECT COUNT(DISTINCT seknum) FROM sektory;");
+ }
+
+ override public string getTablesNum()
+ {
+ return this.mysql.selectOne("SELECT COUNT(*) FROM sektory;");
+ }
+
+ }
+}
diff --git a/Aktywator/TeamyTournament.cs b/Aktywator/TeamyTournament.cs
new file mode 100644
index 0000000..34908be
--- /dev/null
+++ b/Aktywator/TeamyTournament.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Aktywator
+{
+ class TeamyTournament : MySQLTournament
+ {
+ public TeamyTournament(string name)
+ : base(name)
+ {
+ }
+
+ override internal string getTypeLabel()
+ {
+ return "Teamy";
+ }
+
+ override public string getSectionsNum()
+ {
+ return "1";
+ }
+
+ override public string getTablesNum()
+ {
+ return this.mysql.selectOne("SELECT teamcnt FROM admin;");
+ }
+
+ }
+}
diff --git a/Aktywator/Tournament.cs b/Aktywator/Tournament.cs
new file mode 100644
index 0000000..fdeb323
--- /dev/null
+++ b/Aktywator/Tournament.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Aktywator
+{
+ abstract public class Tournament
+ {
+ public const int TYPE_PARY = 1;
+ public const int TYPE_TEAMY = 2;
+ public const int TYPE_UNKNOWN = 0;
+
+ protected string _name;
+ public string name
+ {
+ get { return _name; }
+ }
+
+ protected int _type; // 0-unknown, 1-Pary, 2-Teamy
+ public int type
+ {
+ get { return _type; }
+ }
+
+ abstract internal void setup();
+
+ abstract internal string getName();
+
+ abstract public string getSectionsNum();
+
+ abstract public string getTablesNum();
+
+ abstract internal string getTypeLabel();
+
+ }
+}