diff options
author | emkael <emkael@tlen.pl> | 2017-07-30 14:24:30 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2017-07-30 14:27:05 +0200 |
commit | ea9027a8e624cc6d0ef193189bf1d7b1e0e13724 (patch) | |
tree | abbf44c935e1b7993ce7339e1c5fd984fdc80eb8 | |
parent | 808116c88329954ce07280fb6caf12d60c5b59df (diff) |
Adding names to BWS if no player numbers are provided in Bridgematesrrb-names
-rw-r--r-- | Aktywator/Bws.cs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/Aktywator/Bws.cs b/Aktywator/Bws.cs index 7f8a899..e1921a8 100644 --- a/Aktywator/Bws.cs +++ b/Aktywator/Bws.cs @@ -331,15 +331,24 @@ namespace Aktywator name = Common.bezOgonkow(name); if (name.Length > 18) name = name.Substring(0, 18); - string actual = sql.selectOne("SELECT Name FROM PlayerNumbers WHERE `Section`=" + section + " AND `Table`=" + table - + " AND `Direction`='" + direction + "'"); - if (actual != name) + try + { + string actual = sql.selectOne("SELECT Name FROM PlayerNumbers WHERE `Section`=" + section + " AND `Table`=" + table + + " AND `Direction`='" + direction + "'", true); + if (actual != name) + { + sql.query("UPDATE PlayerNumbers SET Name='" + name + "', Updated=TRUE WHERE `Section`=" + section + " AND `Table`=" + table + + " AND `Direction`='" + direction + "'"); + return 1; + } + else return 0; + } + catch (OleDbRowMissingException) { - sql.query("UPDATE PlayerNumbers SET Name='" + name + "', Updated=TRUE WHERE `Section`=" + section + " AND `Table`=" + table - + " AND `Direction`='" + direction + "'"); + sql.query("INSERT INTO PlayerNumbers(`Section`, `Table`, Direction, Name, Updated) VALUES(" + + section + ", " + table + ", '" + direction + "', '" + name + "', TRUE)"); return 1; } - else return 0; } private int getBWSNumber(OleDbDataReader reader, int index) |