// Busca pelo codigo da marca public Marca BuscarMarca(int codMarca) { Marca marca = null; using (OracleCommand c = _conn.ObterConexao().CreateCommand()) { c.CommandType = System.Data.CommandType.Text; c.CommandText = "select CODMARCA, DESCMARCA FROM MARCA WHERE CODMARCA = :CODMARCA"; c.Parameters.Add("CODMARCA", OracleType.Number).Value = codMarca; using (OracleDataReader leitor = c.ExecuteReader()) { if (leitor.HasRows) { leitor.Read(); int bd_cod_marca = leitor.GetInt32(0); string bd_descricao = leitor.GetString(1); marca = new Marca(bd_cod_marca, bd_descricao); } else { return null; } } } return marca; }
public bool Excluir(Marca objeto) { using (OracleCommand c = _conn.ObterConexao().CreateCommand()) { c.CommandType = System.Data.CommandType.Text; c.CommandText = "delete from MARCA WHERE CODMARCA = :CODMARCA"; c.Parameters.Add("CODMODELO", OracleType.Int32).Value = objeto.CodMarca; c.ExecuteNonQuery(); return true; } return false; }