summaryrefslogtreecommitdiff
path: root/Aktywator
diff options
context:
space:
mode:
Diffstat (limited to 'Aktywator')
-rw-r--r--Aktywator/Bws.cs315
-rw-r--r--Aktywator/MainForm.Designer.cs41
-rw-r--r--Aktywator/MainForm.cs27
-rw-r--r--Aktywator/MainForm.resx4
-rw-r--r--Aktywator/ParyTournament.cs33
-rw-r--r--Aktywator/Properties/AssemblyInfo.cs4
-rw-r--r--Aktywator/Resources/BuildDate.txt2
-rw-r--r--Aktywator/Setting.cs8
8 files changed, 274 insertions, 160 deletions
diff --git a/Aktywator/Bws.cs b/Aktywator/Bws.cs
index e589418..9121eb1 100644
--- a/Aktywator/Bws.cs
+++ b/Aktywator/Bws.cs
@@ -27,11 +27,22 @@ namespace Aktywator
public bool analysis = false;
}
+ class PairPosition
+ {
+ public int pairNo;
+ public int table;
+ public string position;
+ }
+
public Bws(string filename, MainForm main)
{
this._filename = filename;
sql = new Sql(filename);
this.main = main;
+ }
+
+ public void init()
+ {
string[] sections = this.getSections().Split(',');
this.displaySectionBoardsInfo(sections);
}
@@ -108,6 +119,16 @@ namespace Aktywator
this.setHandRecordInfo(board.Key);
}
}
+ main.xShowResults_CheckedChanged(null, EventArgs.Empty);
+ if (this.detectDifferentRecordsInSections())
+ {
+ if (main.xGroupSections.Checked)
+ {
+ MessageBox.Show(MainForm.differentRecordsInSections, "Ustawienia grupowania zapisów w sektorach", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ main.xGroupSections.Checked = false;
+ }
+ Setting.saveSectionGroups(this.sql, main.xGroupSections.Checked);
+ }
}
private void setHandRecordInfo(int board, string section = null, List<string> layout = null, bool analysis = false)
@@ -369,13 +390,14 @@ namespace Aktywator
{
}
+ this._ensureHandRecordStructure();
+
try
{
- sql.query("CREATE TABLE HandRecord (`Section` integer, `Board` integer, "
- + "NorthSpades text(13),NorthHearts text(13),NorthDiamonds text(13),NorthClubs text(13),"
- + "EastSpades text(13),EastHearts text(13),EastDiamonds text(13),EastClubs text(13),"
- + "SouthSpades text(13),SouthHearts text(13),SouthDiamonds text(13),SouthClubs text(13),"
- + "WestSpades text(13),WestHearts text(13),WestDiamonds text(13),WestClubs text(13)"
+ sql.query("CREATE TABLE PlayData ("
+ + "`ID` autoincrement, `Section` integer, `Table` integer, `Round` integer, `Board` integer,"
+ + "`Counter` integer, `Direction` text(2), `Card` text(10), `DateLog` datetime,"
+ + "`TimeLog` datetime, `Erased` bit"
+ ");");
}
catch (OleDbException)
@@ -383,23 +405,26 @@ namespace Aktywator
}
try
{
- sql.query("CREATE TABLE HandEvaluation (`Section` integer, `Board` integer, "
- + "NorthSpades integer,NorthHearts integer,NorthDiamonds integer,NorthClubs integer,NorthNotrump integer,"
- + "EastSpades integer,EastHearts integer,EastDiamonds integer,EastClubs integer,EastNotrump integer,"
- + "SouthSpades integer,SouthHearts integer,SouthDiamonds integer,SouthClubs integer,SouthNotrump integer,"
- + "WestSpades integer,WestHearts integer,WestDiamonds integer,WestClubs integer,WestNotrump integer,"
- + "NorthHcp integer,EastHcp integer,SouthHcp integer,WestHcp integer"
+ sql.query("CREATE TABLE BiddingData ("
+ + "`ID` autoincrement, `Section` integer, `Table` integer, `Round` integer, `Board` integer,"
+ + "`Counter` integer, `Direction` text(2), `Bid` text(10), `DateLog` datetime,"
+ + "`TimeLog` datetime, `Erased` bit"
+ ");");
}
catch (OleDbException)
{
}
+ }
+
+ private void _ensureHandRecordStructure()
+ {
try
{
- sql.query("CREATE TABLE PlayData ("
- + "`ID` autoincrement, `Section` integer, `Table` integer, `Round` integer, `Board` integer,"
- + "`Counter` integer, `Direction` text(2), `Card` text(10), `DateLog` datetime,"
- + "`TimeLog` datetime, `Erased` bit"
+ sql.query("CREATE TABLE HandRecord (`Section` integer, `Board` integer, "
+ + "NorthSpades text(13),NorthHearts text(13),NorthDiamonds text(13),NorthClubs text(13),"
+ + "EastSpades text(13),EastHearts text(13),EastDiamonds text(13),EastClubs text(13),"
+ + "SouthSpades text(13),SouthHearts text(13),SouthDiamonds text(13),SouthClubs text(13),"
+ + "WestSpades text(13),WestHearts text(13),WestDiamonds text(13),WestClubs text(13)"
+ ");");
}
catch (OleDbException)
@@ -407,10 +432,12 @@ namespace Aktywator
}
try
{
- sql.query("CREATE TABLE BiddingData ("
- + "`ID` autoincrement, `Section` integer, `Table` integer, `Round` integer, `Board` integer,"
- + "`Counter` integer, `Direction` text(2), `Bid` text(10), `DateLog` datetime,"
- + "`TimeLog` datetime, `Erased` bit"
+ sql.query("CREATE TABLE HandEvaluation (`Section` integer, `Board` integer, "
+ + "NorthSpades integer,NorthHearts integer,NorthDiamonds integer,NorthClubs integer,NorthNotrump integer,"
+ + "EastSpades integer,EastHearts integer,EastDiamonds integer,EastClubs integer,EastNotrump integer,"
+ + "SouthSpades integer,SouthHearts integer,SouthDiamonds integer,SouthClubs integer,SouthNotrump integer,"
+ + "WestSpades integer,WestHearts integer,WestDiamonds integer,WestClubs integer,WestNotrump integer,"
+ + "NorthHcp integer,EastHcp integer,SouthHcp integer,WestHcp integer"
+ ");");
}
catch (OleDbException)
@@ -503,7 +530,7 @@ namespace Aktywator
public void sectionGroupWarning()
{
main.lGroupSectionsWarning.Visible = false;
- if (main.xShowResults.Checked)
+ if (main.xShowResults.Checked || this.detectDifferentRecordsInSections())
{
main.lGroupSectionsWarning.Visible = true;
}
@@ -541,15 +568,7 @@ namespace Aktywator
Setting.save("BM2NameSource", "2", this, errors, section);
Setting.save("BM2PINcode", "'" + main.xPINcode.Text + "'", this, errors, section);
Setting.save("BM2ResultsOverview", main.xResultsOverview.SelectedIndex.ToString(), this, errors, section);
- if (main.xGroupSections.Checked)
- {
- sql.query("UPDATE Tables SET `Group` = 1;");
- }
- else
- {
- sql.query("UPDATE Tables SET `Group` = `Section`;");
- }
-
+ Setting.saveSectionGroups(this.sql, main.xGroupSections.Checked);
this.loadSettings();
}
@@ -590,101 +609,171 @@ namespace Aktywator
throw new InvalidCastException("Unable to read numeric value from BWS field");
}
- public void syncNames(Tournament tournament, bool interactive, string startRounds, string section, DataGridView grid)
+ public void syncNames(Tournament tournament, bool interactive, string section, DataGridView grid)
{
int count = 0, countNew = 0, SKOK_STOLOW = Convert.ToInt32(main.numTeamsTableOffset.Value);
- OleDbDataReader d;
- startRounds = startRounds.Trim();
- string fromRound = sql.selectOne("SELECT min(`Round`) FROM RoundData WHERE NSPair>0");
- string sectionCondition = "";
- if (!("*".Equals(section)))
+ OleDbDataReader roundsReader = sql.select("SELECT `Section`, MIN(`Round`) FROM RoundData WHERE LowBoard > 0 GROUP BY `Section`;");
+ Dictionary<int, int> firstRounds = new Dictionary<int, int>();
+ while (roundsReader.Read())
+ {
+ firstRounds.Add(this.getBWSNumber(roundsReader, 0), this.getBWSNumber(roundsReader, 1));
+ }
+ roundsReader.Close();
+ if (firstRounds.Count == 0)
+ {
+ MessageBox.Show("W BWSie nie ma danych rund!", "Brak danych", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ StringBuilder pairsQuery = new StringBuilder("SELECT `Section`, `Table`, NSPair, EWPair FROM RoundData WHERE (");
+ List<string> roundQueries = new List<string>();
+ foreach (KeyValuePair<int, int> firstRound in firstRounds)
{
- section = this.sectorLetterToNumber(section).ToString();
- sectionCondition = " AND `Section` = " + section;
+ StringBuilder roundQuery = new StringBuilder("(`Round` = ");
+ roundQuery.Append(firstRound.Value);
+ roundQuery.Append(" AND `Section` = ");
+ roundQuery.Append(firstRound.Key);
+ roundQuery.Append(")");
+ roundQueries.Add(roundQuery.ToString());
}
- if (tournament.type != Tournament.TYPE_TEAMY)
+ pairsQuery.Append(String.Join(" OR ", roundQueries.ToArray()));
+ pairsQuery.Append(")");
+ if (tournament.type == Tournament.TYPE_TEAMY)
{
- if (tournament.type == Tournament.TYPE_PARY && startRounds.Length > 0)
+ pairsQuery.Append(" AND `Table` <= ");
+ pairsQuery.Append(SKOK_STOLOW);
+ }
+ pairsQuery.Append(";");
+
+ OleDbDataReader d;
+ d = sql.select(pairsQuery.ToString());
+
+ Dictionary<int, List<int>> sectionPairs = new Dictionary<int, List<int>>();
+ Dictionary<int, List<PairPosition>> pairs = new Dictionary<int, List<PairPosition>>();
+ while (d.Read())
+ {
+ int sectionNumber = this.getBWSNumber(d, 0);
+ int tableNumber = this.getBWSNumber(d, 1);
+ int nsPairNumber = this.getBWSNumber(d, 2);
+ int ewPairNumber = this.getBWSNumber(d, 3);
+ if (!sectionPairs.ContainsKey(sectionNumber))
{
- d = sql.select("SELECT `Section`, `Table`, NSPair, EWPair FROM RoundData WHERE NSPair>0 AND `Round` in (" + startRounds + ")" + sectionCondition);
+ sectionPairs.Add(sectionNumber, new List<int>());
}
- else
+ sectionPairs[sectionNumber].Add(nsPairNumber);
+ sectionPairs[sectionNumber].Add(ewPairNumber);
+ if (!pairs.ContainsKey(sectionNumber))
{
- d = sql.select("SELECT `Section`, `Table`, NSPair, EWPair FROM RoundData WHERE `Round`=" + fromRound + sectionCondition);
+ pairs.Add(sectionNumber, new List<PairPosition>());
}
+ pairs[sectionNumber].Add(new PairPosition { pairNo = nsPairNumber, position = "NS", table = tableNumber });
+ pairs[sectionNumber].Add(new PairPosition { pairNo = ewPairNumber, position = "EW", table = tableNumber });
}
- else
- {
- d = sql.select("SELECT `Section`, `Table`, NSPair, EWPair FROM RoundData WHERE `Round`=" + fromRound + " AND `Table`<=" + SKOK_STOLOW + sectionCondition);
- }
+ d.Close();
- try
- {
- Dictionary<int, List<String>> names = tournament.getBWSNames(grid);
+ Dictionary<int, List<String>> names = tournament.getBWSNames(grid);
- while (d.Read())
+ Dictionary<int, List<int>> usedSections = new Dictionary<int, List<int>>();
+ List<int> extraPairs = new List<int>();
+ foreach (KeyValuePair<int, List<String>> pair in names)
+ {
+ bool foundInBWS = false;
+ foreach (KeyValuePair<int, List<int>> pairsInSection in sectionPairs)
{
- string pairSection = "*".Equals(section) ? this.getBWSNumber(d, 0).ToString() : section;
- string table = this.getBWSNumber(d, 1).ToString();
- int ns = this.getBWSNumber(d, 2);
- int ew = this.getBWSNumber(d, 3);
-
- try
+ if (pairsInSection.Value.Contains(pair.Key))
{
- if (!names.ContainsKey(ns))
- {
- throw new KeyNotFoundException(ns.ToString());
- }
- countNew += updateName(pairSection, table, "N", names[ns][0]);
- countNew += updateName(pairSection, table, "S", names[ns][1]);
- count += 2;
- if (tournament.type == Tournament.TYPE_TEAMY)
+ if (!usedSections.ContainsKey(pairsInSection.Key))
{
- countNew += updateName(pairSection, (int.Parse(table) + SKOK_STOLOW).ToString(), "E",
- names.ContainsKey(ns + TeamNamesSettings.OpenClosedDiff) ? names[ns + TeamNamesSettings.OpenClosedDiff][0] : names[ns][0]);
- countNew += updateName(pairSection, (int.Parse(table) + SKOK_STOLOW).ToString(), "W",
- names.ContainsKey(ns + TeamNamesSettings.OpenClosedDiff) ? names[ns + TeamNamesSettings.OpenClosedDiff][1] : names[ns][1]);
- count += 2;
+ usedSections.Add(pairsInSection.Key, new List<int>());
}
+ usedSections[pairsInSection.Key].Add(pair.Key);
+ foundInBWS = true;
}
- catch (KeyNotFoundException keyE)
- {
- if (interactive)
- {
- DialogResult dr = MessageBox.Show("W bws-ie jest para/team (" + keyE.Message + ")"
- + ", który nie istnieje w wybranym turnieju."
- + "Może to nie ten turniej?" + "\n\n" + "Kontynuować wczytywanie?",
- "Zły turniej", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
- if (dr == DialogResult.No) break;
- }
- }
- try
+ }
+ if (!foundInBWS) {
+ extraPairs.Add(pair.Key);
+ }
+ }
+
+ if (interactive) {
+ List<string> warnings = new List<string>();
+ foreach (KeyValuePair<int, List<int>> sectionData in sectionPairs)
+ {
+ if (this.sectorNumberToLetter(sectionData.Key).Equals(section) || "*".Equals(section))
{
- if (!names.ContainsKey(ew))
+ if (!usedSections.ContainsKey(sectionData.Key))
{
- throw new KeyNotFoundException(ew.ToString());
+ warnings.Add(" - w turnieju nie ma par dla sektora " + this.sectorNumberToLetter(sectionData.Key));
}
- countNew += updateName(pairSection, table, "E", names[ew][0]);
- countNew += updateName(pairSection, table, "W", names[ew][1]);
- count += 2;
- if (tournament.type == Tournament.TYPE_TEAMY)
+ else
{
- countNew += updateName(pairSection, (int.Parse(table) + SKOK_STOLOW).ToString(), "N",
- names.ContainsKey(ns + TeamNamesSettings.OpenClosedDiff) ? names[ew + TeamNamesSettings.OpenClosedDiff][0] : names[ew][0]);
- countNew += updateName(pairSection, (int.Parse(table) + SKOK_STOLOW).ToString(), "S",
- names.ContainsKey(ns + TeamNamesSettings.OpenClosedDiff) ? names[ew + TeamNamesSettings.OpenClosedDiff][1] : names[ew][1]);
- count += 2;
+ List<int> missingPairs = new List<int>();
+ foreach (int pair in sectionData.Value)
+ {
+ if (!usedSections[sectionData.Key].Contains(pair))
+ {
+ missingPairs.Add(pair);
+ }
+ }
+ if (missingPairs.Count > 0)
+ {
+ StringBuilder warning = new StringBuilder(" - w sektorze ");
+ warning.Append(this.sectorNumberToLetter(sectionData.Key));
+ warning.Append(" brakuje ");
+ warning.Append(missingPairs.Count);
+ warning.Append(" par:");
+ foreach (int pair in missingPairs)
+ {
+ warning.Append(' ');
+ warning.Append(pair);
+ }
+ warnings.Add(warning.ToString());
+ }
}
}
- catch (KeyNotFoundException keyE)
+ }
+ if (extraPairs.Count > 0)
+ {
+ StringBuilder warning = new StringBuilder(" - w BWS nie ma w ogóle ");
+ warning.Append(extraPairs.Count);
+ warning.Append(" par:");
+ foreach (int pair in extraPairs)
{
- if (interactive)
- {
- DialogResult dr = MessageBox.Show("W bws-ie jest para/team (" + keyE.Message + ")"
- + ", który nie istnieje w wybranym turnieju."
- + "Może to nie ten turniej?" + "\n\n" + "Kontynuować wczytywanie?",
- "Zły turniej", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
- if (dr == DialogResult.No) break;
+ warning.Append(' ');
+ warning.Append(pair);
+ }
+ warnings.Add(warning.ToString());
+ }
+
+ if (warnings.Count > 0)
+ {
+ DialogResult warningDialog = MessageBox.Show("Wykryto potencjalne problemy z wczytaniem nazwisk: \n\n" + String.Join("\n", warnings.ToArray()) + "\n\nCzy chcesz wczytać nazwiska mimo wszystko?", "Problemy z nazwiskami", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
+ if (warningDialog == DialogResult.No)
+ {
+ return;
+ }
+ }
+ }
+
+ try
+ {
+ int sectionNumber = 0;
+ if (!"*".Equals(section)) {
+ sectionNumber = this.sectorLetterToNumber(section);
+ }
+ char[] seatMapping = { 'N', 'S', 'E', 'W' };
+ foreach (KeyValuePair<int, List<int>> sections in usedSections) {
+ if ("*".Equals(section) || sectionNumber == sections.Key) {
+ foreach (int pairNumber in sections.Value) {
+ PairPosition pair = pairs[sections.Key].Find(delegate(PairPosition p) { return p.pairNo == pairNumber; });
+ for (int i = 0; i < names[pair.pairNo].Count; i++) {
+ countNew += this.updateName(sections.Key.ToString(), pair.table.ToString(), pair.position[i].ToString(), names[pair.pairNo][i]);
+ if (tournament.type == Tournament.TYPE_TEAMY)
+ {
+ char otherTableSeat = seatMapping[(Array.IndexOf(seatMapping, pair.position[i]) + 2) % 4];
+ countNew += this.updateName(sections.Key.ToString(), (pair.table + SKOK_STOLOW).ToString(), otherTableSeat.ToString(), names[pair.pairNo][i]);
+ }
+ }
+ count += names[pair.pairNo].Count * ((tournament.type == Tournament.TYPE_TEAMY) ? 2 : 1);
}
}
}
@@ -768,6 +857,7 @@ namespace Aktywator
{
sql.query("DELETE FROM HandRecord WHERE `Section` = " + section);
sql.query("DELETE FROM HandEvaluation WHERE `Section` = " + section);
+ this._differentRecordsDetected = false;
}
public void clearHandRecords()
@@ -849,6 +939,31 @@ namespace Aktywator
return count;
}
+ private bool _differentRecordsDetected = false;
+ private bool _differentRecordsInSections = false;
+
+ public bool detectDifferentRecordsInSections()
+ {
+ this._ensureHandRecordStructure();
+ if (!this._differentRecordsDetected)
+ {
+ this._differentRecordsInSections = false;
+ OleDbDataReader sections = sql.select("SELECT DISTINCT COUNT(`Section`) FROM HandRecord GROUP BY Board, NorthSpades, NorthHearts, NorthDiamonds, NorthClubs, EastSpades, EastHearts, EastDiamonds, EastClubs, SouthSpades, SouthHearts, SouthDiamonds, SouthClubs");
+ while (sections.Read())
+ {
+ int boardSections = this.getBWSNumber(sections, 0);
+ int bwsSections = main.gwSections.Rows.Count;
+ if (boardSections != bwsSections)
+ {
+ this._differentRecordsInSections = true;
+ break;
+ }
+ }
+ this._differentRecordsDetected = true;
+ }
+ return this._differentRecordsInSections;
+ }
+
internal string getMySQLDatabaseForSection()
{
try
diff --git a/Aktywator/MainForm.Designer.cs b/Aktywator/MainForm.Designer.cs
index 7485e01..f8b03b9 100644
--- a/Aktywator/MainForm.Designer.cs
+++ b/Aktywator/MainForm.Designer.cs
@@ -90,9 +90,6 @@
this.xResultsOverview = new System.Windows.Forms.ComboBox();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.sectionToolStrip = new System.Windows.Forms.ToolStrip();
- this.eOomRounds = new System.Windows.Forms.ToolStripTextBox();
- this.lOomLabel = new System.Windows.Forms.ToolStripLabel();
- this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel();
this.cbNamesSection = new System.Windows.Forms.ToolStripComboBox();
this.namesPanel = new System.Windows.Forms.Panel();
@@ -802,9 +799,6 @@
this.sectionToolStrip.GripMargin = new System.Windows.Forms.Padding(0);
this.sectionToolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
this.sectionToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.eOomRounds,
- this.lOomLabel,
- this.toolStripButton2,
this.toolStripLabel1,
this.cbNamesSection});
this.sectionToolStrip.Location = new System.Drawing.Point(3, 458);
@@ -813,38 +807,6 @@
this.sectionToolStrip.TabIndex = 30;
this.sectionToolStrip.Text = "toolStrip5";
//
- // eOomRounds
- //
- this.eOomRounds.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
- this.eOomRounds.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.eOomRounds.Enabled = false;
- this.eOomRounds.Name = "eOomRounds";
- this.eOomRounds.Size = new System.Drawing.Size(80, 25);
- this.eOomRounds.ToolTipText = "Jeśli nie wiesz do czego to jest, to nic nie wpisuj!";
- //
- // lOomLabel
- //
- this.lOomLabel.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
- this.lOomLabel.Enabled = false;
- this.lOomLabel.Name = "lOomLabel";
- this.lOomLabel.Size = new System.Drawing.Size(92, 22);
- this.lOomLabel.Text = "Rundy dla OOM";
- this.lOomLabel.ToolTipText = "Jeśli nie wiesz do czego to jest, to nic nie wpisuj!";
- //
- // toolStripButton2
- //
- this.toolStripButton2.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
- this.toolStripButton2.BackColor = System.Drawing.Color.Transparent;
- this.toolStripButton2.CheckOnClick = true;
- this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
- this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
- this.toolStripButton2.Name = "toolStripButton2";
- this.toolStripButton2.Size = new System.Drawing.Size(23, 22);
- this.toolStripButton2.Text = "‎✔";
- this.toolStripButton2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
- this.toolStripButton2.ToolTipText = "Jeśli nie wiesz do czego to jest, to nic nie wpisuj!";
- this.toolStripButton2.CheckedChanged += new System.EventHandler(this.toolStripButton2_CheckedChanged);
- //
// toolStripLabel1
//
this.toolStripLabel1.Name = "toolStripLabel1";
@@ -1620,9 +1582,6 @@
private System.Windows.Forms.ToolStripButton bTruncate;
private System.Windows.Forms.ToolStripButton bAutoSync;
private System.Windows.Forms.ToolStripTextBox eInterval;
- private System.Windows.Forms.ToolStripTextBox eOomRounds;
- private System.Windows.Forms.ToolStripLabel lOomLabel;
- private System.Windows.Forms.ToolStripButton toolStripButton2;
private System.Windows.Forms.DataGridView namesGridView;
private System.Windows.Forms.Panel namesPanel;
public System.Windows.Forms.NumericUpDown numTeamsTableOffset;
diff --git a/Aktywator/MainForm.cs b/Aktywator/MainForm.cs
index bb6a45e..6284419 100644
--- a/Aktywator/MainForm.cs
+++ b/Aktywator/MainForm.cs
@@ -65,6 +65,7 @@ namespace Aktywator
}
bws = new Bws(filename, this);
+ bws.init();
bws.convert();
labelFilename.Text = filename;
@@ -320,14 +321,17 @@ namespace Aktywator
bws.loadSettings();
}
- private void xShowResults_CheckedChanged(object sender, EventArgs e)
+ static public string sectionGroupWarningLabel = "Opcja grupowania zapisów w sektorach (albo osobnego maksowania sektorów) nie może być zaktualizowana w trakcie trwania sesji!";
+ static public string differentRecordsInSections = "BWS zawiera różne rozkłady w różnych sektorach, opcja grupowania sektorów musi być wyłączona.";
+
+ public void xShowResults_CheckedChanged(object sender, EventArgs e)
{
if (xShowResults.Checked)
{
xRepeatResults.Enabled = true;
xShowPercentage.Enabled = true;
xResultsOverview.Enabled = true;
- xGroupSections.Enabled = true;
+ xGroupSections.Enabled = !bws.detectDifferentRecordsInSections();
}
else
{
@@ -337,10 +341,14 @@ namespace Aktywator
xResultsOverview.Enabled = false;
xGroupSections.Enabled = false;
}
- if (cbSettingsSection.Items.Count > 2)
+ if (cbSettingsSection.Items.Count > 2 || bws.detectDifferentRecordsInSections())
{
bws.sectionGroupWarning();
}
+ if (cbSettingsSection.Items.Count <= 2)
+ {
+ xGroupSections.Enabled = false;
+ }
}
private void xMemberNumbers_CheckedChanged(object sender, EventArgs e)
@@ -450,7 +458,7 @@ namespace Aktywator
{
try
{
- bws.syncNames(tournament, true, eOomRounds.Text, cbNamesSection.SelectedItem.ToString(), namesGridView);
+ bws.syncNames(tournament, true, cbNamesSection.SelectedItem.ToString(), namesGridView);
}
catch (Exception ee)
{
@@ -505,7 +513,7 @@ namespace Aktywator
private void timer_Tick(object sender, EventArgs e)
{
- bws.syncNames(tournament, false, eOomRounds.Text, cbNamesSection.SelectedItem.ToString(), namesGridView);
+ bws.syncNames(tournament, false, cbNamesSection.SelectedItem.ToString(), namesGridView);
}
private void bForceSync_Click(object sender, EventArgs e)
@@ -580,12 +588,6 @@ namespace Aktywator
toolStripSplitButton1.ShowDropDown();
}
- private void toolStripButton2_CheckedChanged(object sender, EventArgs e)
- {
- eOomRounds.Enabled = toolStripButton2.Checked;
- lOomLabel.Enabled = toolStripButton2.Checked;
- }
-
private void namesGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex > -1 && e.ColumnIndex > 0)
@@ -637,7 +639,8 @@ namespace Aktywator
private void lGroupSectionsWarning_Click(object sender, EventArgs e)
{
- MessageBox.Show("Opcja grupowania zapisów w sektorach (albo osobnego maksowania sektorów) nie może być zaktualizowana w trakcie trwania sesji!", "Ustawienia grupowania zapisów w sektorach", MessageBoxButtons.OK, MessageBoxIcon.Question);
+ string message = bws.detectDifferentRecordsInSections() ? MainForm.differentRecordsInSections : MainForm.sectionGroupWarningLabel;
+ MessageBox.Show(message, "Ustawienia grupowania zapisów w sektorach", MessageBoxButtons.OK, MessageBoxIcon.Question);
}
private void bTeamsNamesSettings_Click(object sender, EventArgs e)
diff --git a/Aktywator/MainForm.resx b/Aktywator/MainForm.resx
index a60549f..11af55c 100644
--- a/Aktywator/MainForm.resx
+++ b/Aktywator/MainForm.resx
@@ -340,7 +340,7 @@
S5vmPfe+JjvtcklE6MUrYYEbmdtDfF9ayn2gKP5L/6d/QueutWjblIOunWvQezgfd/74BmoPvHwuwN7e
mZGPOdVz5pg0Lc/JVm/IvXF77xZ0bl6BusRpOOPujCXm7LNiXd1EkhkPir9vUQU/VBS2aV7bhaaceWhe
ngT1moVo35yDzh2r0bV7Le6/9hLUeXn/3D5j+ubBTmOEMjqaV580N7/zxRd77r1zEANv5KNx8XycdZUj
- 1dj4Y1MWawbJBENqImHqVP8jeXnfd+Q9T8bPQevqDKjXZ6Ej7wV07d0Izf48dB/Yju7929D/yhbg8E7c
+ 1dj4Y1MWawbJBENqImHqVP/DeXnfd+Q9T8bPQevqDKjXZ6Ej7wV07d0Izf48dB/Yju7929D/yhbg8E7c
WLpIESgSeTNDjBoNqQs2t6xf33/33SN4+OGb6MjfiOuTw5FnafmVLUtnIUlsh5Q/4ui2LTvxwZtQ06q3
r8uEekM22retJONfRDftSPeRPeg5mo/eQ7vQSxPppUn8q2AD7mxcgY2hwauZYf4vVFlZz6lXvaDsO7QH
D/6wHwPv7MetFYtwQiodiNLTe5kkHtQMB8U/hc1m895cmHK1acsaaDYvg2bHKmho5btf24meY/vQe+wV
@@ -383,7 +383,7 @@
imXm5oeYS8Mz0czM8UFGIno2ZKI9Zy5aUmKhSgjBLcpE9REUyMFy7OXzS0k6bMU5Ghx1dy47zuXWMF8f
jZppE2sGctPRuTKFiYNwNMb44FaUC65RdggzNP7ff22OIZZ6eh5xpqbaU/nRM95kC4v49vgo9K5JG3yF
rp4/Gc0JwSgNdUe+wLqKJE5Dyl+Nx3/9uJTDKWicEoKOhXF0HkSjMsoPb/D5fVa6uvGM5OknwdB42wlb
- 287TlJO3WnNvWOrozKXLVKL8htBnsdwoD2tLBq3bjMnJ+zu/fVisfwMVwMtUf+V6egAAAABJRU5ErkJg
+ 287TlJO3WnNvWOrozKXLVKL8htBnsdwoD2tLBq3bjMnJ+zu/fVisfwP1S8tTgtT67QAAAABJRU5ErkJg
gg==
</value>
</data>
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);
diff --git a/Aktywator/Properties/AssemblyInfo.cs b/Aktywator/Properties/AssemblyInfo.cs
index e31f26d..90362f9 100644
--- a/Aktywator/Properties/AssemblyInfo.cs
+++ b/Aktywator/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.1.3.0")]
-[assembly: AssemblyFileVersion("1.1.3.0")]
+[assembly: AssemblyVersion("1.1.4.1")]
+[assembly: AssemblyFileVersion("1.1.4.1")]
diff --git a/Aktywator/Resources/BuildDate.txt b/Aktywator/Resources/BuildDate.txt
index fb76437..c370c3b 100644
--- a/Aktywator/Resources/BuildDate.txt
+++ b/Aktywator/Resources/BuildDate.txt
@@ -1 +1 @@
-2018-02-04
+2018-04-15
diff --git a/Aktywator/Setting.cs b/Aktywator/Setting.cs
index 613065f..bde6fd1 100644
--- a/Aktywator/Setting.cs
+++ b/Aktywator/Setting.cs
@@ -170,5 +170,13 @@ namespace Aktywator
{
}
}
+
+ public static void saveSectionGroups(Sql sql, bool value)
+ {
+ StringBuilder sb = new StringBuilder("UPDATE Tables SET `Group` = ");
+ sb.Append(value ? "1" : "`Section`");
+ sb.Append(";");
+ sql.query(sb.ToString());
+ }
}
}