Package org.salamanca.ui

Source Code of org.salamanca.ui.HistorialPagosFrame

package org.salamanca.ui;

import java.awt.BorderLayout;

import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.BorderFactory;
import com.toedter.calendar.JCalendar;
import javax.swing.JLabel;
import java.awt.Font;
import componenteTabla.compomenteABMCList;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.WindowConstants;
import org.salamanca.domain.Curso;
import org.salamanca.domain.CuotaBasica;
import org.salamanca.broker.BrokerServer;
import java.util.Vector;
import org.salamanca.domain.Alumno;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.salamanca.domain.Pago;
import java.util.GregorianCalendar;
import java.awt.Dimension;
import java.util.*;
import java.awt.Rectangle;
import org.salamanca.domain.Vale;

/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class HistorialPagosFrame extends JInternalFrame {
    compomenteABMCList compomenteABMCListPagosRegistrados = new
            compomenteABMCList();
    compomenteABMCList compomenteABMCListPagosAnulados = new
            compomenteABMCList();


    BorderLayout borderLayout1 = new BorderLayout();
    JPanel jPanel1 = new JPanel();
    JPanel jPanel2 = new JPanel();
    JPanel jPanel3 = new JPanel();
    JPanel jPanel4 = new JPanel();
    BorderLayout borderLayout2 = new BorderLayout();
    JPanel jPanel5 = new JPanel();
    JCalendar jCalendar1 = new JCalendar();
    JLabel jLabel1 = new JLabel();
    JPanel jPanel6 = new JPanel();
    JPanel jPanel7 = new JPanel();
    BorderLayout borderLayout3 = new BorderLayout();
    JLabel jLabel2 = new JLabel();
    JPanel jPanel8 = new JPanel();
    JPanel jPanel9 = new JPanel();
    BorderLayout borderLayout4 = new BorderLayout();
    JLabel jLabel3 = new JLabel();
    BorderLayout borderLayout5 = new BorderLayout();
    BorderLayout borderLayout6 = new BorderLayout();
    JLabel jLabel4 = new JLabel();
    JLabel jLabel5 = new JLabel();
    JLabel jLabelTotalFacturado = new JLabel();
    JLabel jLabelValesRecibidos = new JLabel();
    JLabel jLabel6 = new JLabel();
    JLabel jLabelValesEmitidos = new JLabel();


    public HistorialPagosFrame() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        getContentPane().setLayout(borderLayout1);
        jPanel1.setBorder(BorderFactory.createEtchedBorder());
        jPanel1.setLayout(borderLayout2);
        jPanel4.setBorder(BorderFactory.createEtchedBorder());
        jPanel5.setBorder(BorderFactory.createEtchedBorder());
        jPanel5.setMinimumSize(new Dimension(198, 170));
        jPanel5.setPreferredSize(new Dimension(198, 170));
        jPanel5.setLayout(null);
        jLabel1.setFont(new java.awt.Font("Arial", Font.BOLD, 14));
        jLabel1.setText("Listado de Pagos y Anulaciones");
        jPanel2.setLayout(borderLayout3);
        jPanel2.setBorder(BorderFactory.createEtchedBorder());
        jPanel3.setBorder(BorderFactory.createEtchedBorder());
        jPanel3.setLayout(borderLayout4);
        jPanel7.setBorder(BorderFactory.createEtchedBorder());
        jPanel7.setMinimumSize(new Dimension(27, 120));
        jPanel7.setPreferredSize(new Dimension(456, 120));
        jPanel7.setLayout(borderLayout5);
        jLabel2.setFont(new java.awt.Font("Arial", Font.BOLD, 11));
        jLabel2.setText("Pagos registrados");
        jPanel9.setBorder(BorderFactory.createEtchedBorder());
        jPanel9.setMinimumSize(new Dimension(27, 120));
        jPanel9.setPreferredSize(new Dimension(456, 120));
        jPanel9.setLayout(borderLayout6);
        jLabel3.setFont(new java.awt.Font("Arial", Font.BOLD, 11));
        jLabel3.setText("Pagos anulados");
        jCalendar1.addPropertyChangeListener(new
                                             HistorialPagosFrame_jCalendar1_propertyChangeAdapter(this));
        this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
        this.setMaximizable(true);
        this.setResizable(true);
        jCalendar1.setBounds(new Rectangle(15, 7, 184, 153));
        jLabel4.setFont(new java.awt.Font("Arial", Font.BOLD, 11));
        jLabel4.setText("Total facturado: ");
        jLabel4.setBounds(new Rectangle(246, 51, 91, 15));
        jLabel5.setFont(new java.awt.Font("Arial", Font.BOLD, 11));
        jLabel5.setText("Monto total vales recibidos: ");
        jLabel5.setBounds(new Rectangle(246, 112, 156, 15));
        jLabelTotalFacturado.setFont(new java.awt.Font("Arial", Font.BOLD, 11));
        jLabelTotalFacturado.setText("...");
        jLabelTotalFacturado.setBounds(new Rectangle(340, 51, 49, 15));
        jLabelValesRecibidos.setFont(new java.awt.Font("Arial", Font.BOLD, 11));
        jLabelValesRecibidos.setText("...");
        jLabelValesRecibidos.setBounds(new Rectangle(402, 112, 46, 15));
        jLabel6.setFont(new java.awt.Font("Arial", Font.BOLD, 11));
        jLabel6.setText("Monto total vales emitidos:");
        jLabel6.setBounds(new Rectangle(246, 92, 150, 15));
        jLabelValesEmitidos.setFont(new java.awt.Font("Arial", Font.BOLD, 11));
        jLabelValesEmitidos.setText("...");
        jLabelValesEmitidos.setBounds(new Rectangle(402, 92, 46, 14));
        this.getContentPane().add(jPanel3, java.awt.BorderLayout.SOUTH);
        jPanel1.add(jPanel5, java.awt.BorderLayout.CENTER);
        jPanel5.add(jCalendar1);
        jPanel5.add(jLabel5);
        jPanel5.add(jLabelValesRecibidos);
        jPanel5.add(jLabel4);
        jPanel5.add(jLabelTotalFacturado);
        jPanel5.add(jLabel6);
        jPanel5.add(jLabelValesEmitidos);
        jPanel1.add(jPanel4, java.awt.BorderLayout.NORTH);
        jPanel4.add(jLabel1);
        jPanel2.add(jPanel7, java.awt.BorderLayout.CENTER);
        jPanel2.add(jPanel6, java.awt.BorderLayout.NORTH);
        jPanel6.add(jLabel2);
        jPanel3.add(jPanel8, java.awt.BorderLayout.NORTH);
        jPanel8.add(jLabel3);
        jPanel3.add(jPanel9, java.awt.BorderLayout.CENTER);
        this.getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);

        this.getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);

        //PAGOS REGISTRADOS
        jPanel7.add(compomenteABMCListPagosRegistrados,
                    java.awt.BorderLayout.CENTER);
        compomenteABMCListPagosRegistrados.setVisibleCantidadRegistros(true);
        compomenteABMCListPagosRegistrados.setVisibleBuscar(true);
        compomenteABMCListPagosRegistrados.setInfoColumna(new String[][] { {
                "nombre",
                "tipo", "editable", "editor",
                "val.Combo", "Ancho Columna"}

                , {"Nombre", "String", "true",
                "comun", "", "90"}

                , {"Apellido", "String",
                "true", "comun", "", "90"}

                , {"DNI", "Long", "true",
                "comun", "", "50"}

                , {"Curso", "String",
                "true", "comun", "", "50"}

                , {"Concepto", "String",
                "true", "comun", "", "55"}

                , {"Concepto descuento", "String",
                "true", "comun", "", "110"}

                , {"Importe", "Double",
                "true", "comun", "", "80"}

        });

        compomenteABMCListPagosRegistrados.setVisibleAgregar(false);
        compomenteABMCListPagosRegistrados.setVisibleOrdenar(false);
        compomenteABMCListPagosRegistrados.setVisibleModificar(false);
        compomenteABMCListPagosRegistrados.setVisibleImprimir(true);
        compomenteABMCListPagosRegistrados.setVisibleGuardarComo(true);
        compomenteABMCListPagosRegistrados.setVisibleHeaderTabla(true);
        compomenteABMCListPagosRegistrados.setVisibleFiltrar(false);
        compomenteABMCListPagosRegistrados.setVisibleEliminar(false);
        compomenteABMCListPagosRegistrados.setVisibleCopyclipboard(true);
        compomenteABMCListPagosRegistrados.setVisibleReportes(true);
        compomenteABMCListPagosRegistrados.setEditableBoolean(false);
        compomenteABMCListPagosRegistrados.setTituloImprimir(
                "Pagos Registrados ");

