public static players_handler Read(int id) { string sql = $"select * from players where id = {id}"; var result = db_handler.instance.query(sql); var player = new players_handler(); if (result.Rows.Count > 0) { player.name = result.Rows[0].Field <string>(0); player.player_dt = result; } return(player); }
public static List <players_handler> ReadAllList() { string sql = "select * from players"; var list = new List <players_handler>(); var item = new players_handler(); var result = db_handler.instance.query(sql); foreach (DataRow obj in result.Rows) { item = new players_handler(); item.id = obj.Field <int>(0); item.name = obj.Field <string>(1); list.Add(item); } return(list); }
private void btn_give_Click(object sender, EventArgs e) { int item_count; try { item_count = int.Parse(txt_count.Text); } catch { MessageBox.Show("Please enter a valid amount..."); return; } players_handler p_handler = (players_handler)cb_players.Items[cb_players.SelectedIndex]; items_handler i_handler = (items_handler)cb_item.Items[cb_item.SelectedIndex]; inventories_handler.Give(p_handler.id, i_handler.id, item_count); clear_frm(); }