public void delete(Marca marca) { FbConnection conn = ConnectionFactory.getConnection(); FbCommand query = new FbCommand(DELETE, conn); try { query.Parameters.AddWithValue("@codMarca", marca.getCodMarca()); conn.Open(); query.ExecuteNonQuery(); } catch (FbException ex) { ex.Message.ToString(); } finally { ConnectionFactory.closeAll(conn, query); } }
public Marca selectById(Marca marca) { FbConnection conn = ConnectionFactory.getConnection(); FbCommand query = new FbCommand(SELECTBYID, conn); FbDataReader reader = null; try { query.Parameters.AddWithValue("@codMarca", marca.getCodMarca()); conn.Open(); reader = query.ExecuteReader(); if (reader.Read()) { marca.setCodMarca(int.Parse(reader["codMarca"].ToString())); marca.setDescricao(reader["descricao"].ToString()); } } catch (FbException ex) { ex.Message.ToString(); } finally { ConnectionFactory.closeAll(conn, query, reader); } return marca; }