Kamis, 20 Juli 2017

Tugas Uas Algo




oke saya akan menampilkan hasil nya screenshots project saya yaitu membuat tiket konser 








private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
        {
            System.exit(0);
        }
    }                        

private void NewButtonActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        tiketkonser.Penjualankonser p = new tiketkonser.Penjualankonser();
        entityManager.persist(p);
        list.add(p);
        int row = list.size() - 1;
        masterTable.setRowSelectionInterval(row, row);
        masterTable.scrollRectToVisible(masterTable.getCellRect(row, 0, true));
    }                                         

private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
        try {
            entityManager.getTransaction().commit();
            entityManager.getTransaction().begin();
        } catch (RollbackException rex) {
            rex.printStackTrace();
            entityManager.getTransaction().begin();
            List<tiketkonser.Penjualankonser> merged = new ArrayList<tiketkonser.Penjualankonser>(list.size());
            for (tiketkonser.Penjualankonser p : list) {
                merged.add(entityManager.merge(p));
            }
            list.clear();
            list.addAll(merged);
        }
    }                                          

private void hitungButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            
        // TODO add your handling code here:
        float jumlahtiket=Float.parseFloat(jumlahtiketField.getText());
        float hargatiket=Float.parseFloat(hargatiketField.getText());
        float hargatotal=jumlahtiket*hargatiket;
        hargatotalField.setText(""+hargatotal);

    }                                           

private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {                                             
        // TODO add your handling code here:
        entityManager.getTransaction().rollback();
        entityManager.getTransaction().begin();
        java.util.Collection data = query.getResultList();
        for (Object entity : data) {
            entityManager.refresh(entity);
        }
        list.clear();
        list.addAll(data);
    }                                            

private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            
        // TODO add your handling code here:

        int[] selected = masterTable.getSelectedRows();
        List<tiketkonser.Penjualankonser> toRemove = new ArrayList<tiketkonser.Penjualankonser>(selected.length);
        for (int idx = 0; idx < selected.length; idx++) {
            tiketkonser.Penjualankonser t = list.get(masterTable.convertRowIndexToModel(selected[idx]));
            toRemove.add(t);
            entityManager.remove(t);
        }
        list.removeAll(toRemove);

    }                                           


Tidak ada komentar:

Posting Komentar