Пример #1
0
        public static bool Alterar(Ingredientes ingrediente)
        {
            try
            {
                using (OracleCommand c = ConexaoOracle.ObterConexao().CreateCommand())
                {
                    c.CommandType = System.Data.CommandType.Text;
                    c.CommandText = "UPDATE ingredientes SET nome=:nome, preco=:preco, estoque=:estoque, descricao=:descricao WHERE ingredienteid = :codigo";
                    c.Parameters.Add("nome", OracleType.VarChar).Value = ingrediente.getNome();
                    c.Parameters.Add("preco", OracleType.Float).Value = ingrediente.getPreco();
                    c.Parameters.Add("estoque", OracleType.Int32).Value = ingrediente.getEstoque();
                    c.Parameters.Add("descricao", OracleType.VarChar).Value = ingrediente.getDescricao();
                    c.Parameters.Add("codigo", OracleType.Int32).Value = ingrediente.getIngredienteId();

                    c.ExecuteNonQuery();
                    return true;
                }
            }
            catch (OracleException e)
            {
                throw e;
            }
        }
Пример #2
0
 public static bool Inserir(Ingredientes ingrediente)
 {
     try
     {
         using (OracleCommand c = ConexaoOracle.ObterConexao().CreateCommand())
         {
             c.CommandType = System.Data.CommandType.Text;
             c.CommandText = "INSERT into ingredientes values(INGREDIENTES_SEQ.NEXTVAL, :nome, :preco, :estoque, :descricao)";
             c.Parameters.Add("nome", OracleType.VarChar).Value = ingrediente.getNome();
             c.Parameters.Add("preco", OracleType.Float).Value = ingrediente.getPreco();
             c.Parameters.Add("estoque", OracleType.Int32).Value = ingrediente.getEstoque();
             c.Parameters.Add("descricao", OracleType.VarChar).Value = ingrediente.getDescricao();
             c.ExecuteNonQuery();
             return true;
         }
     }
     catch (OracleException e)
     {
         throw e;
     }
 }