public bool ChangePlayerPocketmonStatus(int pocketmon_id, int status) { bool bSuccess = false; if (isPlayerLoaded()) { Pocketmon selectPocketmon = null; foreach (Pocketmon cur in itsPlayerPocketmonList) { if (cur.PocketmonId == pocketmon_id) { selectPocketmon = cur; break; } } if (selectPocketmon != null) { selectPocketmon.PocketmonStatus = status; SavePocketmonStatus(pocketmon_id, status); bSuccess = true; } } return(bSuccess); }
private bool LoadPlayerPocketmonList(String player_id) { String sql = "select * from pocketmon left join mon on pocketmon.mon_id = mon.mon_id where player_id=@player_id;"; bool bSucces = false; if (isPlayerLoaded()) { using (MySqlConnection conn = ConnectToDB()) { conn.Open(); using (MySqlCommand comm = new MySqlCommand(sql, conn)) { comm.Prepare(); comm.Parameters.AddWithValue("@player_id", player_id); using (MySqlDataReader reader = comm.ExecuteReader()) { itsPlayerPocketmonList.Clear(); while (reader.Read()) { Pocketmon pocketmon = new Pocketmon(); pocketmon.PocketmonId = (int)reader["pocketmon_id"]; pocketmon.MonId = (int)reader["mon_id"]; pocketmon.PocketmonStatus = (int)reader["pocketmon_status"]; pocketmon.Rank = (int)reader["rank"]; pocketmon.GainCoin = (int)reader["gain_coin"]; pocketmon.PlayerId = (String)reader["player_id"]; pocketmon.MonName = (String)reader["mon_name"]; pocketmon.MonExplanation = (String)reader["mon_explanation"]; pocketmon.GainCoinExplanation = (String)reader["gain_coin_explanation"]; pocketmon.btnSave.Click += onPocketmonSaveClick; pocketmon.btnLoad.Click += onPocketmonLoadClick; itsPlayerPocketmonList.Add(pocketmon); } bSucces = true; } } } } return(bSucces); }
private bool LoadPlayerPocketmonList(String player_id) { String sql = "select * from pocketmon left join mon on pocketmon.mon_id = mon.mon_id where player_id=@player_id;"; bool bSucces = false; if (isPlayerLoaded()) { using (MySqlConnection conn = ConnectToDB()) { conn.Open(); using (MySqlCommand comm = new MySqlCommand(sql, conn)) { comm.Prepare(); comm.Parameters.AddWithValue("@player_id", player_id); using (MySqlDataReader reader = comm.ExecuteReader()) { itsPlayerPocketmonList.Clear(); while (reader.Read()) { Pocketmon pocketmon = new Pocketmon(); pocketmon.PocketmonId = (int)reader["pocketmon_id"]; pocketmon.MonId = (int)reader["mon_id"]; pocketmon.PocketmonStatus = (int)reader["pocketmon_status"]; pocketmon.Rank = (int)reader["rank"]; pocketmon.GainCoin = (int)reader["gain_coin"]; pocketmon.PlayerId = (String)reader["player_id"]; pocketmon.MonName = (String)reader["mon_name"]; pocketmon.MonExplanation = (String)reader["mon_explanation"]; pocketmon.GainCoinExplanation = (String)reader["gain_coin_explanation"]; pocketmon.btnSave.Click += onPocketmonSaveClick; pocketmon.btnLoad.Click += onPocketmonLoadClick; itsPlayerPocketmonList.Add(pocketmon); } bSucces = true; } } } } return bSucces; }