public void destroy(Integer id) throws NonexistentEntityException { EntityManager em = null; try { em = getEntityManager(); em.getTransaction().begin(); OrdenCompra ordenCompra; try { ordenCompra = em.getReference(OrdenCompra.class, id); ordenCompra.getCodOrden(); } catch (EntityNotFoundException enfe) { throw new NonexistentEntityException( "The ordenCompra with id " + id + " no longer exists.", enfe); } em.remove(ordenCompra); em.getTransaction().commit(); } finally { if (em != null) { em.close(); } } }
public void edit(OrdenCompra ordenCompra) throws NonexistentEntityException, Exception { EntityManager em = null; try { em = getEntityManager(); em.getTransaction().begin(); ordenCompra = em.merge(ordenCompra); em.getTransaction().commit(); } catch (Exception ex) { String msg = ex.getLocalizedMessage(); if (msg == null || msg.length() == 0) { Integer id = ordenCompra.getCodOrden(); if (findOrdenCompra(id) == null) { throw new NonexistentEntityException( "The ordenCompra with id " + id + " no longer exists."); } } throw ex; } finally { if (em != null) { em.close(); } } }
private void btn_imprimirActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btn_imprimirActionPerformed // TODO add your handling code here: OrdenCompra o = obtenerOrden(codigo); imprimir(o.getCodOrden()); } // GEN-LAST:event_btn_imprimirActionPerformed