Package Boundary

Source Code of Boundary.generarReportes

package Boundary;

import Control.ReportesC;
import java.awt.Color;
import java.awt.Cursor;
import javax.swing.JOptionPane;

public class generarReportes extends javax.swing.JPanel {

    private ReportesC reporte = new ReportesC();

    public generarReportes() {
        initComponents();
        estacionL.setVisible(false);
        estacionesCB.setVisible(false);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jScrollPane1 = new javax.swing.JScrollPane();
        tablaT = new javax.swing.JTable();
        guardarB = new javax.swing.JButton();
        ActualizarB = new javax.swing.JButton();
        listareportesCB = new javax.swing.JComboBox();
        bogotaRB = new javax.swing.JRadioButton();
        caliRB = new javax.swing.JRadioButton();
        estacionL = new javax.swing.JLabel();
        estacionesCB = new javax.swing.JComboBox();
        operacionL = new javax.swing.JLabel();

        tablaT.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jScrollPane1.setViewportView(tablaT);

        guardarB.setText("Guardar");
        guardarB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                guardarBActionPerformed(evt);
            }
        });

        ActualizarB.setText("Actualizar");
        ActualizarB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ActualizarBActionPerformed(evt);
            }
        });

        listareportesCB.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Premios por estación", "Inventario de premios", "Puntos por estación", " " }));
        listareportesCB.setSelectedIndex(3);
        listareportesCB.setSelectedItem(null);
        listareportesCB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listareportesCBActionPerformed(evt);
            }
        });

        buttonGroup1.add(bogotaRB);
        bogotaRB.setText("Bogotá");
        bogotaRB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bogotaRBActionPerformed(evt);
            }
        });

        buttonGroup1.add(caliRB);
        caliRB.setText("Cali");
        caliRB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                caliRBActionPerformed(evt);
            }
        });

        estacionL.setText("Seleccione la estación");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 471, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(bogotaRB)
                        .addGap(31, 31, 31)
                        .addComponent(caliRB)
                        .addGap(58, 58, 58)
                        .addComponent(estacionL)
                        .addGap(18, 18, 18)
                        .addComponent(estacionesCB, 0, 158, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(operacionL, javax.swing.GroupLayout.DEFAULT_SIZE, 285, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(ActualizarB)
                        .addGap(18, 18, 18)
                        .addComponent(guardarB))
                    .addComponent(listareportesCB, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(listareportesCB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bogotaRB)
                    .addComponent(caliRB)
                    .addComponent(estacionesCB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(estacionL))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(guardarB)
                    .addComponent(ActualizarB)
                    .addComponent(operacionL, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void ActualizarBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ActualizarBActionPerformed
        if (listareportesCB.getSelectedIndex() == 0) {
            reporte = new ReportesC();
            if (bogotaRB.isSelected()) {
                tablaT.setModel(reporte.genRepEst("Bogota", estacionesCB.getSelectedItem().toString()));
            } else if (caliRB.isSelected()) {
                tablaT.setModel(reporte.genRepEst("Cali", estacionesCB.getSelectedItem().toString()));
            } else {
                JOptionPane.showMessageDialog(null, "Por favor seleccione una opción", "Error", JOptionPane.ERROR_MESSAGE);
            }
        } else if (listareportesCB.getSelectedIndex() == 1) {
            reporte = new ReportesC();
            if (bogotaRB.isSelected()) {
                tablaT.setModel(reporte.genRepInv("Bogota"));
            } else if (caliRB.isSelected()) {
                tablaT.setModel(reporte.genRepInv("Cali"));
            }
        } else if (listareportesCB.getSelectedIndex() == 2) {
            reporte = new ReportesC();
            if (bogotaRB.isSelected()) {
                tablaT.setModel(reporte.genRepPunEst("Bogota"));
            } else if (caliRB.isSelected()) {
                tablaT.setModel(reporte.genRepPunEst("Cali"));
            } else {
                JOptionPane.showMessageDialog(null, "No implementado todavia", "Proximamente..", JOptionPane.WARNING_MESSAGE);
            }
        }
    }//GEN-LAST:event_ActualizarBActionPerformed
    private void bogotaRBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bogotaRBActionPerformed
        estacionesCB.setModel(reporte.combodatos("Bogota"));
        operacionL.setForeground(Color.black);
        operacionL.setText("");
    }//GEN-LAST:event_bogotaRBActionPerformed

    private void caliRBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_caliRBActionPerformed
        estacionesCB.setModel(reporte.combodatos("Cali"));
        operacionL.setForeground(Color.black);
        operacionL.setText("");
    }//GEN-LAST:event_caliRBActionPerformed

    private void listareportesCBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listareportesCBActionPerformed
        if (listareportesCB.getSelectedIndex() == 0) {
            estacionL.setVisible(true);
            estacionesCB.setVisible(true);
        } else {
            estacionL.setVisible(false);
            estacionesCB.setVisible(false);
        }
        operacionL.setForeground(Color.black);
        operacionL.setText("");
    }//GEN-LAST:event_listareportesCBActionPerformed

    private void guardarBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_guardarBActionPerformed
        String ciudadsel = null;
        String estacion;
        if (listareportesCB.getSelectedIndex() == 0) {
            if (bogotaRB.isSelected()) {
                ciudadsel = "Bogota";
            } else if (caliRB.isSelected()) {
                ciudadsel = "Cali";
            }
            operacionL.setText("Lanzando el visor...");
            estacion = estacionesCB.getSelectedItem().toString();
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            reporte.impRepEst(estacion, operacionL);
            setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        } else if (listareportesCB.getSelectedIndex() == 1) {
            if (bogotaRB.isSelected()) {
                ciudadsel = "Bogota";

            } else if (caliRB.isSelected()) {
                ciudadsel = "Cali";
            }
            operacionL.setText("Lanzando el visor...");
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            reporte.impRepInv(ciudadsel, operacionL);
            setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        } else if (listareportesCB.getSelectedIndex() == 2) {
            if (bogotaRB.isSelected()) {
                ciudadsel = "Bogota";
            } else if (caliRB.isSelected()) {
                ciudadsel = "Cali";
            }
            operacionL.setText("Lanzando el visor...");
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            reporte.impRepPunEst(ciudadsel, operacionL);
            setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        } else {
            JOptionPane.showMessageDialog(null, "Por favor seleccione una opción válida", "Advertencia", JOptionPane.WARNING_MESSAGE);
        }


    }//GEN-LAST:event_guardarBActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton ActualizarB;
    private javax.swing.JRadioButton bogotaRB;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JRadioButton caliRB;
    private javax.swing.JLabel estacionL;
    private javax.swing.JComboBox estacionesCB;
    private javax.swing.JButton guardarB;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JComboBox listareportesCB;
    private javax.swing.JLabel operacionL;
    private javax.swing.JTable tablaT;
    // End of variables declaration//GEN-END:variables
}
TOP

Related Classes of Boundary.generarReportes

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.