public void Excluir(int id) { DbConnection conexao = DAOUtils.GetConexao(); DbCommand comando = DAOUtils.GetComando(conexao); comando.CommandType = CommandType.Text; comando.CommandText = "DELETE FROM CONTATOS WHERE ID = @id"; comando.Parameters.Add(DAOUtils.GetParametro("@id", id)); comando.ExecuteNonQuery(); }
public void Inserir(Contato contato) { DbConnection conexao = DAOUtils.GetConexao(); DbCommand comando = DAOUtils.GetComando(conexao); comando.CommandType = CommandType.Text; comando.CommandText = "INSERT INTO CONTATOS (NOME, EMAIL, TELEFONE) VALUES (@nome, @email, @telefone)"; comando.Parameters.Add(DAOUtils.GetParametro("@nome", contato.Nome)); comando.Parameters.Add(DAOUtils.GetParametro("@email", contato.Email)); comando.Parameters.Add(DAOUtils.GetParametro("@telefone", contato.Telefone)); comando.ExecuteNonQuery(); }
public void Atualizar(Contato contato) { DbConnection conexao = DAOUtils.GetConexao(); DbCommand comando = DAOUtils.GetComando(conexao); comando.CommandType = CommandType.Text; comando.CommandText = "UPDATE CONTATOS SET NOME = @nome, EMAIL = @email, TELEFONE = @telefone WHERE ID = @id"; comando.Parameters.Add(DAOUtils.GetParametro("@nome", contato.Nome)); comando.Parameters.Add(DAOUtils.GetParametro("@email", contato.Email)); comando.Parameters.Add(DAOUtils.GetParametro("@telefone", contato.Telefone)); comando.Parameters.Add(DAOUtils.GetParametro("@id", contato.Id)); comando.ExecuteNonQuery(); }
public void Excluir(int id) { DbConnection conexao = DAOUtils.GetConexao(); DbCommand comando = DAOUtils.GetComando(conexao); comando.CommandType = CommandType.Text; comando.CommandText = "DELETE FROM CONTATOS WHERE ID = @id"; //Passa parametro para SQL Server e MySQl via metodo comando.Parameters.Add(DAOUtils.GetParametro("@id", id)); //Executa comando SQL comando.ExecuteNonQuery(); }