public static bool Alterar(Comida_Ingrediente comida) { try { using (OracleCommand c = ConexaoOracle.ObterConexao().CreateCommand()) { c.CommandType = System.Data.CommandType.Text; c.CommandText = "UPDATE Comida_Ingrediente SET quantidade = :quantidade WHERE ingredienteid = :ingrediente and produtoid = :produto"; c.Parameters.Add("quantidade", OracleType.Int32).Value = comida.getQuantidade(); c.Parameters.Add("ingrediente", OracleType.Int32).Value = comida.getIngredienteId(); c.Parameters.Add("produto", OracleType.Int32).Value = comida.getProdutoId(); c.ExecuteNonQuery(); return true; } } catch (OracleException e) { throw e; } }
public static bool Inserir(Comida_Ingrediente comida) { using (OracleCommand c = ConexaoOracle.ObterConexao().CreateCommand()) { c.CommandType = System.Data.CommandType.Text; c.CommandText = "INSERT INTO Comida_Ingrediente values(comida_ingrediente_seq.nextval, :ingredienteid, :produtoid, :quantidade)"; c.Parameters.Add("ingredienteid", OracleType.Int32).Value = comida.getIngredienteId(); c.Parameters.Add("produtoid", OracleType.Int32).Value = comida.getProdutoId(); c.Parameters.Add("quantidade", OracleType.Int32).Value = comida.getQuantidade(); c.ExecuteScalar(); return true; } }
public static bool ValidaCaracter(Comida_Ingrediente comida) { if (comida.getQuantidade() < 1) throw new CaracterInvalidoException("A quantidade de ingrediente deve ser maior que zero!"); return true; }