Package org.salamanca.ui

Source Code of org.salamanca.ui.CuotasFrame_compomenteABMCListCuotas_componentAdapter

package org.salamanca.ui;

import java.awt.BorderLayout;

import javax.swing.JInternalFrame;
import org.salamanca.domain.Curso;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Font;
import componenteTabla.compomenteABMCList;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.WindowConstants;
import componenteTabla.InsertarEvent;
import componenteTabla.InsertarListener;
import java.text.ParseException;
import javax.swing.JOptionPane;
import java.text.SimpleDateFormat;
import org.salamanca.commands.curso.InsertarCurso;
import java.util.Date;
import java.util.Vector;
import org.salamanca.commands.MessageException;
import org.salamanca.domain.CuotaBasica;
import java.util.GregorianCalendar;
import org.salamanca.commands.cuota.InsertarCuota;
import org.salamanca.broker.*;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentAdapter;
import componenteTabla.EliminarEvent;
import componenteTabla.EliminarListener;
import org.salamanca.commands.curso.EliminarCurso;
import org.jdoinstruments.runtime.discfilemodel.util.DirectOID;
import org.salamanca.commands.cuota.EliminarCuota;
import componenteTabla.ModificarEvent;
import componenteTabla.ModificarListener;
import org.salamanca.commands.curso.ModificarCurso;
import org.salamanca.commands.cuota.ModificarCuota;
import org.salamanca.commands.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class CuotasFrame extends JInternalFrame implements CursoSelectableI {
    compomenteABMCList compomenteABMCListCuotas = new
                                                  compomenteABMCList();
    BorderLayout borderLayout1 = new BorderLayout();
    CursoFrame cursoFrame;
    Curso curso;
    JPanel jPanel1 = new JPanel();
    JPanel jPanel2 = new JPanel();
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    BorderLayout borderLayout2 = new BorderLayout();
    public CuotasFrame(CursoFrame cursoFrame) {
        this.cursoFrame = cursoFrame;

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

    }

    private void jbInit() throws Exception {
        getContentPane().setLayout(borderLayout1);
        jLabel1.setFont(new java.awt.Font("Arial", Font.PLAIN, 18));
        jLabel1.setText("Cuotas del Curso : ");
        jPanel2.setLayout(borderLayout2);
        jPanel2.setBorder(BorderFactory.createEtchedBorder());
        this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
        this.addComponentListener(new CuotasFrame_this_componentAdapter(this));
        compomenteABMCListCuotas.addInsertarListener(new
                CuotasFrame_compomenteABMCListCuotas_insertarAdapter(this));
        compomenteABMCListCuotas.addComponentListener(new
                CuotasFrame_compomenteABMCListCuotas_componentAdapter(this));
        compomenteABMCListCuotas.addEliminarListener(new
                CuotasFrame_compomenteABMCListCuotas_eliminarAdapter(this));
        compomenteABMCListCuotas.addModificarListener(new
                CuotasFrame_compomenteABMCListCuotas_modificarAdapter(this));
        this.getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
        jLabel2.setFont(new java.awt.Font("Arial", Font.PLAIN, 18));
        jLabel2.setText("...");
        jPanel1.add(jLabel1);
        jPanel1.add(jLabel2);
        jPanel2.add(compomenteABMCListCuotas, java.awt.BorderLayout.CENTER);
        this.getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);
        jPanel2.add(compomenteABMCListCuotas, java.awt.BorderLayout.CENTER);
        compomenteABMCListCuotas.setVisibleCantidadRegistros(true);
        compomenteABMCListCuotas.setVisibleBuscar(true);
        compomenteABMCListCuotas.setInfoColumna(new String[][] { {"nombre",
                                                "tipo", "editable", "editor",
                                                "val.Combo", "Ancho Columna"}
                                                , {"Fecha vencimiento",
                                                "String",
                                                "true",
                                                "comun", "", "130"}
                                                , {"Importe", "Double", "true",
                                                "comun", "", "100"}
                                                , {"Concepto", "String",
                                                "true",
                                                "comun", "", "70"}
                                                , {"Es Pago extra", "Boolean",
                                                "true", "comun", "", "130"},
                                                {"oid", "String",
                                                "false", "comun", "", "1"}

        });
        compomenteABMCListCuotas.setEditableBoolean(false);
        compomenteABMCListCuotas.setVisibleAgregar(true);
        compomenteABMCListCuotas.setVisibleOrdenar(false);
        compomenteABMCListCuotas.setVisibleModificar(true);
        compomenteABMCListCuotas.setVisibleImprimir(true);
        compomenteABMCListCuotas.setVisibleGuardarComo(false);
        compomenteABMCListCuotas.setVisibleHeaderTabla(true);
        compomenteABMCListCuotas.setVisibleFiltrar(false);
        compomenteABMCListCuotas.setVisibleEliminar(true);
        compomenteABMCListCuotas.setVisibleCopyclipboard(true);
        compomenteABMCListCuotas.setVisibleReportes(true);

        compomenteABMCListCuotas.setTituloImprimir("Cuotas del curso");

    }

    public void setCurso(Curso curso) {
        this.curso = curso;
        this.jLabel2.setText(this.curso.getNombre());
    }

    /**
     * loadList
     */
    private void loadListCuotas() {
        try {

            compomenteABMCListCuotas.clearDatos();
//actualizo el objeto curso el cual puede que se le hayan insertado modificado o borrado objetos
            curso = (Curso) BrokerServer.instance().getPMF().
                    getPersistenceManager().getObjectById(javax.jdo.JDOHelper.
                    getObjectId(curso),true);
            Vector v = new Vector(curso.
                                  getSetCuotaBasica());
            if ((v != null) && (v.size() > 0)) {
                Object[][] trabajo = new Object[v.size()][5];
                for (int i = 0; i < v.size(); i++) {
                    CuotaBasica cuota = (CuotaBasica) v.elementAt(i);
                    SimpleDateFormat dateFormatInicio = new SimpleDateFormat(
                            "d-M-yyyy");
                    trabajo[i][0] = dateFormatInicio.format(cuota.
                            getFechaVencimiento());
                    trabajo[i][1] = Double.valueOf(cuota.getImporte());
                    trabajo[i][2] = cuota.getConcepto();
                    trabajo[i][3] = Boolean.valueOf(cuota.isPagoExtra());
                    trabajo[i][4] = javax.jdo.JDOHelper.
                                    getObjectId(cuota).toString();
                }
                compomenteABMCListCuotas.setDatos(trabajo);
            }
        }

        catch (Exception ex) {
            ex.printStackTrace();
        }

    }


    public void compomenteABMCListCuotas_Insercion(InsertarEvent e) {
        CuotaBasica cuota = new CuotaBasica();
        SimpleDateFormat dateFechaVencimiento = new SimpleDateFormat("d-M-yyyy");
        String fechaVencimientoStr = (String) ((Vector) e.getVector()).
                                     elementAt(
                                             0);
        Date fechaVencimiento = null;

        try {
            fechaVencimiento = dateFechaVencimiento.parse(fechaVencimientoStr);
        } catch (ParseException ex1) {
            JOptionPane.showMessageDialog(this, "Fecha de vencimiento erronea");
            this.loadListCuotas();
            return;
        }

        double importe = ((Double) ((Vector) e.getVector()).elementAt(1)).
                         doubleValue();
        String concepto = (String) ((Vector) e.getVector()).elementAt(2);
        boolean esPagoExtra = ((Boolean) ((Vector) e.getVector()).elementAt(3)).
                              booleanValue();

        cuota.setFechaVencimiento(fechaVencimiento);
        cuota.setImporte(importe);
        cuota.setConcepto(concepto);
        cuota.setPagoExtra(esPagoExtra);

        ICommand insertarCuota = CommandFactory.createInsertarCuota(cuota, curso);
        try {
            insertarCuota.execute();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());

        }

        this.loadListCuotas();
    }

    public void compomenteABMCListCuotas_componentShown(ComponentEvent e) {

    }

    public void this_componentShown(ComponentEvent e) {
        loadListCuotas();
    }

    public void compomenteABMCListCuotas_Eliminacion(EliminarEvent e) {
        String oidStr = ((String) ((Vector) e.getVector()).elementAt(4));
        kodo.util.Id oid = new kodo.util.Id(oidStr);

        CuotaBasica cuota = (CuotaBasica) BrokerServer.instance().getPMF().
                            getPersistenceManager().getObjectById(oid,true);

        ICommand eiminarCuota = CommandFactory.createEliminarCuota(cuota);
        try {
            eiminarCuota.execute();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }
        this.loadListCuotas();
    }

    public void compomenteABMCListCuotas_Modificacion(ModificarEvent e) {
        String oidStr = ((String) ((Vector) e.getVector()).elementAt(4));
        kodo.util.Id oid = new kodo.util.Id(oidStr);

        CuotaBasica cuota = (CuotaBasica) BrokerServer.instance().getPMF().
                            getPersistenceManager().getObjectById(oid,true);

        SimpleDateFormat dateFechaVencimiento = new SimpleDateFormat("d-M-yyyy");
        String fechaVencimientoStr = (String) ((Vector) e.getVector()).
                                     elementAt(
                                             0);
        Date fechaVencimiento = null;

        try {
            fechaVencimiento = dateFechaVencimiento.parse(fechaVencimientoStr);
        } catch (ParseException ex1) {
            JOptionPane.showMessageDialog(this, "Fecha de vencimiento erronea");
            this.loadListCuotas();
            return;
        }

        double importe = ((Double) ((Vector) e.getVector()).elementAt(1)).
                         doubleValue();
        String concepto = (String) ((Vector) e.getVector()).elementAt(2);
        boolean esPagoExtra = ((Boolean) ((Vector) e.getVector()).elementAt(3)).
                              booleanValue();

        ICommand modificarCuota = CommandFactory.createModificarCuota(cuota,
                esPagoExtra, importe, fechaVencimiento, concepto);
        try {
            modificarCuota.execute();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
            loadListCuotas();
        }
        loadListCuotas();
    }


}


