public int InserirPlayerVip(PlayersVip playersVip) { try { using (var con = new SQLiteConnection(_conStringDB)) { using (var cmd = new SQLiteCommand(con)) { cmd.CommandText = "INSERT INTO TB_COESERVER_PLAYERS_VIP(PLAYER_NOME, PLAYER_NICK, PLAYER_DT_INCLUSAO_SLOT_VIP, PLAYER_ATIVO, PLAYER_EH_ADMIN, PLAYER_DIAS_VIP) " + "VALUES(@PLAYER_NOME, @PLAYER_NICK, " + "@PLAYER_DT_INCLUSAO_SLOT_VIP, @PLAYER_ATIVO, @PLAYER_EH_ADMIN, @PLAYER_DIAS_VIP);"; cmd.Parameters.AddWithValue("PLAYER_NOME", playersVip.PlayerNome); cmd.Parameters.AddWithValue("PLAYER_NICK", playersVip.PlayerNick); cmd.Parameters.AddWithValue("PLAYER_DT_INCLUSAO_SLOT_VIP", playersVip.PlayerDataInclusaoSLOTVip); cmd.Parameters.AddWithValue("PLAYER_ATIVO", playersVip.PlayerAtivo); cmd.Parameters.AddWithValue("PLAYER_EH_ADMIN", playersVip.PlayerEhAdmin); cmd.Parameters.AddWithValue("PLAYER_DIAS_VIP", playersVip.PlayerDiasVIP); cmd.CommandType = System.Data.CommandType.Text; if (con.State == System.Data.ConnectionState.Closed) { con.Open(); } return(cmd.ExecuteNonQuery()); } } } catch (Exception ex) { throw new Exception("Erro ao inserir o Player VIP na base de dados: " + ex.Message); } }
private void btnSalvarNovoPlayerVip_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtNickPlayerVip.Text)) { MessageBox.Show("O Nick do Player está vazio e ele é requirido. Favor informar um Nick válido", "Entrada inválida", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (!string.IsNullOrEmpty(txtQtdDiasPlayerVip.Text)) { if (Convert.ToInt32(txtQtdDiasPlayerVip.Text) > 32000) { MessageBox.Show("A quantidade de dias de Vip é superior ao limite de 32.000. Favor informar uma quantidade inferior", "Entrada inválida", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } _businessOperations = new BusinessOperations(); // gera uma entidade com os dados do formulário PlayersVip playersVip = new PlayersVip { PlayerNome = txtNomePlayerVip.Text.Trim(), PlayerNick = txtNickPlayerVip.Text.Trim(), PlayerDiasVIP = string.IsNullOrEmpty(txtQtdDiasPlayerVip.Text.Trim()) == true ? (short)0 : Convert.ToInt16(txtQtdDiasPlayerVip.Text.Trim()), PlayerAtivo = rdbPlayerVipAtivoSim.Checked, PlayerEhAdmin = rdbPlayerVipEhAdminSim.Checked, PlayerDataInclusaoSLOTVip = dtpDataCadastroPlayerVip.Value }; if (_businessOperations.BusinessInserirPlayerVip(playersVip)) { MessageBox.Show(string.Format("Sucesso ao cadastrar o novo Player Vip \"{0}\"", txtNickPlayerVip.Text), "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Information); btnCancelarGravarNovoPlayerVip.Visible = false; btnSalvarNovoPlayerVip.Visible = false; btnNovoPlayerVip.Visible = true; CarregarTodosPlayersVip(); } else { MessageBox.Show(string.Format("Não foi possível cadastrar o novo Player Vip \"{0}\". Favor verificar a entrada dos dados.", txtNickPlayerVip.Text), "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public static PlayersVip MapFromReader(IDataReader reader) { PlayersVip playersVip = new PlayersVip(); while (reader.Read()) { playersVip = new PlayersVip { PlayerID = reader.GetInt32(0), PlayerNome = reader.GetString(1) ?? "N/D", PlayerNick = reader.GetString(2), PlayerDataInclusaoSLOTVip = reader.GetDateTime(3), PlayerAtivo = reader.GetBoolean(4), PlayerEhAdmin = reader.GetBoolean(5), PlayerDiasVIP = reader.GetInt16(6) }; } return(playersVip); }
public int EditarPlayerVip(PlayersVip playersVip) { try { using (var con = new SQLiteConnection(_conStringDB)) { using (var cmd = new SQLiteCommand(con)) { cmd.CommandText = "UPDATE TB_COESERVER_PLAYERS_VIP SET " + "PLAYER_NOME = @PLAYER_NOME, " + "PLAYER_NICK = @PLAYER_NICK, " + "PLAYER_DT_INCLUSAO_SLOT_VIP = @PLAYER_DT_INCLUSAO_SLOT_VIP, " + "PLAYER_ATIVO = @PLAYER_ATIVO, " + "PLAYER_EH_ADMIN = @PLAYER_EH_ADMIN, " + "PLAYER_DIAS_VIP = @PLAYER_DIAS_VIP " + "WHERE PLAYER_ID = @PLAYER_ID;"; cmd.Parameters.AddWithValue("PLAYER_NOME", playersVip.PlayerNome); cmd.Parameters.AddWithValue("PLAYER_NICK", playersVip.PlayerNick); cmd.Parameters.AddWithValue("PLAYER_DT_INCLUSAO_SLOT_VIP", playersVip.PlayerDataInclusaoSLOTVip); cmd.Parameters.AddWithValue("PLAYER_ATIVO", playersVip.PlayerAtivo); cmd.Parameters.AddWithValue("PLAYER_EH_ADMIN", playersVip.PlayerEhAdmin); cmd.Parameters.AddWithValue("PLAYER_DIAS_VIP", playersVip.PlayerDiasVIP); cmd.Parameters.AddWithValue("PLAYER_ID", playersVip.PlayerID); cmd.CommandType = System.Data.CommandType.Text; if (con.State == System.Data.ConnectionState.Closed) { con.Open(); } return(cmd.ExecuteNonQuery()); } } } catch (Exception ex) { throw new Exception("Erro ao editar o Players VIP na base de dados: " + ex.Message); } }
public bool BusinessEditarPlayerVip(PlayersVip playersVip) { _operationsDataBase = new OperationsDataBase(); return(_operationsDataBase.EditarPlayerVip(playersVip) > 0 ? true : false); }