Package org.salamanca.ui

Source Code of org.salamanca.ui.RecargosTarjetasFrame_this_internalFrameAdapter

package org.salamanca.ui;

import java.awt.BorderLayout;

import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import java.awt.Font;
import componenteTabla.compomenteABMCList;
import org.salamanca.domain.Vale;
import org.salamanca.broker.BrokerServer;
import java.util.Vector;
import java.text.SimpleDateFormat;
import org.salamanca.domain.*;
import componenteTabla.InsertarEvent;
import componenteTabla.InsertarListener;
import java.util.Date;
import org.salamanca.commands.CommandFactory;
import org.salamanca.commands.ICommand;
import javax.swing.JOptionPane;
import componenteTabla.EliminarEvent;
import componenteTabla.EliminarListener;
import javax.swing.WindowConstants;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.InternalFrameAdapter;
import componenteTabla.ModificarEvent;
import componenteTabla.ModificarListener;
import java.text.ParseException;

/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class RecargosTarjetasFrame extends JInternalFrame {
    BorderLayout borderLayout1 = new BorderLayout();
    JPanel jPanel1 = new JPanel();
    JPanel jPanel2 = new JPanel();
    JLabel jLabel1 = new JLabel();
    compomenteABMCList compomenteABMCListRecargos = new
            compomenteABMCList();
    BorderLayout borderLayout2 = new BorderLayout();
    MainFrame mainFrame;

    /**
     * RecargosTarjetasFrame
     */
    public RecargosTarjetasFrame() {
        try {
            jbInit();
            loadList();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    /**
     * RecargosTarjetasFrame
     *
     * @param mainFrame MainFrame
     */
    public RecargosTarjetasFrame(MainFrame mainFrame) {

        this.mainFrame = mainFrame;
        try {
            jbInit();
            loadList();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }


    /**
     * jbInit
     *
     * @throws Exception
     */
    private void jbInit() throws Exception {
        getContentPane().setLayout(borderLayout1);
        jPanel2.setLayout(borderLayout2);
        compomenteABMCListRecargos.addInsertarListener(new
                RecargosTarjetasFrame_compomenteABMCListRecargos_insertarAdapter(this));
        compomenteABMCListRecargos.addEliminarListener(new
                RecargosTarjetasFrame_compomenteABMCListRecargos_eliminarAdapter(this));
        this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
        this.addInternalFrameListener(new
                                      RecargosTarjetasFrame_this_internalFrameAdapter(this));
        compomenteABMCListRecargos.addModificarListener(new
                RecargosTarjetasFrame_compomenteABMCListRecargos_modificarAdapter(this));
        this.getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
        jLabel1.setFont(new java.awt.Font("Arial", Font.BOLD, 14));
        jPanel1.add(jLabel1);
        jLabel1.setText("Recragos por forma de pago");
        jPanel2.setBorder(BorderFactory.createEtchedBorder());
        this.getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);
        jPanel2.add(compomenteABMCListRecargos, java.awt.BorderLayout.NORTH);

        compomenteABMCListRecargos.setVisibleCantidadRegistros(true);
        compomenteABMCListRecargos.setVisibleBuscar(true);
        compomenteABMCListRecargos.setInfoColumna(new String[][] { {"nombre",
                                                  "tipo", "editable", "editor",
                                                  "val.Combo", "Ancho Columna"}
                                                  , {"Concepto",
                                                  "String", "true", "comun",
                                                  "",
                                                  "140"}

                                                  , {"Porcentaje Recargo",
                                                  "Double",
                                                  "true", "comun", "", "180"}

                                                  , {"oid", "String",
                                                  "false", "comun", "", "1"}
        });
        compomenteABMCListRecargos.setPrimaryKeyColumn(0); //es el DNI
        compomenteABMCListRecargos.setVisibleAgregar(true);
        compomenteABMCListRecargos.setVisibleOrdenar(false);
        compomenteABMCListRecargos.setVisibleModificar(true);
        compomenteABMCListRecargos.setVisibleImprimir(true);
        compomenteABMCListRecargos.setVisibleGuardarComo(false);
        compomenteABMCListRecargos.setVisibleHeaderTabla(true);
        compomenteABMCListRecargos.setVisibleFiltrar(false);
        compomenteABMCListRecargos.setVisibleEliminar(true);
        compomenteABMCListRecargos.setVisibleCopyclipboard(true);
        compomenteABMCListRecargos.setVisibleReportes(true);
        compomenteABMCListRecargos.setEditableBoolean(false);

        compomenteABMCListRecargos.setTituloImprimir("Recargos");

    }


    /**
     * loadList
     */
    private void loadList() {
        Vector v = BrokerServer.instance().getAll(Recargo.class);
        try {
            compomenteABMCListRecargos.clearDatos();
            if ((v != null) && (v.size() > 0)) {
                Object[][] trabajo = new Object[v.size()][3];
                for (int i = 0; i < v.size(); i++) {
                    Recargo recargo = (Recargo) v.elementAt(i);
                    trabajo[i][0] = recargo.getConcepto();
                    trabajo[i][1] = new Double(recargo.getPorcentaje());

                    trabajo[i][2] = javax.jdo.JDOHelper.
                                    getObjectId(recargo).toString();
                }
                compomenteABMCListRecargos.setDatos(trabajo);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /**
     * compomenteABMCListRecargos_Insercion
     *
     * @param e InsertarEvent
     */
    public void compomenteABMCListRecargos_Insercion(InsertarEvent e) {
        Recargo recargo = new Recargo();
        String concepto = ((String) ((Vector) e.getVector()).elementAt(0));
        double porcentaje = ((Double) ((Vector) e.getVector()).elementAt(1)).
                            doubleValue();
        recargo.setConcepto(concepto);
        recargo.setPorcentaje(porcentaje);
        ICommand insertarVale = CommandFactory.createInsertarRecargoTarjeta(
                recargo);
        try {
            insertarVale.execute();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }
        loadList();
    }

    /**
     * compomenteABMCListRecargos_Eliminacion
     *
     * @param e EliminarEvent
     */
    public void compomenteABMCListRecargos_Eliminacion(EliminarEvent e) {
        String oidStr = ((String) ((Vector) e.getVector()).elementAt(2));
        kodo.util.Id oid = new kodo.util.Id(oidStr);

        Recargo recargo = (Recargo) BrokerServer.instance().getPMF().
                          getPersistenceManager().getObjectById(oid, true);

        ICommand eiminarRecargo = CommandFactory.createEliminarRecargoTarjeta(
                recargo);
        try {
            eiminarRecargo.execute();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
            loadList();

        }
        loadList();
    }

    public void this_internalFrameClosing(InternalFrameEvent e) {

    }

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

        Recargo recargo = (Recargo) BrokerServer.instance().getPMF().
                          getPersistenceManager().getObjectById(oid, true);
        String concepto = (String) ((Vector) e.getVector()).elementAt(0);
        double porcentaje = ((Double) ((Vector) e.getVector()).elementAt(1)).
                            doubleValue();

        ICommand modificarRecargo = CommandFactory.createModificarRecargoTarjeta(recargo,concepto,porcentaje);
        try {
            modificarRecargo.execute();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
            loadList();
        }

        loadList();
    }

}


class RecargosTarjetasFrame_this_internalFrameAdapter extends
        InternalFrameAdapter {
    private RecargosTarjetasFrame adaptee;
    RecargosTarjetasFrame_this_internalFrameAdapter(RecargosTarjetasFrame
            adaptee) {
        this.adaptee = adaptee;
    }

    public void internalFrameClosing(InternalFrameEvent e) {
        adaptee.this_internalFrameClosing(e);
    }
}


class RecargosTarjetasFrame_compomenteABMCListRecargos_modificarAdapter implements
        ModificarListener {
    private RecargosTarjetasFrame adaptee;
    RecargosTarjetasFrame_compomenteABMCListRecargos_modificarAdapter(
            RecargosTarjetasFrame adaptee) {
        this.adaptee = adaptee;
    }

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


class RecargosTarjetasFrame_compomenteABMCListRecargos_eliminarAdapter implements
        EliminarListener {
    private RecargosTarjetasFrame adaptee;
    RecargosTarjetasFrame_compomenteABMCListRecargos_eliminarAdapter(
            RecargosTarjetasFrame adaptee) {
        this.adaptee = adaptee;
    }

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


class RecargosTarjetasFrame_compomenteABMCListRecargos_insertarAdapter implements
        InsertarListener {
    private RecargosTarjetasFrame adaptee;
    RecargosTarjetasFrame_compomenteABMCListRecargos_insertarAdapter(
            RecargosTarjetasFrame adaptee) {
        this.adaptee = adaptee;
    }

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

Related Classes of org.salamanca.ui.RecargosTarjetasFrame_this_internalFrameAdapter

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.