Exemple #1
0
 public static void saveSectionGroups(Sql sql, bool value, int teamTableOffset = 0)
 {
     if (teamTableOffset == 0)
     {
         StringBuilder sb = new StringBuilder("UPDATE Tables SET `Group` = ");
         sb.Append(value ? "1" : "`Section`");
         sb.Append(";");
         sql.query(sb.ToString());
     }
     else
     {
         int           group       = 1;
         StringBuilder tablesQuery = new StringBuilder("SELECT `Section`, (`Table` MOD ");
         tablesQuery.Append(teamTableOffset);
         tablesQuery.Append(") FROM `Tables` GROUP BY `Section`, (`Table` MOD ");
         tablesQuery.Append(teamTableOffset);
         tablesQuery.Append(");");
         OleDbDataReader tables  = sql.select(tablesQuery.ToString());
         List <string>   queries = new List <string>();
         while (tables.Read())
         {
             StringBuilder sb = new StringBuilder("UPDATE `Tables` SET `Group` = ");
             sb.Append(group++);
             sb.Append(" WHERE `Section` = ");
             sb.Append(Bws.bwsNumber(tables, 0));
             sb.Append(" AND (`Table` MOD ");
             sb.Append(teamTableOffset);
             sb.Append(") = ");
             sb.Append(Bws.bwsNumber(tables, 1));
             sb.Append(";");
             queries.Add(sb.ToString());
         }
         foreach (string query in queries)
         {
             sql.query(query);
         }
     }
 }