/*
* Copyright (C) 2014 heap.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.dataman.prometeo.swing;
import com.dataman.prometeo.core.TM_Productos;
import com.dataman.prometeo.core.Compra;
import com.dataman.prometeo.core.IF_Constantes;
import com.dataman.prometeo.core.Item;
import com.dataman.prometeo.core.Proveedor;
import com.dataman.prometeo.core.TYPE_TipoOperacion;
import java.awt.HeadlessException;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Currency;
import java.util.Locale;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
/**
*
* @author heap
* @param <E>
*/
public class Transaccion<IF_SQL_OPs> extends javax.swing.JInternalFrame {
private static final Logger LOG = Logger.getLogger(Transaccion.class.getName());
private IF_SQL_OPs e;
private PnlBuscador<Proveedor> pnlBuscadorProveedor;
private PnlBuscador<Item> pnlBuscadorItem;
private Proveedor pro;
private Item it;
private TM_Productos productosModelo;
private float subtotal = 0F, iva = 0F, total = 0F;
/**
* Compras
*
* @param title de la ventana
* @param icon de la ventana
* @param op elemento de trabajo
*/
public Transaccion(String title, String icon, IF_SQL_OPs op) {
initComponents();
this.setTitle(title);
this.setFrameIcon(frameIcon);
this.e = op;
this.productosModelo = new TM_Productos();
jtblProductos.setModel(productosModelo);
pnlBuscadorItem = new PnlBuscador<>(new Item(-1), "Buscador de Producto");
pnlBuscadorProveedor = new PnlBuscador<>(new Proveedor(-1),
"Buscador de Proveedores");
jspBuscadores.setTopComponent(pnlBuscadorProveedor);
jspBuscadores.setBottomComponent(pnlBuscadorItem);
//combo
for (TYPE_TipoOperacion t : TYPE_TipoOperacion.values()) {
jcmbTipo.addItem(t.toString());
}
jtxtFecha.setText(DateFormat.getDateInstance(DateFormat.DEFAULT).
format(Calendar.getInstance().getTime()));
jbtnProductoDetalles.setVisible(false);
jbtnDetalles.setVisible(false);
this.pack();
}
/**
* 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() {
java.awt.GridBagConstraints gridBagConstraints;
jspPrincipal = new javax.swing.JSplitPane();
jpnlIzq = new javax.swing.JPanel();
jpnlA = new javax.swing.JPanel();
jtxtPar = new javax.swing.JTextField();
jbtnDetalles = new javax.swing.JButton();
jbtnProveedorBuscar = new javax.swing.JButton();
jlblParDatos = new javax.swing.JLabel();
jlblParDetalle = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jcmbTipo = new javax.swing.JComboBox();
jLabel2 = new javax.swing.JLabel();
jtxtFecha = new javax.swing.JFormattedTextField();
jpnlProducto = new javax.swing.JPanel();
jtxtProducto = new javax.swing.JTextField();
jbtnProductoDetalles = new javax.swing.JButton();
jbtnProductoSeleccionar = new javax.swing.JButton();
jlblProductoEstado = new javax.swing.JLabel();
jlblProductoCategoria = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jtxtPrecio = new javax.swing.JFormattedTextField();
jLabel3 = new javax.swing.JLabel();
jtxtCantidad = new javax.swing.JFormattedTextField();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jtxtTalla = new javax.swing.JTextField();
jtxtColor = new javax.swing.JTextField();
jPanel4 = new javax.swing.JPanel();
jbtnAgregarProducto = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jtblProductos = new javax.swing.JTable();
jbtnRemover = new javax.swing.JButton();
jlblSubtotal = new javax.swing.JLabel();
jlblIVA = new javax.swing.JLabel();
jlblTotal = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jPanel3 = new javax.swing.JPanel();
jbtnCerrar = new javax.swing.JButton();
jbtnRgistrar = new javax.swing.JButton();
filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 0));
jpnlDer = new javax.swing.JPanel();
jspBuscadores = new javax.swing.JSplitPane();
setClosable(true);
setIconifiable(true);
setMaximizable(true);
setResizable(true);
setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/com/dataman/prometeo/res/icons/cashRegister.gif"))); // NOI18N
setPreferredSize(new java.awt.Dimension(960, 540));
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.PAGE_AXIS));
jspPrincipal.setDividerLocation(620);
jspPrincipal.setResizeWeight(0.7);
jspPrincipal.setToolTipText("");
jspPrincipal.setAutoscrolls(true);
jpnlIzq.setLayout(new javax.swing.BoxLayout(jpnlIzq, javax.swing.BoxLayout.PAGE_AXIS));
jpnlA.setBorder(javax.swing.BorderFactory.createTitledBorder("A"));
jpnlA.setLayout(new java.awt.GridBagLayout());
jtxtPar.setMinimumSize(new java.awt.Dimension(4, 24));
jtxtPar.setPreferredSize(new java.awt.Dimension(55, 26));
jtxtPar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jtxtParActionPerformed(evt);
}
});
jtxtPar.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) {
jtxtParFocusGained(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 5;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 2.0;
jpnlA.add(jtxtPar, gridBagConstraints);
jbtnDetalles.setText("Detalles ...");
jbtnDetalles.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
jbtnDetallesMouseReleased(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 5;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
jpnlA.add(jbtnDetalles, gridBagConstraints);
jbtnProveedorBuscar.setText("Mostrar Datos");
jbtnProveedorBuscar.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
jbtnProveedorBuscarMouseReleased(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 6;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
jpnlA.add(jbtnProveedorBuscar, gridBagConstraints);
jlblParDatos.setText("*");
jlblParDatos.setToolTipText("RFC");
jlblParDatos.setMinimumSize(new java.awt.Dimension(34, 24));
jlblParDatos.setPreferredSize(new java.awt.Dimension(34, 26));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 5;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
jpnlA.add(jlblParDatos, gridBagConstraints);
jlblParDetalle.setText("*");
jlblParDetalle.setToolTipText("Dirección");
jlblParDetalle.setMinimumSize(new java.awt.Dimension(34, 24));
jlblParDetalle.setPreferredSize(new java.awt.Dimension(34, 26));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = 5;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
jpnlA.add(jlblParDetalle, gridBagConstraints);
jLabel4.setText("Tipo de Operación:");
jLabel4.setMinimumSize(new java.awt.Dimension(130, 24));
jLabel4.setPreferredSize(new java.awt.Dimension(160, 26));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
jpnlA.add(jLabel4, gridBagConstraints);
jcmbTipo.setMinimumSize(new java.awt.Dimension(100, 24));
jcmbTipo.setPreferredSize(new java.awt.Dimension(120, 26));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
gridBagConstraints.weightx = 1.0;
jpnlA.add(jcmbTipo, gridBagConstraints);
jLabel2.setText("Fecha de Operación:");
jLabel2.setMinimumSize(new java.awt.Dimension(130, 24));
jLabel2.setPreferredSize(new java.awt.Dimension(160, 26));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
jpnlA.add(jLabel2, gridBagConstraints);
jtxtFecha.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter()));
jtxtFecha.setMinimumSize(new java.awt.Dimension(24, 24));
jtxtFecha.setPreferredSize(new java.awt.Dimension(103, 26));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
jpnlA.add(jtxtFecha, gridBagConstraints);
jpnlIzq.add(jpnlA);
jpnlProducto.setBorder(javax.swing.BorderFactory.createTitledBorder("Producto"));
jpnlProducto.setLayout(new java.awt.GridBagLayout());
jtxtProducto.setMinimumSize(new java.awt.Dimension(4, 24));
jtxtProducto.setPreferredSize(new java.awt.Dimension(55, 26));
jtxtProducto.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jtxtProductoActionPerformed(evt);
}
});
jtxtProducto.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) {
jtxtProductoFocusGained(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 6;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.weightx = 1.0;
jpnlProducto.add(jtxtProducto, gridBagConstraints);
jbtnProductoDetalles.setText("Detalles ...");
jbtnProductoDetalles.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
jbtnProductoDetallesMouseReleased(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 6;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
jpnlProducto.add(jbtnProductoDetalles, gridBagConstraints);
jbtnProductoSeleccionar.setText("Mostrar Datos");
jbtnProductoSeleccionar.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
jbtnProductoSeleccionarMouseReleased(evt);
}
});
jbtnProductoSeleccionar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtnProductoSeleccionarActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 7;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
jpnlProducto.add(jbtnProductoSeleccionar, gridBagConstraints);
jlblProductoEstado.setText("*");
jlblProductoEstado.setToolTipText("Estado del producto");
jlblProductoEstado.setMinimumSize(new java.awt.Dimension(34, 24));
jlblProductoEstado.setPreferredSize(new java.awt.Dimension(34, 26));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.weightx = 1.0;
jpnlProducto.add(jlblProductoEstado, gridBagConstraints);
jlblProductoCategoria.setText("*");
jlblProductoCategoria.setToolTipText("Tipo de producto");
jlblProductoCategoria.setMinimumSize(new java.awt.Dimension(34, 24));
jlblProductoCategoria.setPreferredSize(new java.awt.Dimension(34, 26));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.weightx = 1.0;
jpnlProducto.add(jlblProductoCategoria, gridBagConstraints);
jLabel1.setText("Precio de Producto : $");
jLabel1.setMinimumSize(new java.awt.Dimension(130, 24));
jLabel1.setPreferredSize(new java.awt.Dimension(160, 26));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 4;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
jpnlProducto.add(jLabel1, gridBagConstraints);
jtxtPrecio.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0.00"))));
jtxtPrecio.setMinimumSize(new java.awt.Dimension(4, 24));
jtxtPrecio.setPreferredSize(new java.awt.Dimension(103, 26));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 5;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
jpnlProducto.add(jtxtPrecio, gridBagConstraints);
jLabel3.setText("Cantidad:");
jLabel3.setMinimumSize(new java.awt.Dimension(100, 24));
jLabel3.setPreferredSize(new java.awt.Dimension(120, 26));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 4;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
jpnlProducto.add(jLabel3, gridBagConstraints);
jtxtCantidad.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));
jtxtCantidad.setText("1");
jtxtCantidad.setMinimumSize(new java.awt.Dimension(4, 24));
jtxtCantidad.setPreferredSize(new java.awt.Dimension(103, 26));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 5;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
gridBagConstraints.weightx = 1.0;
jpnlProducto.add(jtxtCantidad, gridBagConstraints);
jLabel5.setText("Color:");
jLabel5.setMinimumSize(new java.awt.Dimension(34, 24));
jLabel5.setPreferredSize(new java.awt.Dimension(34, 26));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 2;
jpnlProducto.add(jLabel5, gridBagConstraints);
jLabel6.setText("Talla:");
jLabel6.setMinimumSize(new java.awt.Dimension(34, 24));
jLabel6.setPreferredSize(new java.awt.Dimension(25, 26));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 3;
jpnlProducto.add(jLabel6, gridBagConstraints);
jtxtTalla.setMinimumSize(new java.awt.Dimension(4, 24));
jtxtTalla.setPreferredSize(new java.awt.Dimension(55, 26));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
jpnlProducto.add(jtxtTalla, gridBagConstraints);
jtxtColor.setMinimumSize(new java.awt.Dimension(4, 24));
jtxtColor.setPreferredSize(new java.awt.Dimension(55, 26));
jtxtColor.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) {
jtxtColorFocusGained(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
jpnlProducto.add(jtxtColor, gridBagConstraints);
jpnlIzq.add(jpnlProducto);
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Listado"));
jPanel4.setLayout(new java.awt.GridBagLayout());
jbtnAgregarProducto.setText("Agregar");
jbtnAgregarProducto.setMinimumSize(new java.awt.Dimension(80, 24));
jbtnAgregarProducto.setPreferredSize(new java.awt.Dimension(80, 26));
jbtnAgregarProducto.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
jbtnAgregarProductoMouseReleased(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
jPanel4.add(jbtnAgregarProducto, gridBagConstraints);
jtblProductos.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null}
},
new String [] {
"Clave", "Nombre", "Cantidad", "Precio Unitario", "Subtotal"
}
) {
boolean[] canEdit = new boolean [] {
false, false, false, false, false
};
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jScrollPane1.setViewportView(jtblProductos);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
jPanel4.add(jScrollPane1, gridBagConstraints);
jbtnRemover.setText("Remover");
jbtnRemover.setMinimumSize(new java.awt.Dimension(80, 24));
jbtnRemover.setPreferredSize(new java.awt.Dimension(80, 26));
jbtnRemover.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
jbtnRemoverMouseReleased(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
jPanel4.add(jbtnRemover, gridBagConstraints);
jlblSubtotal.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jlblSubtotal.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
jlblSubtotal.setMinimumSize(new java.awt.Dimension(34, 24));
jlblSubtotal.setPreferredSize(new java.awt.Dimension(34, 26));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
jPanel4.add(jlblSubtotal, gridBagConstraints);
jlblIVA.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jlblIVA.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
jlblIVA.setMinimumSize(new java.awt.Dimension(34, 24));
jlblIVA.setPreferredSize(new java.awt.Dimension(34, 26));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
jPanel4.add(jlblIVA, gridBagConstraints);
jlblTotal.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jlblTotal.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
jlblTotal.setMinimumSize(new java.awt.Dimension(34, 24));
jlblTotal.setPreferredSize(new java.awt.Dimension(34, 26));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 4;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
jPanel4.add(jlblTotal, gridBagConstraints);
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel7.setText("Subtotal:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
jPanel4.add(jLabel7, gridBagConstraints);
jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel8.setText("IVA:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
jPanel4.add(jLabel8, gridBagConstraints);
jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel9.setText("Total:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 4;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
jPanel4.add(jLabel9, gridBagConstraints);
jpnlIzq.add(jPanel4);
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Detalles"));
jPanel3.setLayout(new java.awt.GridBagLayout());
jbtnCerrar.setText("Cerrar");
jbtnCerrar.setMaximumSize(new java.awt.Dimension(102, 25));
jbtnCerrar.setMinimumSize(new java.awt.Dimension(102, 25));
jbtnCerrar.setPreferredSize(new java.awt.Dimension(102, 25));
jbtnCerrar.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
jbtnCerrarMouseReleased(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
jPanel3.add(jbtnCerrar, gridBagConstraints);
jbtnRgistrar.setText("Registrar");
jbtnRgistrar.setMaximumSize(new java.awt.Dimension(102, 25));
jbtnRgistrar.setMinimumSize(new java.awt.Dimension(102, 25));
jbtnRgistrar.setPreferredSize(new java.awt.Dimension(102, 25));
jbtnRgistrar.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
jbtnRgistrarMouseReleased(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
jPanel3.add(jbtnRgistrar, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
jPanel3.add(filler1, gridBagConstraints);
jpnlIzq.add(jPanel3);
jspPrincipal.setLeftComponent(jpnlIzq);
jpnlDer.setLayout(new java.awt.BorderLayout());
jspBuscadores.setDividerLocation(150);
jspBuscadores.setDividerSize(15);
jspBuscadores.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
jspBuscadores.setOneTouchExpandable(true);
jpnlDer.add(jspBuscadores, java.awt.BorderLayout.CENTER);
jspPrincipal.setRightComponent(jpnlDer);
getContentPane().add(jspPrincipal);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jbtnProveedorBuscarMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnProveedorBuscarMouseReleased
if (pnlBuscadorProveedor.getSelected() != null) {
pro = (Proveedor) pnlBuscadorProveedor.getSelected();
pro.buscarSQL(pro.getId());
jlblParDetalle.setText(pro.getDomicilio());
jtxtPar.setText(pro.getNombre());
jlblParDatos.setText(pro.getRfc());
}
}//GEN-LAST:event_jbtnProveedorBuscarMouseReleased
private void jbtnDetallesMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnDetallesMouseReleased
PnlProveedores pTmp = new PnlProveedores(pro.getId());
pTmp.setVisible(true);
JIFGenerico proveedorDetalles = new JIFGenerico(
"/com/dataman/prometeo/res/icons/morePeople.gif",
"Proveedores",
pTmp);
proveedorDetalles.show();
proveedorDetalles.pack();
getParent().getParent().add(pTmp);
getParent().getParent().repaint();
}//GEN-LAST:event_jbtnDetallesMouseReleased
private void jbtnProductoDetallesMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnProductoDetallesMouseReleased
if (jspPrincipal.getRightComponent() != null) {
jspPrincipal.remove(2);
}
PnlItems pTmp = new PnlItems(it.getIdProducto());
pTmp.setVisible(true);
jspPrincipal.add(pTmp, 2);
}//GEN-LAST:event_jbtnProductoDetallesMouseReleased
private void jbtnProductoSeleccionarMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnProductoSeleccionarMouseReleased
if (pnlBuscadorItem.getSelected() != null) {
it = (Item) pnlBuscadorItem.getSelected();
it.buscarSQL(it.getId());
jtxtProducto.setText(it.getNombre());
jlblProductoEstado.setText(it.getEstado());
jtxtPrecio.setText(String.valueOf(it.getPrecioBase()));
jlblProductoCategoria.setText(it.getCategoria());
jtxtColor.setText(it.getColor());
jtxtTalla.setText(it.getTalla());
}
}//GEN-LAST:event_jbtnProductoSeleccionarMouseReleased
private void jtxtProductoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtProductoActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jtxtProductoActionPerformed
private void jtxtParActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtParActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jtxtParActionPerformed
private void jbtnAgregarProductoMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnAgregarProductoMouseReleased
if (it != null && jtxtColor.getText().length() > 0
&& jtxtTalla.getText().length() > 0) {
try {
//Subtotal
jtxtCantidad.commitEdit();
jtxtPrecio.commitEdit();
Double d = Double.valueOf(jtxtPrecio.getText());
Long p = (Long) jtxtCantidad.getValue();
Double s = p * d;
//
int fila = jtblProductos.getRowCount() - 1;
jtblProductos.setValueAt(it.getIdProducto(), fila, 0);
jtblProductos.setValueAt(it.getNombre(), fila, 1);
jtblProductos.setValueAt(String.valueOf(p), fila, 2);
jtblProductos.setValueAt(jtxtColor.getText().toUpperCase(), fila, 3);
jtblProductos.setValueAt(jtxtTalla.getText(), fila, 4);
jtblProductos.setValueAt(String.valueOf(d), fila, 5);
jtblProductos.setValueAt(String.valueOf(s.floatValue()), fila, 6);
productosModelo.addRow();
jtblProductos.repaint();
jspPrincipal.setDividerLocation(
jspPrincipal.getDividerLocation() + 1);
subtotal += s;
iva = subtotal * IF_Constantes.IVA;
total = subtotal + iva;
jlblSubtotal.setText(
DecimalFormat.getCurrencyInstance().
format(subtotal));
jlblIVA.setText(
DecimalFormat.getCurrencyInstance().
format(iva));
jlblTotal.setText(
DecimalFormat.getCurrencyInstance().
format(total));
} catch (ParseException parseException) {
LOG.severe(parseException.getLocalizedMessage());
}
}
}//GEN-LAST:event_jbtnAgregarProductoMouseReleased
private void jbtnRemoverMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnRemoverMouseReleased
int r = jtblProductos.getSelectedRow();
String valor = (String) jtblProductos.getValueAt(r, 0);
if (valor.compareTo("") != 0) {
//Borrado y resta del total
String c = (String) jtblProductos.getValueAt(r, 2);
String p = (String) jtblProductos.getValueAt(r, 5);
float cnt = Float.parseFloat(c);
float prc = Float.parseFloat(p);
float sub = cnt * prc;
subtotal -= sub;
iva = subtotal * IF_Constantes.IVA;
total = subtotal + iva;
jlblSubtotal.setText(
DecimalFormat.getCurrencyInstance().
format(subtotal));
jlblIVA.setText(
DecimalFormat.getCurrencyInstance().
format(iva));
jlblTotal.setText(
DecimalFormat.getCurrencyInstance().
format(total));
productosModelo.removeRow(r);
this.repaint();
jspPrincipal.setDividerLocation(
jspPrincipal.getDividerLocation() - 1);
}
}//GEN-LAST:event_jbtnRemoverMouseReleased
private void jtxtProductoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtxtProductoFocusGained
jtxtProducto.selectAll();
}//GEN-LAST:event_jtxtProductoFocusGained
private void jtxtParFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtxtParFocusGained
jtxtPar.selectAll();
}//GEN-LAST:event_jtxtParFocusGained
private void jbtnCerrarMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnCerrarMouseReleased
this.dispose();
}//GEN-LAST:event_jbtnCerrarMouseReleased
private void jbtnRgistrarMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnRgistrarMouseReleased
try {
/**
* Checa haiga proveedor e items en la tabla
*/
String minimo = (String) jtblProductos.getValueAt(0, 0);
if (pro == null || minimo.compareTo("") == 0) {
JOptionPane.showMessageDialog(this, "SELECCIONA UN PROVEEDOR"
+ " Y AGREGA PRODUCTOS",
"MENSAJE DEL SISTEMA", JOptionPane.WARNING_MESSAGE);
return;
}
/**
* Pregunta al usuario confirmacion de registro
*/
int pregunta = JOptionPane.showConfirmDialog(this, "ESTA SEGURO(A)?",
"MENSAJE DEL SISTEMA", JOptionPane.YES_NO_OPTION);
if (pregunta == 0) {
Compra compra = new Compra();
compra.setIdProveedor(pro.getId());
compra.setEstado("NORMAL"); //Normal ó Cancelada
compra.setFechaRegistro(DateFormat.getDateInstance(DateFormat.DEFAULT).
parse(jtxtFecha.getText()));
compra.insertaSQL();
//Detalle
int r = -1;
for (int k = 0; k < productosModelo.getModel().size() - 1; ++k) {
ArrayList<String> w = productosModelo.getModel().get(k);
String idProducto = w.get(0);
String nombreProducto = w.get(1);
int cantidadProducto = Integer.valueOf(w.get(2));
String color = w.get(3);
String talla = w.get(4);
double precioProducto = Double.valueOf(w.get(5));
r = compra.insertaProductoSQL(idProducto, nombreProducto,
cantidadProducto, precioProducto,
color, talla);
}
if (r == -1) {
JOptionPane.showMessageDialog(this, "EL REGISTRO NO FUE CORRECTO",
"MENSAJE DEL SISTEMA", JOptionPane.ERROR_MESSAGE);
} else {
JOptionPane.showMessageDialog(this, "EL REGISTRO FUE CORRECTO",
"MENSAJE DEL SISTEMA", JOptionPane.INFORMATION_MESSAGE);
// LOG.log(Level.INFO, "Se agrego la COMPRA con ID=" + compra.getIdCompra());
this.dispose();
}
}
} catch (HeadlessException | NumberFormatException | ParseException ex) {
LOG.severe(ex.getLocalizedMessage());
}
}//GEN-LAST:event_jbtnRgistrarMouseReleased
private void jbtnProductoSeleccionarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnProductoSeleccionarActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jbtnProductoSeleccionarActionPerformed
private void jtxtColorFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtxtColorFocusGained
jtxtColor.selectAll();
}//GEN-LAST:event_jtxtColorFocusGained
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.Box.Filler filler1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JButton jbtnAgregarProducto;
private javax.swing.JButton jbtnCerrar;
private javax.swing.JButton jbtnDetalles;
private javax.swing.JButton jbtnProductoDetalles;
private javax.swing.JButton jbtnProductoSeleccionar;
private javax.swing.JButton jbtnProveedorBuscar;
private javax.swing.JButton jbtnRemover;
private javax.swing.JButton jbtnRgistrar;
private javax.swing.JComboBox jcmbTipo;
private javax.swing.JLabel jlblIVA;
private javax.swing.JLabel jlblParDatos;
private javax.swing.JLabel jlblParDetalle;
private javax.swing.JLabel jlblProductoCategoria;
private javax.swing.JLabel jlblProductoEstado;
private javax.swing.JLabel jlblSubtotal;
private javax.swing.JLabel jlblTotal;
private javax.swing.JPanel jpnlA;
private javax.swing.JPanel jpnlDer;
private javax.swing.JPanel jpnlIzq;
private javax.swing.JPanel jpnlProducto;
private javax.swing.JSplitPane jspBuscadores;
private javax.swing.JSplitPane jspPrincipal;
private javax.swing.JTable jtblProductos;
private javax.swing.JFormattedTextField jtxtCantidad;
private javax.swing.JTextField jtxtColor;
private javax.swing.JFormattedTextField jtxtFecha;
private javax.swing.JTextField jtxtPar;
private javax.swing.JFormattedTextField jtxtPrecio;
private javax.swing.JTextField jtxtProducto;
private javax.swing.JTextField jtxtTalla;
// End of variables declaration//GEN-END:variables
}