From ea9027a8e624cc6d0ef193189bf1d7b1e0e13724 Mon Sep 17 00:00:00 2001 From: emkael Date: Sun, 30 Jul 2017 14:24:30 +0200 Subject: Adding names to BWS if no player numbers are provided in Bridgemates --- Aktywator/Bws.cs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'Aktywator/Bws.cs') 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) -- cgit v1.2.3