class CuotasFrame_this_componentAdapter extends ComponentAdapter {
    private CuotasFrame adaptee;
    CuotasFrame_this_componentAdapter(CuotasFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void componentShown(ComponentEvent e) {
        adaptee.this_componentShown(e);
    }
}


class CuotasFrame_compomenteABMCListCuotas_componentAdapter extends
        ComponentAdapter {
    private CuotasFrame adaptee;
    CuotasFrame_compomenteABMCListCuotas_componentAdapter(CuotasFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void componentShown(ComponentEvent e) {
        adaptee.compomenteABMCListCuotas_componentShown(e);
    }
}


class CuotasFrame_compomenteABMCListCuotas_modificarAdapter implements
        ModificarListener {
    private CuotasFrame adaptee;
    CuotasFrame_compomenteABMCListCuotas_modificarAdapter(CuotasFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void Modificacion(ModificarEvent e) {
        adaptee.compomenteABMCListCuotas_Modificacion(e);
    }
}


class CuotasFrame_compomenteABMCListCuotas_eliminarAdapter implements
        EliminarListener {
    private CuotasFrame adaptee;
    CuotasFrame_compomenteABMCListCuotas_eliminarAdapter(CuotasFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void Eliminacion(EliminarEvent e) {
        adaptee.compomenteABMCListCuotas_Eliminacion(e);
    }
}


class CuotasFrame_compomenteABMCListCuotas_insertarAdapter implements
        InsertarListener {
    private CuotasFrame adaptee;
    CuotasFrame_compomenteABMCListCuotas_insertarAdapter(CuotasFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void Insercion(InsertarEvent e) {
        adaptee.compomenteABMCListCuotas_Insercion(e);
    }
}
TOP

Related Classes of org.salamanca.ui.CuotasFrame_compomenteABMCListCuotas_componentAdapter

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.