diff options
Diffstat (limited to 'Aktywator/Bws.cs')
-rw-r--r-- | Aktywator/Bws.cs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Aktywator/Bws.cs b/Aktywator/Bws.cs index 8884868..8b92d7f 100644 --- a/Aktywator/Bws.cs +++ b/Aktywator/Bws.cs @@ -106,6 +106,8 @@ namespace Aktywator return false; if (!sql.checkTableExists("HandRecord")) return false; + if (!sql.checkTableExists("HandEvaluation")) + return false; return true; } @@ -173,6 +175,19 @@ 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" + + ");"); + } + catch (OleDbException) + { + } + 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," @@ -403,6 +418,7 @@ namespace Aktywator public void loadHandRecords(PBN pbn) { sql.query("DELETE FROM HandRecord"); + sql.query("DELETE FROM HandEvaluation"); for (int i = 0; i < pbn.handRecords.Length; i++) if (pbn.handRecords[i] != null) for (int section = 1; section <= highSection(); section++) @@ -429,6 +445,32 @@ namespace Aktywator str.Append(b.west[2]); str.Append("','"); str.Append(b.west[3]); str.Append("')"); sql.query(str.ToString()); + int[,] ddTable = pbn.ddTables[i].GetDDTable(); + if (ddTable != null) + { + StringBuilder ddStr = new StringBuilder(); + ddStr.Append("INSERT INTO HandEvaluation VALUES("); + ddStr.Append(section); ddStr.Append(","); + ddStr.Append(i); ddStr.Append(","); + for (int player = 0; player < 4; player++) + { + for (int denom = 0; denom < 5; denom++) + { + ddStr.Append(ddTable[player, denom]); + ddStr.Append(","); + } + } + for (int j = 0; j < 4; j++) + { + ddStr.Append(b.hpcs[j]); + if (j < 3) + { + ddStr.Append(","); + } + } + ddStr.Append(")"); + sql.query(ddStr.ToString()); + } } } } |