From 04ddfb636057d72381ce8c69c3ab81422b1d11a4 Mon Sep 17 00:00:00 2001 From: emkael Date: Tue, 20 Mar 2018 20:52:41 +0100 Subject: Names for individual tournaments from JFR Pary Fixes #30 --- Aktywator/ParyTournament.cs | 33 +++++++++++++++++++++++++++++++-- Aktywator/Resources/BuildDate.txt | 2 +- 2 files changed, 32 insertions(+), 3 deletions(-) (limited to 'Aktywator') 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> getNameList() { Dictionary> pairs = new Dictionary>(); - 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); diff --git a/Aktywator/Resources/BuildDate.txt b/Aktywator/Resources/BuildDate.txt index fb76437..c28b5ac 100644 --- a/Aktywator/Resources/BuildDate.txt +++ b/Aktywator/Resources/BuildDate.txt @@ -1 +1 @@ -2018-02-04 +2018-03-20 -- cgit v1.2.3