Package visao

Source Code of visao.JanelaDeletarCartao

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package visao;

import java.util.logging.Level;
import java.util.logging.Logger;
import negocio.GerenciarDB;

/**
*
* @author Rafaella
*/
public class JanelaDeletarCartao extends javax.swing.JFrame {

    /**
     * Creates new form DeletarCartao
     */
    public JanelaDeletarCartao() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        DelIDCartao = new javax.swing.JFormattedTextField();
        ConfirmarDelCartao = new javax.swing.JButton();
        CancelarDelCartao = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        IDCartao = new javax.swing.JLabel();
        todosCampos = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Deletar Cartão");
        setMinimumSize(new java.awt.Dimension(720, 460));
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        try
            javax.swing.text.MaskFormatter data= new javax.swing.text.MaskFormatter("####-####")
            DelIDCartao = new javax.swing.JFormattedTextField(data)
       
        catch (Exception e){ 
        }
        getContentPane().add(DelIDCartao, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 150, 117, 30));

        ConfirmarDelCartao.setText("Confirmar");
        ConfirmarDelCartao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ConfirmarDelCartaoActionPerformed(evt);
            }
        });
        getContentPane().add(ConfirmarDelCartao, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 260, 100, 30));

        CancelarDelCartao.setText("Cancelar");
        CancelarDelCartao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CancelarDelCartaoActionPerformed(evt);
            }
        });
        getContentPane().add(CancelarDelCartao, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 260, 100, 30));

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
        jLabel1.setText("Deletar Cartão");
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(235, 23, -1, -1));

        IDCartao.setText("Digite o ID do Cartão:");
        getContentPane().add(IDCartao, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 150, 120, 30));

        todosCampos.setForeground(new java.awt.Color(255, 0, 0));
        getContentPane().add(todosCampos, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 150, 360, 30));

        setSize(new java.awt.Dimension(736, 518));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void ConfirmarDelCartaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConfirmarDelCartaoActionPerformed
        // TODO add your handling code here:
        String IDcartao = DelIDCartao.getText().replaceAll("[-]","");
        if ((IDcartao.isEmpty()) || ("        ".equals(IDcartao)) ) {
            todosCampos.setText("O campo deve ser preenchido");
        } else {
            try {
                 GerenciarDB banco = new GerenciarDB();
                
                 if (banco.checkCartaoDB(IDcartao)) {
                    banco.delCartao(IDcartao);
                    JanelaInicioAdmin frame = new JanelaInicioAdmin();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
                    this.dispose();
                 } else {
                     todosCampos.setText("Cartão incorreto ou inexistente.");
                 }
            } catch (Exception ex) {
                Logger.getLogger(JanelaDeletarCartao.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_ConfirmarDelCartaoActionPerformed

    private void CancelarDelCartaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelarDelCartaoActionPerformed
        //TODO add your handling code here:
        JanelaInicioAdmin frame = new JanelaInicioAdmin();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_CancelarDelCartaoActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(JanelaDeletarCartao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(JanelaDeletarCartao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(JanelaDeletarCartao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(JanelaDeletarCartao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new JanelaDeletarCartao().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton CancelarDelCartao;
    private javax.swing.JButton ConfirmarDelCartao;
    private javax.swing.JFormattedTextField DelIDCartao;
    private javax.swing.JLabel IDCartao;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel todosCampos;
    // End of variables declaration//GEN-END:variables
}
TOP

Related Classes of visao.JanelaDeletarCartao

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.