summaryrefslogtreecommitdiff
path: root/Aktywator/ParyTournament.cs
diff options
context:
space:
mode:
authorMichał Zimniewicz <michzimny@users.noreply.github.com>2018-10-05 15:42:40 +0200
committerGitHub <noreply@github.com>2018-10-05 15:42:40 +0200
commit97622b13166643aba599c167bb6dbb04fcc055cf (patch)
treef84052b926f5dc56b376908dce9cd4a610774ebc /Aktywator/ParyTournament.cs
parent397dc4a9d17fe517f83ac85ec27dd347589b1f96 (diff)
parente6b05c1de6ff45e012d986b721bbbdfb11f3ee37 (diff)
Merge pull request #45 from emkael/master
v1.1.4
Diffstat (limited to 'Aktywator/ParyTournament.cs')
-rw-r--r--Aktywator/ParyTournament.cs33
1 files changed, 31 insertions, 2 deletions
diff --git a/Aktywator/ParyTournament.cs b/Aktywator/ParyTournament.cs
index 0c9209f..2fdf360 100644
--- a/Aktywator/ParyTournament.cs
+++ b/Aktywator/ParyTournament.cs
@@ -2,20 +2,41 @@
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;
+using System.Windows.Forms;
namespace Aktywator
{
class ParyTournament: MySQLTournament
{
+ private bool _indy = false;
+
public ParyTournament(string name, int type = Tournament.TYPE_PARY)
: base(name, type)
{
this._type = Tournament.TYPE_PARY;
+ this._indy = this.isIndy();
}
override internal string getTypeLabel()
{
- return "Pary";
+ string label = "Pary";
+ if (this._indy)
+ {
+ label += " (indywiduel)";
+ MessageBox.Show(
+ "Nazwiska w turnieju indywidualnym są wyświetlane PARAMI, według rozstawienia w pierwszej rundzie.\n" +
+ "Używać TYLKO dla turniejów typu Finał GPPP ze stałym skojarzeniem par!",
+ "Nazwiska w turnieju indywidualnym", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ }
+ return label;
+ }
+
+ private bool isIndy()
+ {
+ this.setup();
+ bool pary;
+ Boolean.TryParse(this.mysql.selectOne("SELECT pary FROM admin;"), out pary);
+ return !pary;
}
override public string getSectionsNum()
@@ -31,7 +52,15 @@ namespace Aktywator
override internal Dictionary<int, List<string>> getNameList()
{
Dictionary<int, List<String>> pairs = new Dictionary<int, List<string>>();
- MySqlDataReader dbData = this.mysql.select("SELECT idp, CONCAT(imie, ' ', nazw) name FROM zawodnicy ORDER BY idp");
+ string query = this._indy ?
+ "SELECT pairs.pair, CONCAT(zawodnicy.imie, ' ', zawodnicy.nazw) name FROM ( " +
+ "SELECT zN player, zN pair, 0 in_pair FROM zapisy WHERE rnd = 1 GROUP BY zN UNION " +
+ "SELECT zS player, zN pair, 1 in_pair FROM zapisy WHERE rnd = 1 GROUP BY zN UNION " +
+ "SELECT zE player, zE pair, 0 in_pair FROM zapisy WHERE rnd = 1 GROUP BY zN UNION " +
+ "SELECT zW player, zE pair, 1 in_pair FROM zapisy WHERE rnd = 1 GROUP BY zN " +
+ ") pairs JOIN zawodnicy ON pairs.player = zawodnicy.id ORDER BY pairs.pair, pairs.in_pair;" :
+ "SELECT idp, CONCAT(imie, ' ', nazw) name FROM zawodnicy ORDER BY idp";
+ MySqlDataReader dbData = this.mysql.select(query);
while (dbData.Read())
{
int pairNo = dbData.GetInt32(0);