//PAGOS ANULADOS
        jPanel9.add(compomenteABMCListPagosAnulados,
                    java.awt.BorderLayout.CENTER);
        compomenteABMCListPagosAnulados.setVisibleCantidadRegistros(true);
        compomenteABMCListPagosAnulados.setVisibleBuscar(true);
        compomenteABMCListPagosAnulados.setInfoColumna(new String[][] { {
                "nombre",
                "tipo", "editable", "editor",
                "val.Combo", "Ancho Columna"}

                , {"Nombre", "String", "true",
                "comun", "", "90"}

                , {"Apellido", "String",
                "true", "comun", "", "90"}

                , {"DNI", "Long", "true",
                "comun", "", "50"}

                , {"Curso", "String",
                "true", "comun", "", "50"}

                , {"Concepto", "String",
                "true", "comun", "", "55"}

                , {"Concepto descuento", "String",
                "true", "comun", "", "110"}

                , {"Importe", "Double",
                "true", "comun", "", "80"}

        });

        compomenteABMCListPagosAnulados.setVisibleAgregar(false);
        compomenteABMCListPagosAnulados.setVisibleOrdenar(false);
        compomenteABMCListPagosAnulados.setVisibleModificar(false);
        compomenteABMCListPagosAnulados.setVisibleImprimir(true);
        compomenteABMCListPagosAnulados.setVisibleGuardarComo(true);
        compomenteABMCListPagosAnulados.setVisibleHeaderTabla(true);
        compomenteABMCListPagosAnulados.setVisibleFiltrar(false);
        compomenteABMCListPagosAnulados.setVisibleEliminar(false);
        compomenteABMCListPagosAnulados.setVisibleCopyclipboard(true);
        compomenteABMCListPagosAnulados.setVisibleReportes(true);
        compomenteABMCListPagosAnulados.setEditableBoolean(false);
        compomenteABMCListPagosAnulados.setTituloImprimir(
                "Pagos Anulados ");
    }


    /**
     * loadList
     */
    private void loadLists(Date date) {
double totalFacturado=0;
        Date dateMax = new Date(date.getTime() + 86400000L); // le sumo un dia

        compomenteABMCListPagosRegistrados.clearDatos();
        compomenteABMCListPagosAnulados.clearDatos();

        //Registrados
        Vector vRegistrados = org.salamanca.broker.BrokerServer.instance().
                              queryParameter(
                                      Pago.class, "import java.util.Date",
                                      "java.util.Date dateMin, java.util.Date dateMax",
                                      "fechaPago>=dateMin && fechaPago<=dateMax && anulado==false",
                                      date, dateMax);

        if ((vRegistrados != null) && (vRegistrados.size() > 0)) {
            Object[][] trabajo = new Object[vRegistrados.size()][7];
            for (int i = 0; i < vRegistrados.size(); i++) {
                Pago pago = (Pago) vRegistrados.elementAt(i);

                trabajo[i][0] = pago.getAlumno().getNombre();
                trabajo[i][1] = pago.getAlumno().getApellido();
                trabajo[i][2] = pago.getAlumno().getDocumento();
                trabajo[i][3] = pago.getCuotaPagada().getCurso().getNombre();
                trabajo[i][4] = pago.getCuotaPagada().getConcepto();
                trabajo[i][5] = pago.getNombreDescuento();
                trabajo[i][6] = String.valueOf(pago.getImportePagado());
                totalFacturado=totalFacturado+pago.getImportePagado();
                compomenteABMCListPagosRegistrados.setDatos(trabajo);
            }
        }
        this.jLabelTotalFacturado.setText(String.valueOf(totalFacturado));
//Anulados

        Vector vAnulados = org.salamanca.broker.BrokerServer.instance().
                           queryParameter(
                                   Pago.class, "import java.util.Date",
                                   "java.util.Date dateMin, java.util.Date dateMax",
                                   "anulado==true && fechaAnulacion>=dateMin && fechaAnulacion<=dateMax",
                                   date, dateMax);

        if ((vAnulados != null) && (vAnulados.size() > 0)) {
            Object[][] trabajo = new Object[vAnulados.size()][7];
            for (int i = 0; i < vAnulados.size(); i++) {
                Pago pago = (Pago) vAnulados.elementAt(i);

                trabajo[i][0] = pago.getAlumno().getNombre();
                trabajo[i][1] = pago.getAlumno().getApellido();
                trabajo[i][2] = pago.getAlumno().getDocumento();
                trabajo[i][3] = pago.getCuotaPagada().getCurso().getNombre();
                trabajo[i][4] = pago.getCuotaPagada().getConcepto();
                trabajo[i][5] = pago.getNombreDescuento();
                trabajo[i][6] = String.valueOf(pago.getImportePagado());

                compomenteABMCListPagosAnulados.setDatos(trabajo);
            }
        }

    }

    /**
     * loadTotalesValesRecibidos
     *
     * @param date Date
     */
    private void loadTotalesValesRecibidos(Date date) {

        Date dateMax = new Date(date.getTime() + 86400000L); // le sumo un dia

        //Registrados
        Vector vRegistrados = org.salamanca.broker.BrokerServer.instance().
                              queryParameter(
                                      Vale.class, "import java.util.Date",
                                      "java.util.Date dateMin, java.util.Date dateMax",
                                      "fechaUtilizacion !=null && fechaUtilizacion>=dateMin &&  fechaUtilizacion<=dateMax",
                                      date, dateMax);
        double totalVales = 0;
        Enumeration enumer = vRegistrados.elements();
        while (enumer.hasMoreElements()) {
            Vale itemVale = (Vale) enumer.nextElement();
            totalVales = totalVales + itemVale.getImporte();

        }
        this.jLabelValesRecibidos.setText(String.valueOf(totalVales));
    }

    /**
     * loadTotalesValesEmitidos
     *
     * @param date Date
     */
    private void loadTotalesValesEmitidos(Date date) {

        Date dateMax = new Date(date.getTime() + 86400000L); // le sumo un dia

        //Registrados
        Vector vRegistrados = org.salamanca.broker.BrokerServer.instance().
                              queryParameter(
                                      Vale.class, "import java.util.Date",
                                      "java.util.Date dateMin, java.util.Date dateMax",
                                      "fechaEmision>=dateMin && fechaEmision<=dateMax",
                                      date, dateMax);
        double totalVales = 0;
        Enumeration enumer = vRegistrados.elements();
        while (enumer.hasMoreElements()) {
            Vale itemVale = (Vale) enumer.nextElement();
            totalVales = totalVales + itemVale.getImporte();

        }
        this.jLabelValesEmitidos.setText(String.valueOf(totalVales));
    }
    /**
     * jCalendar1_propertyChange
     *
     * @param evt PropertyChangeEvent
     */
    public void jCalendar1_propertyChange(PropertyChangeEvent evt) {
        int day = this.jCalendar1.getDayChooser().getDay();
        int month = this.jCalendar1.getMonthChooser().getMonth();
        int year = this.jCalendar1.getYearChooser().getYear();

        GregorianCalendar calMin = new GregorianCalendar(year, month, day);
        Date date = calMin.getTime();
        loadLists(date);
        loadTotalesValesRecibidos(date);
        loadTotalesValesEmitidos(date);
    }
}


class HistorialPagosFrame_jCalendar1_propertyChangeAdapter implements
        PropertyChangeListener {
    private HistorialPagosFrame adaptee;
    HistorialPagosFrame_jCalendar1_propertyChangeAdapter(HistorialPagosFrame
            adaptee) {
        this.adaptee = adaptee;
    }

    public void propertyChange(PropertyChangeEvent evt) {
        adaptee.jCalendar1_propertyChange(evt);
    }
}
TOP

Related Classes of org.salamanca.ui.HistorialPagosFrame

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.