Exemple #1
0
 //Método que agrega un jugador a la base de datos
 public static void InsertPlayer(string player)
 {
     try
     {
         string query = $"INSERT INTO PLAYER(nickname) VALUES ('{player}')";
         ConnectionDB.ExecuteNonQuery(query);
     }
     catch (PlayerRegistrationException Ex)
     {
         MessageBox.Show("Ha ocurrido un error!");
     }
 }
Exemple #2
0
 //Método que añade los score a la base de datos
 public static void AddScore(int score, string nickname)
 {
     try
     {
         string query = $"INSERT INTO SCORE(score, nickname) VALUES ({score},'{nickname}');";
         ConnectionDB.ExecuteNonQuery(query);
     }
     catch (AddScoreException e)
     {
         MessageBox.Show("Ha ocurrido un error!");
     }
 }
        public static bool CreatePlayer(string nickname)
        {
            var dt = ConnectionDB.ExecuteQuery($"SELECT * FROM PLAYER WHERE nickname = '{nickname}'");

            if (dt.Rows.Count > 0)
            {
                return(true);
            }
            else
            {
                ConnectionDB.ExecuteNonQuery($"INSERT INTO PLAYER(nickname) VALUES ('{nickname}')");

                return(false);
            }
        }
 public static void NewScore(string idPlayer, int sc)
 {
     ConnectionDB.ExecuteNonQuery($"INSERT INTO  SCORE(IdPlayer, score) VALUES ({idPlayer},{sc})");
 }