public bool update(PlayerDTO player)
 {
     DBConnector dbCon = new DBConnector();
     if(dbCon.openConnection() == true){
         string query = "UPDATE `player` SET `name`='" + player.name + "',`status`='" + player.status + "' WHERE id='" + player.id + "'";
         MySqlCommand cmd = new MySqlCommand(query, dbCon.connection);
         cmd.ExecuteNonQuery();
         dbCon.closeConnection();
         return true;
     }
     return false;
 }
        public bool create(ScoreDTO score)
        {
            DBConnector dbCon = new DBConnector();

            if (dbCon.openConnection() == true)
            {
                string query = "INSERT INTO `score`(`id`, `player_id`,`score`,`difficulty`,`game_mode`) VALUES (null,'" + score.player_id + "','"+score.score+"','"+ (int)score.difficulty +"','"+(int)score.game_mode+"')";
                MySqlCommand cmd = new MySqlCommand(query, dbCon.connection);
                cmd.ExecuteNonQuery();
                dbCon.closeConnection();
                return true;
            }
            return false;
        }
        public bool create(Player player)
        {
            DBConnector dbCon = new DBConnector();

            if (dbCon.openConnection() == true)
            {
                string query = "INSERT INTO `player`(`id`, `name`,`status`) VALUES (null,'" + player.name + "','1')";
                MySqlCommand cmd = new MySqlCommand(query, dbCon.connection);
                cmd.ExecuteNonQuery();
                dbCon.closeConnection();
                return true;
            }
            return false;
        }
 public ScoreDTO getHighScore(PlayerDTO player)
 {
     string query = "SELECT max(score) FROM score WHERE player_id='" + player.id + "'";
     ScoreDTO score = null;
     DBConnector dbCon = new DBConnector();
     if (dbCon.openConnection() == true)
     {
         MySqlCommand cmd = new MySqlCommand(query, dbCon.connection);
         MySqlDataReader dataReader = cmd.ExecuteReader();
         score.score = Int32.Parse(cmd.ExecuteScalar().ToString());
         dataReader.Close();
         dbCon.closeConnection();
     }
     return score;
 }
        public int count()
        {
            DBConnector dbCon = new DBConnector();

            if (dbCon.openConnection() == true)
            {
                string query = "SELECT * FROM `player`";
                int count = 0;
                MySqlCommand cmd = new MySqlCommand(query, dbCon.connection);
                MySqlDataReader dataReader = cmd.ExecuteReader();
                while (dataReader.Read())
                {
                    count++;
                }
                dbCon.closeConnection();
                return count;
            }
            return -1;
        }
 public List<PlayerDTO> selectAll()
 {
     string query = "SELECT * FROM player WHERE status='1'";
     List<PlayerDTO> list = new List<PlayerDTO>();
     DBConnector dbCon = new DBConnector();
     if (dbCon.openConnection() == true)
     {
         MySqlCommand cmd = new MySqlCommand(query, dbCon.connection);
         MySqlDataReader dataReader = cmd.ExecuteReader();
         while (dataReader.Read())
         {
             PlayerDTO tmp = new PlayerDTO();
             tmp.id = Int32.Parse(dataReader["id"].ToString());
             tmp.name = dataReader["name"].ToString();
             list.Add(tmp);
         }
         dataReader.Close();
         dbCon.closeConnection();
     }
     return list;
 }
 public List<ScoreDTO> getScore(PlayerDTO player)
 {
     string query = "SELECT * FROM score WHERE player_id='"+ player.id +"'";
     List<ScoreDTO> list = new List<ScoreDTO>();
     DBConnector dbCon = new DBConnector();
     if (dbCon.openConnection() == true)
     {
         MySqlCommand cmd = new MySqlCommand(query, dbCon.connection);
         MySqlDataReader dataReader = cmd.ExecuteReader();
         while (dataReader.Read())
         {
             ScoreDTO tmp = new ScoreDTO();
             tmp.id = Int32.Parse(dataReader["id"].ToString());
             tmp.player_id = player.id;
             tmp.score = Int32.Parse(dataReader["score"].ToString());
             tmp.difficulty = (Difficulty)Int32.Parse(dataReader["difficulty"].ToString());
             tmp.game_mode = (GameMode)Int32.Parse(dataReader["game_mode"].ToString());
             list.Add(tmp);
         }
         dataReader.Close();
         dbCon.closeConnection();
     }
     return list;
 }