public static int InsertResultItem(Simulation.GameRecord record, SQLiteCommand command)
        {
            string tableStr = $"Tbl{record.holeUniquePrime}";

            command.CommandText = $"SELECT * FROM {tableStr} where Flop = {record.flopUniquePrime}";
            SQLiteDataReader dr = command.ExecuteReader();

            if (record.winFlag == 1)
            {
                // read integer in Wins column
                dr.Read();
                long updatedWinCount = dr.GetInt64(1) + 1;

                // update integer in Wins column
                dr.Close();
                command.CommandText = $"UPDATE {tableStr} SET W = {updatedWinCount} WHERE Flop = {record.flopUniquePrime};";
            }
            else if (record.winFlag == 0)
            {
                // read integer in Losses column
                dr.Read();
                long updatedLossCount = dr.GetInt64(2) + 1;

                // update integer in Losses column
                dr.Close();
                command.CommandText = $"UPDATE {tableStr} SET L = {updatedLossCount} WHERE Flop = {record.flopUniquePrime};";
            }

            return(command.ExecuteNonQuery());
        }
Beispiel #2
0
 public static int InsertResultItem(Simulation.GameRecord record, SQLiteCommand command)
 {
     command.Parameters.AddWithValue("@hole1", "");
     command.Parameters.AddWithValue("@hole2", "");
     command.Parameters.AddWithValue("@flop1", "");
     command.Parameters.AddWithValue("@flop2", "");
     command.Parameters.AddWithValue("@flop3", "");
     command.Parameters.AddWithValue("@win_flag", "");
     command.CommandText = "INSERT INTO PlayerHandsTable "
                           + "(Hole1, Hole2, Flop1, Flop2, Flop3, Winflag) "
                           + "VALUES (@hole1, @hole2, @flop1,@flop2, @flop3, @win_flag)";
     command.Parameters["@hole1"].Value    = Program.card_to_int_dict[record.hole1.ToString()];
     command.Parameters["@hole2"].Value    = Program.card_to_int_dict[record.hole2.ToString()];
     command.Parameters["@flop1"].Value    = Program.card_to_int_dict[record.flop1.ToString()];
     command.Parameters["@flop2"].Value    = Program.card_to_int_dict[record.flop2.ToString()];
     command.Parameters["@flop3"].Value    = Program.card_to_int_dict[record.flop3.ToString()];
     command.Parameters["@win_flag"].Value = record.winFlag;
     return(command.ExecuteNonQuery());
 }