From: <jos...@us...> - 2007-09-16 23:50:53
|
Revision: 38 http://opaloerp.svn.sourceforge.net/opaloerp/?rev=38&view=rev Author: jose_cruz64 Date: 2007-09-16 16:50:57 -0700 (Sun, 16 Sep 2007) Log Message: ----------- Funcionalidades agregadas: -Agregar nuevos proveedores -Agregar detalles generales al proveedor -Agregar direccion principal -Agrgar contacto principal -Agregar contactos secundarios -Agregar direcciones secundarias -Editar proveedores -Editar los datos generales del proveedor -Editar la direccion principal -Editar el contacto principal -Borrar proveedores -Borra en cascada todo lo relacionado al proveedor -Visualizar proveedores -Perite visualizar todo lo relacionado al proveedor seleccionada Funcionalidades removidas: -Ninguna en esta revision Funcionalidades pendientes para las proximas revisiones: -Agregar nuevos proveedores -Editar las direcciones secundarias -Borrar las direcciones secundarias -Asignar, editar, y remover productos para el proveedor -Editar proveedores -Editar las direcciones secundarias -Borrar las direcciones secundarias -Borrar direcciones y contactos en forma individual dentro de un proveedor -Asignar, editar, y remover productos para el proveedor Modified Paths: -------------- OpaloERP/src/frontend/cliente/DgDireccionCliente.form OpaloERP/src/frontend/cliente/DgDireccionCliente.java OpaloERP/src/frontend/proveedor/DgCrearProveedor.form OpaloERP/src/frontend/proveedor/DgCrearProveedor.java OpaloERP/src/frontend/proveedor/IAdministrarProveedor.form OpaloERP/src/mensaje_objetos/proveedor/Proveedor.java OpaloERP/src/modelo_objetos/proveedor/ModeloProveedor.java Modified: OpaloERP/src/frontend/cliente/DgDireccionCliente.form =================================================================== --- OpaloERP/src/frontend/cliente/DgDireccionCliente.form 2007-09-16 18:38:42 UTC (rev 37) +++ OpaloERP/src/frontend/cliente/DgDireccionCliente.form 2007-09-16 23:50:57 UTC (rev 38) @@ -3,7 +3,7 @@ <Form version="1.3" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> <Properties> <Property name="defaultCloseOperation" type="int" value="2"/> - <Property name="title" type="java.lang.String" value="Seleccionar Direccion Cliente"/> + <Property name="title" type="java.lang.String" value="Seleccionar Direccion"/> </Properties> <SyntheticProperties> <SyntheticProperty name="formSizePolicy" type="int" value="1"/> Modified: OpaloERP/src/frontend/cliente/DgDireccionCliente.java =================================================================== --- OpaloERP/src/frontend/cliente/DgDireccionCliente.java 2007-09-16 18:38:42 UTC (rev 37) +++ OpaloERP/src/frontend/cliente/DgDireccionCliente.java 2007-09-16 23:50:57 UTC (rev 38) @@ -87,7 +87,8 @@ * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents - private void initComponents() { + private void initComponents() + { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); @@ -106,7 +107,7 @@ btnBuscarCiudad = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - setTitle("Seleccionar Direccion Cliente"); + setTitle("Seleccionar Direccion"); jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); jLabel1.setText("Direccion"); @@ -121,8 +122,10 @@ btnCerrar.setMnemonic('C'); btnCerrar.setText("Cerrar"); - btnCerrar.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCerrar.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(java.awt.event.ActionEvent evt) + { btnCerrarActionPerformed(evt); } }); @@ -130,23 +133,29 @@ btnSeleccionar.setFont(new java.awt.Font("Dialog", 0, 12)); btnSeleccionar.setMnemonic('S'); btnSeleccionar.setText("Seleccionar"); - btnSeleccionar.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { + btnSeleccionar.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(java.awt.event.ActionEvent evt) + { btnSeleccionarActionPerformed(evt); } }); btnBuscarPais.setMnemonic('B'); btnBuscarPais.setText("Buscar..."); - btnBuscarPais.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { + btnBuscarPais.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(java.awt.event.ActionEvent evt) + { btnBuscarPaisActionPerformed(evt); } }); btnBuscarProvincia.setText("Buscar..."); - btnBuscarProvincia.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { + btnBuscarProvincia.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(java.awt.event.ActionEvent evt) + { btnBuscarProvinciaActionPerformed(evt); } }); @@ -154,15 +163,19 @@ jLabel5.setText("Region"); btnBuscarRegion.setText("Buscar..."); - btnBuscarRegion.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { + btnBuscarRegion.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(java.awt.event.ActionEvent evt) + { btnBuscarRegionActionPerformed(evt); } }); btnBuscarCiudad.setText("Buscar..."); - btnBuscarCiudad.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { + btnBuscarCiudad.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(java.awt.event.ActionEvent evt) + { btnBuscarCiudadActionPerformed(evt); } }); Modified: OpaloERP/src/frontend/proveedor/DgCrearProveedor.form =================================================================== --- OpaloERP/src/frontend/proveedor/DgCrearProveedor.form 2007-09-16 18:38:42 UTC (rev 37) +++ OpaloERP/src/frontend/proveedor/DgCrearProveedor.form 2007-09-16 23:50:57 UTC (rev 38) @@ -420,7 +420,7 @@ </Group> <EmptySpace max="-2" attributes="0"/> <Component id="btnInsertarDireccion" min="-2" max="-2" attributes="0"/> - <EmptySpace pref="51" max="32767" attributes="0"/> + <EmptySpace pref="49" max="32767" attributes="0"/> </Group> </Group> </DimensionLayout> @@ -440,8 +440,16 @@ <SubComponents> <Component class="javax.swing.JTextArea" name="areaDireccion"> <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="e5" green="cf" id="Button.shadow" palette="3" red="b8" type="palette"/> + </Property> <Property name="columns" type="int" value="20"/> <Property name="rows" type="int" value="5"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder/> + </Border> + </Property> </Properties> </Component> </SubComponents> @@ -739,6 +747,9 @@ <Properties> <Property name="text" type="java.lang.String" value="Borrar"/> </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnBorrarDireccionActionPerformed"/> + </Events> </Component> <Component class="javax.swing.JButton" name="btnVisualizarDireccion"> <Properties> @@ -814,7 +825,7 @@ <EmptySpace max="-2" attributes="0"/> <Component id="jLabel22" min="-2" pref="137" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> - <Component id="cmbTipoBusquedaDirecciones1" pref="219" max="32767" attributes="0"/> + <Component id="cmbTipoBusquedaContactos" pref="219" max="32767" attributes="0"/> </Group> </Group> <EmptySpace max="-2" attributes="0"/> @@ -830,7 +841,7 @@ <Group type="103" groupAlignment="3" attributes="0"> <Component id="jLabel21" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="txtBuscarContacto" alignment="3" min="-2" max="-2" attributes="0"/> - <Component id="cmbTipoBusquedaDirecciones1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="cmbTipoBusquedaContactos" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="jLabel22" alignment="3" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace max="-2" attributes="0"/> @@ -865,6 +876,9 @@ <Properties> <Property name="text" type="java.lang.String" value="Borrar"/> </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnBorrarContactoActionPerformed"/> + </Events> </Component> <Component class="javax.swing.JButton" name="btnVisualizarContacto"> <Properties> @@ -888,7 +902,7 @@ <Property name="text" type="java.lang.String" value="Tipo de Busqueda:"/> </Properties> </Component> - <Component class="javax.swing.JComboBox" name="cmbTipoBusquedaDirecciones1"> + <Component class="javax.swing.JComboBox" name="cmbTipoBusquedaContactos"> <Properties> <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> <StringArray count="0"/> @@ -899,7 +913,7 @@ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> <SubComponents> - <Component class="org.jdesktop.swingx.JXTable" name="jtbDireccion1"> + <Component class="org.jdesktop.swingx.JXTable" name="jtbContacto"> <Properties> <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> <Table columnCount="5" rowCount="0"> @@ -1074,6 +1088,9 @@ <Properties> <Property name="text" type="java.lang.String" value="Salvar->"/> </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSalvarCerrarActionPerformed"/> + </Events> </Component> <Component class="javax.swing.JButton" name="btnSalvar"> <Properties> @@ -1087,6 +1104,9 @@ <Properties> <Property name="text" type="java.lang.String" value="Nuevo"/> </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnNuevoActionPerformed"/> + </Events> </Component> </SubComponents> </Form> Modified: OpaloERP/src/frontend/proveedor/DgCrearProveedor.java =================================================================== --- OpaloERP/src/frontend/proveedor/DgCrearProveedor.java 2007-09-16 18:38:42 UTC (rev 37) +++ OpaloERP/src/frontend/proveedor/DgCrearProveedor.java 2007-09-16 23:50:57 UTC (rev 38) @@ -8,6 +8,7 @@ import eventos.ContactoEvent; import eventos.DireccionEvent; +import eventos.IContactoListener; import eventos.IDireccionListener; import eventos.IProveedorListener; import eventos.ProveedorEvent; @@ -17,23 +18,32 @@ import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; +import javax.swing.JOptionPane; import javax.swing.table.AbstractTableModel; import mensaje_objetos.almacen.Producto; import mensaje_objetos.cliente.Contacto; import mensaje_objetos.cliente.Direccion; import mensaje_objetos.proveedor.Proveedor; +import modelo_objetos.cliente.ModeloContacto; +import modelo_objetos.cliente.ModeloDireccion; import modelo_objetos.proveedor.ModeloProveedor; /** * * @author raymi */ -public class DgCrearProveedor extends javax.swing.JDialog implements IProveedorListener +public class DgCrearProveedor extends javax.swing.JDialog implements IProveedorListener, IDireccionListener, + IContactoListener { private Proveedor proveedorSeleccionado; + private Direccion direccionSeleccionada; + private Contacto contactoSeleccionado; private Proveedor proveedorNuevo; private DgDireccionCliente dgDireccionProveedor; private DgCrearContacto dgCrearContacto; + private Direccion dirPrincipal; + private Contacto conPrincipal; + private boolean direccionPrincipal; private List<Direccion> listaDirecciones; private List<Contacto> listaContactos; @@ -43,6 +53,16 @@ private List<Contacto> contactoTable = new ArrayList<Contacto>(); private List<Producto> productoTable = new ArrayList<Producto>(); + private ModeloProveedor modeloProveedor; + private ModeloDireccion modeloDireccion; + private ModeloContacto modeloContacto; + private AbstractTableModel modeloTablaDireccion; + private AbstractTableModel modeloTablaContacto; + private AbstractTableModel modeloTablaProducto; + + private static final String [] headersDireccion = {"Direccion", "Ciudad", "Provincia","Region", "Pais"}; + private static final String [] headersContacto = {"Contacto","Telefono1","Telefono2","Fax","Email"}; + //private DgArticulo dgArticulo; private int accion; /** Creates new form DgCrearProveedor */ @@ -51,12 +71,143 @@ super(parent, modal); initComponents(); inicializarComponentes(); + inicializarTablaDireccion(); + inicializarTablaContacto(); } + private void inicializarTablaContacto() + { + modeloTablaContacto=new AbstractTableModel() + { + public int getColumnCount() + { + return headersContacto.length; + } + public int getRowCount() + { + return contactoTable.size(); + } + public Object getValueAt(int rowIndex, int columnIndex) + { + if(contactoTable.size()>0) + { + Contacto contacto=contactoTable.get(rowIndex); + if(contacto!=null) + { + if(columnIndex==0) + { + return contacto.getNombre(); + } + if(columnIndex==1) + { + return contacto.getTelefono1(); + } + if(columnIndex==2) + { + return contacto.getTelefono2(); + } + if(columnIndex==3) + { + return contacto.getFax(); + } + if(columnIndex==4) + { + return contacto.getEmail(); + } + } + } + return ""; + } + public String getColumnName(int col) + { + return headersContacto[col]; + } + }; + jtbContacto.setModel(modeloTablaContacto); + modeloTablaContacto.fireTableDataChanged(); + + + } + + private void inicializarTablaDireccion() + { + modeloTablaDireccion=new AbstractTableModel() + { + public int getColumnCount() + { + return headersDireccion.length; + } + public int getRowCount() + { + return direccionTable.size(); + } + public Object getValueAt(int rowIndex, int columnIndex) + { + if(direccionTable.size()>0) + { + Direccion direccion=direccionTable.get(rowIndex); + if(direccion!=null) + { + if(columnIndex==0) + { + return direccion.getDescripcion(); + } + if(columnIndex==1) + { + if(direccion.getCiudad()!=null) + { + return direccion.getCiudad().getNombre(); + } + return ""; + } + if(columnIndex==2) + { + if(direccion.getProvincia()!=null) + { + return direccion.getProvincia().getNombre(); + } + return ""; + } + if(columnIndex==3) + { + if(direccion.getRegion()!=null) + { + return direccion.getRegion().getDescripcion(); + } + return ""; + } + if(columnIndex==4) + { + if(direccion.getPais()!=null) + { + return direccion.getPais().getNombre(); + } + return ""; + } + } + } + return ""; + } + public String getColumnName(int col) + { + return headersDireccion[col]; + } + }; + jtbTablaDireccion.setModel(modeloTablaDireccion); + modeloTablaDireccion.fireTableDataChanged(); + + + } + private void inicializarComponentes() { dgDireccionProveedor = new DgDireccionCliente(new JFrame(), true); + dgDireccionProveedor.addDireccionListener(this); dgCrearContacto = new DgCrearContacto(new JFrame(), true); + dgCrearContacto.addContactoListener(this); + modeloProveedor = ModeloProveedor.getInstance(); + modeloDireccion = ModeloDireccion.getInstance(); + modeloContacto = ModeloContacto.getInstance(); //dgArticulo = new DgArticulo(new JFrame(), true); } @@ -77,16 +228,18 @@ contactoTable=proveedorSeleccionado.getContactos(); productoTable=proveedorSeleccionado.getProductos(); - direccionTable=proveedorSeleccionado.getDirecciones(); - /** modeloTablaContacto.fireTableDataChanged(); - * modeloTablaSucursal.fireTableDataChanged(); - * modeloTablaDireccion.fireTableDataChanged(); - * modeloTablaDocumento.fireTableDataChanged();*/ + direccionTable=proveedorSeleccionado.getDirecciones(); + + modeloTablaDireccion.fireTableDataChanged(); + modeloTablaContacto.fireTableDataChanged(); + //modeloTablaProducto.fireTableDataChanged(); + setProveedor(); } setEnable(true); + btnNuevo.setEnabled(false); txtCodigo.setEnabled(false); } @@ -124,6 +277,7 @@ private void limpiarCampos() { + areaDireccion.setText(""); txtBuscarDireccion.setText(""); txtBuscarContacto.setText(""); txtBuscarProducto.setText(""); @@ -150,7 +304,7 @@ private void setProveedor() { - + limpiarCampos(); txtCodigo.setText(proveedorSeleccionado.getCodigo()); if(proveedorSeleccionado.getRnc()!=null) @@ -198,25 +352,25 @@ { if(proveedorSeleccionado.getDirecciones().size()>0) { - Direccion dir=proveedorSeleccionado.getDirecciones().get(0); - if(dir!=null) + dirPrincipal = proveedorSeleccionado.getDirecciones().get(0); + if(dirPrincipal!=null) { - if(dir.getCiudad()!=null) + if(dirPrincipal.getCiudad()!=null) { - lblCiudad.setText(dir.getCiudad().getNombre()); + lblCiudad.setText(dirPrincipal.getCiudad().getNombre()); } - areaDireccion.setText(dir.getDescripcion()); - if(dir.getPais()!=null) + areaDireccion.setText(dirPrincipal.getDescripcion()); + if(dirPrincipal.getPais()!=null) { - lblPais.setText(dir.getPais().getNombre()); + lblPais.setText(dirPrincipal.getPais().getNombre()); } - if(dir.getProvincia()!=null) + if(dirPrincipal.getProvincia()!=null) { - lblProvincia.setText(dir.getProvincia().getNombre()); + lblProvincia.setText(dirPrincipal.getProvincia().getNombre()); } - if(dir.getRegion()!=null) + if(dirPrincipal.getRegion()!=null) { - lblRegion.setText(dir.getRegion().getDescripcion()); + lblRegion.setText(dirPrincipal.getRegion().getDescripcion()); } } } @@ -245,7 +399,7 @@ rbtnContado.setEnabled(ena); rbtnCredito.setEnabled(ena); rbtnRNC.setEnabled(ena); - areaDireccion.setEditable(ena); + areaDireccion.setEditable(false); txtCargo.setEnabled(ena); txtCodigo.setEnabled(ena); txtDocumento.setEnabled(ena); @@ -263,68 +417,129 @@ } public void execute() - { - ModeloProveedor modeloProveedor = ModeloProveedor.getInstance(); + { if(accion == ProveedorEvent.NUEVO) { Proveedor p = new Proveedor(); - if(rbtnCedula.isSelected()) - { - p.setCedula(txtDocumento.getText()); - p.setRnc(""); - } - else - { - p.setRnc(txtDocumento.getText()); - p.setCedula(""); - } - p.setCodigo(txtCodigo.getText()); - p.setLimiteDeCredito(Double.parseDouble(txtLimitCred.getText())); - p.setLimiteDias(BigInteger.valueOf(Long.parseLong(txtLimitDias.getText()))); - p.setNombre(txtNombre.getText()); - p.setPorcMora(new Float(txtMora.getText())); - if(rbtnContado.isSelected()) - { - p.setTipoDePago("Contado"); - } - else - { - p.setTipoDePago("Credito"); - } - - Direccion dir = new Direccion(); + this.setProveedorData(p); + this.setDireccionPrincipal(p); + this.setContactoPrincipal(p); modeloProveedor.addProveedor(p); } else if(accion == ProveedorEvent.EDITAR) { Proveedor p = this.proveedorSeleccionado; - if(rbtnCedula.isSelected()) - { - p.setCedula(txtDocumento.getText()); - p.setRnc(""); - } - else - { - p.setRnc(txtDocumento.getText()); - p.setCedula(""); - } - p.setCodigo(txtCodigo.getText()); - p.setLimiteDeCredito(Double.parseDouble(txtLimitCred.getText())); - p.setLimiteDias(BigInteger.valueOf(Long.parseLong(txtLimitDias.getText()))); - p.setNombre(txtNombre.getText()); - p.setPorcMora(new Float(txtMora.getText())); - if(rbtnContado.isSelected()) - { - p.setTipoDePago("Contado"); - } - else - { - p.setTipoDePago("Credito"); - } + this.setProveedorData(p); + this.setDireccionPrincipal(p); + this.setContactoPrincipal(p); modeloProveedor.updateProveedor(p); } - } - + } + + private void setProveedorData(Proveedor p) + { + + if(rbtnCedula.isSelected()) + { + p.setCedula(txtDocumento.getText()); + p.setRnc(""); + } + else + { + p.setRnc(txtDocumento.getText()); + p.setCedula(""); + } + p.setCodigo(txtCodigo.getText()); + p.setLimiteDeCredito(Double.parseDouble(txtLimitCred.getText())); + p.setLimiteDias(BigInteger.valueOf(Long.parseLong(txtLimitDias.getText()))); + p.setNombre(txtNombre.getText()); + p.setPorcMora(new Float(txtMora.getText())); + if(rbtnContado.isSelected()) + { + p.setTipoDePago("Contado"); + } + else + { + p.setTipoDePago("Credito"); + } + + } + + public Contacto getSelectedContacto() + { + Contacto contacto=null; + int arow=jtbContacto.getSelectedRow(); + if(arow!=-1) + { + int row=jtbContacto.convertRowIndexToModel(arow); + contacto = contactoTable.get(row); + } + return contacto; + } + + public Direccion getSelectedDireccion() + { + Direccion direccion=null; + int arow=jtbTablaDireccion.getSelectedRow(); + if(arow!=-1) + { + int row=jtbTablaDireccion.convertRowIndexToModel(arow); + direccion = direccionTable.get(row); + } + return direccion; + } + + private void setDireccionPrincipal(Proveedor p) + { + List<Direccion> direcciones = p.getDirecciones(); + direcciones.set(0, dirPrincipal); + } + + private void setContactoPrincipal(Proveedor p) + { + List<Contacto> contactos = p.getContactos(); + + conPrincipal = new Contacto(); + conPrincipal.setCargo(txtCargo.getText()); + conPrincipal.setEmail(txtEmail.getText()); + conPrincipal.setFax(txtFax.getText()); + conPrincipal.setNombre(txtNombreContacto.getText()); + conPrincipal.setTelefono1(txtTelefono1.getText()); + conPrincipal.setTelefono2(txtTelefono2.getText()); + contactos.set(0, conPrincipal); + } + + public void fireDireccion(DireccionEvent direccion) + { + Direccion dir = direccion.getDireccion(); + if(direccionPrincipal) + { + dirPrincipal = dir; + areaDireccion.setText(dir.getDescripcion()); + lblCiudad.setText(dir.getCiudad().getNombre()); + lblPais.setText(dir.getPais().getNombre()); + lblProvincia.setText(dir.getProvincia().getNombre()); + lblRegion.setText(dir.getRegion().getDescripcion()); + } + else + { + List<Direccion> direcciones = proveedorSeleccionado.getDirecciones(); + if(!direcciones.contains(dir)) direcciones.add(dir); + else direcciones.set(direcciones.indexOf(dir), dir); + + } + this.inicializarTablaDireccion(); + } + + public void fireContacto(ContactoEvent contacto) + { + List<Contacto> contactos = proveedorSeleccionado.getContactos(); + Contacto con = contacto.getContacto(); + if(!contactos.contains(con)) contactos.add(con); + else contactos.set(contactos.indexOf(con), con); + this.inicializarTablaContacto(); + } + /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is @@ -403,9 +618,9 @@ jLabel21 = new javax.swing.JLabel(); txtBuscarContacto = new javax.swing.JTextField(); jLabel22 = new javax.swing.JLabel(); - cmbTipoBusquedaDirecciones1 = new javax.swing.JComboBox(); + cmbTipoBusquedaContactos = new javax.swing.JComboBox(); jScrollPane3 = new javax.swing.JScrollPane(); - jtbDireccion1 = new org.jdesktop.swingx.JXTable(); + jtbContacto = new org.jdesktop.swingx.JXTable(); jPanel3 = new javax.swing.JPanel(); btnBuscarProducto = new javax.swing.JButton(); jLabel23 = new javax.swing.JLabel(); @@ -530,8 +745,10 @@ jpanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Direccion Principal", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 11), new java.awt.Color(51, 102, 255))); jLabel8.setText("Direccion:"); + areaDireccion.setBackground(javax.swing.UIManager.getDefaults().getColor("Button.shadow")); areaDireccion.setColumns(20); areaDireccion.setRows(5); + areaDireccion.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jScrollPane1.setViewportView(areaDireccion); jLabel9.setText("Ciudad:"); @@ -626,7 +843,7 @@ .addComponent(lblProvincia)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnInsertarDireccion) - .addContainerGap(51, Short.MAX_VALUE)) + .addContainerGap(49, Short.MAX_VALUE)) ); jpanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {lblCiudad, lblPais, lblProvincia, lblRegion}); @@ -781,6 +998,14 @@ jToolBar1.add(btnEditDireccion); btnBorrarDireccion.setText("Borrar"); + btnBorrarDireccion.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + btnBorrarDireccionActionPerformed(evt); + } + }); + jToolBar1.add(btnBorrarDireccion); btnVisualizarDireccion.setText("Visualizar"); @@ -880,6 +1105,14 @@ jToolBar2.add(btnEditContacto); btnBorrarContacto.setText("Borrar"); + btnBorrarContacto.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + btnBorrarContactoActionPerformed(evt); + } + }); + jToolBar2.add(btnBorrarContacto); btnVisualizarContacto.setText("Visualizar"); @@ -897,7 +1130,7 @@ jLabel22.setText("Tipo de Busqueda:"); - jtbDireccion1.setModel(new javax.swing.table.DefaultTableModel( + jtbContacto.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { @@ -918,7 +1151,7 @@ return canEdit [columnIndex]; } }); - jScrollPane3.setViewportView(jtbDireccion1); + jScrollPane3.setViewportView(jtbContacto); javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11); jPanel11.setLayout(jPanel11Layout); @@ -936,7 +1169,7 @@ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(cmbTipoBusquedaDirecciones1, 0, 219, Short.MAX_VALUE))) + .addComponent(cmbTipoBusquedaContactos, 0, 219, Short.MAX_VALUE))) .addContainerGap()) ); jPanel11Layout.setVerticalGroup( @@ -948,7 +1181,7 @@ .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel21) .addComponent(txtBuscarContacto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(cmbTipoBusquedaDirecciones1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(cmbTipoBusquedaContactos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel22)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 334, Short.MAX_VALUE) @@ -1057,6 +1290,13 @@ }); btnSalvarCerrar.setText("Salvar->"); + btnSalvarCerrar.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + btnSalvarCerrarActionPerformed(evt); + } + }); btnSalvar.setText("Salvar"); btnSalvar.addActionListener(new java.awt.event.ActionListener() @@ -1068,6 +1308,13 @@ }); btnNuevo.setText("Nuevo"); + btnNuevo.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + btnNuevoActionPerformed(evt); + } + }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); @@ -1116,19 +1363,80 @@ ); pack(); }// </editor-fold>//GEN-END:initComponents + + private void btnBorrarContactoActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnBorrarContactoActionPerformed + {//GEN-HEADEREND:event_btnBorrarContactoActionPerformed + contactoSeleccionado = getSelectedContacto(); + if(contactoSeleccionado != null) + { + int respuesta = JOptionPane.showInternalConfirmDialog(this, "\u00bfEst\u00e1 seguro de que desea" + + " eliminar este contacto", "Confirmar borrado de contacto", + JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); + if(respuesta == JOptionPane.OK_OPTION) + { + modeloContacto.removeContacto(contactoSeleccionado); + contactoSeleccionado = null; + this.inicializarTablaContacto(); + } + } + else + { + JOptionPane.showInternalMessageDialog(this,"Debes elegir un contacto" + + " para realizar esta operaci\u00f3n", "Seleccione un contacto", JOptionPane.WARNING_MESSAGE); + } + }//GEN-LAST:event_btnBorrarContactoActionPerformed + + private void btnBorrarDireccionActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnBorrarDireccionActionPerformed + {//GEN-HEADEREND:event_btnBorrarDireccionActionPerformed + direccionSeleccionada = getSelectedDireccion(); + if(direccionSeleccionada != null) + { + int respuesta = JOptionPane.showInternalConfirmDialog(this, "\u00bfEst\u00e1 seguro de que desea" + + " eliminar esta direccion", "Confirmar borrado de direccion", + JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); + if(respuesta == JOptionPane.OK_OPTION) + { + modeloDireccion.removeDireccion(direccionSeleccionada); + direccionSeleccionada = null; + this.inicializarTablaDireccion(); + } + } + else + { + JOptionPane.showInternalMessageDialog(this,"Debes elegir un direccion" + + " para realizar esta operaci\u00f3n", "Seleccione un direccion", JOptionPane.WARNING_MESSAGE); + } + }//GEN-LAST:event_btnBorrarDireccionActionPerformed + private void btnNuevoActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnNuevoActionPerformed + {//GEN-HEADEREND:event_btnNuevoActionPerformed + limpiarCampos(); + }//GEN-LAST:event_btnNuevoActionPerformed + + private void btnSalvarCerrarActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnSalvarCerrarActionPerformed + {//GEN-HEADEREND:event_btnSalvarCerrarActionPerformed + execute(); + dispose(); + }//GEN-LAST:event_btnSalvarCerrarActionPerformed + private void btnInsertarDireccionActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnInsertarDireccionActionPerformed {//GEN-HEADEREND:event_btnInsertarDireccionActionPerformed - + direccionPrincipal=true; + dgDireccionProveedor=new DgDireccionCliente(new JFrame(),true); + DireccionEvent dv = new DireccionEvent(); + dv.setId(DireccionEvent.NUEVO); + dgDireccionProveedor.fireDireccion(dv); + dgDireccionProveedor.setVisible(true); }//GEN-LAST:event_btnInsertarDireccionActionPerformed private void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed - this.execute(); + execute(); }//GEN-LAST:event_btnSalvarActionPerformed private void btnVisualizarContactoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnVisualizarContactoActionPerformed ContactoEvent cv = new ContactoEvent(); cv.setId(ContactoEvent.VISUALIZAR); + cv.setContacto(getSelectedContacto()); dgCrearContacto.fireContacto(cv); dgCrearContacto.setVisible(true); }//GEN-LAST:event_btnVisualizarContactoActionPerformed @@ -1136,6 +1444,7 @@ private void btnEditContactoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditContactoActionPerformed ContactoEvent cv = new ContactoEvent(); cv.setId(ContactoEvent.EDITAR); + cv.setContacto(getSelectedContacto()); dgCrearContacto.fireContacto(cv); dgCrearContacto.setVisible(true); }//GEN-LAST:event_btnEditContactoActionPerformed @@ -1143,6 +1452,7 @@ private void btnVisualizarDireccionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnVisualizarDireccionActionPerformed DireccionEvent dv = new DireccionEvent(); dv.setId(DireccionEvent.VISUALIZAR); + dv.setDireccion(getSelectedDireccion()); dgDireccionProveedor.fireDireccion(dv); dgDireccionProveedor.setVisible(true); }//GEN-LAST:event_btnVisualizarDireccionActionPerformed @@ -1150,6 +1460,7 @@ private void btnEditDireccionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditDireccionActionPerformed DireccionEvent dv = new DireccionEvent(); dv.setId(DireccionEvent.EDITAR); + dv.setDireccion(getSelectedDireccion()); dgDireccionProveedor.fireDireccion(dv); dgDireccionProveedor.setVisible(true); }//GEN-LAST:event_btnEditDireccionActionPerformed @@ -1162,6 +1473,7 @@ }//GEN-LAST:event_btnNuevoContactoActionPerformed private void btnNuevoDireccionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNuevoDireccionActionPerformed + direccionPrincipal = false; DireccionEvent dv = new DireccionEvent(); dv.setId(DireccionEvent.NUEVO); dgDireccionProveedor.fireDireccion(dv); @@ -1169,7 +1481,7 @@ }//GEN-LAST:event_btnNuevoDireccionActionPerformed private void btnCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCerrarActionPerformed - this.dispose(); + dispose(); }//GEN-LAST:event_btnCerrarActionPerformed @@ -1191,8 +1503,8 @@ private javax.swing.JButton btnSalvarCerrar; private javax.swing.JButton btnVisualizarContacto; private javax.swing.JButton btnVisualizarDireccion; + private javax.swing.JComboBox cmbTipoBusquedaContactos; private javax.swing.JComboBox cmbTipoBusquedaDirecciones; - private javax.swing.JComboBox cmbTipoBusquedaDirecciones1; private javax.swing.JComboBox cmbTipoBusquedaProducto; private javax.swing.ButtonGroup grpTipoDoc; private javax.swing.ButtonGroup grpTipoPago; @@ -1236,7 +1548,7 @@ private javax.swing.JToolBar jToolBar1; private javax.swing.JToolBar jToolBar2; private javax.swing.JPanel jpanel1; - private org.jdesktop.swingx.JXTable jtbDireccion1; + private org.jdesktop.swingx.JXTable jtbContacto; private org.jdesktop.swingx.JXTable jtbProductos; private org.jdesktop.swingx.JXTable jtbTablaDireccion; private javax.swing.JLabel lblCiudad; Modified: OpaloERP/src/frontend/proveedor/IAdministrarProveedor.form =================================================================== --- OpaloERP/src/frontend/proveedor/IAdministrarProveedor.form 2007-09-16 18:38:42 UTC (rev 37) +++ OpaloERP/src/frontend/proveedor/IAdministrarProveedor.form 2007-09-16 23:50:57 UTC (rev 38) @@ -29,7 +29,7 @@ <EmptySpace max="-2" attributes="0"/> <Component id="jLabel2" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> - <Component id="cmbTipoBusqueda" pref="135" max="32767" attributes="0"/> + <Component id="cmbTipoBusqueda" pref="144" max="32767" attributes="0"/> </Group> </Group> <EmptySpace max="-2" attributes="0"/> Modified: OpaloERP/src/mensaje_objetos/proveedor/Proveedor.java =================================================================== --- OpaloERP/src/mensaje_objetos/proveedor/Proveedor.java 2007-09-16 18:38:42 UTC (rev 37) +++ OpaloERP/src/mensaje_objetos/proveedor/Proveedor.java 2007-09-16 23:50:57 UTC (rev 38) @@ -12,9 +12,9 @@ import java.io.Serializable; import java.math.BigInteger; import java.util.List; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; @@ -72,12 +72,12 @@ @Column(name = "tipo_de_pago") private String tipoDePago; - @OneToMany() + @OneToMany(cascade=CascadeType.ALL) @JoinTable(name="proveedor_contacto",joinColumns={@JoinColumn(name="codigo_proveedor")}, inverseJoinColumns={@JoinColumn(name="codigo_contacto")}) private List<Contacto> contactos; - @OneToMany() + @OneToMany(cascade=CascadeType.ALL) @JoinTable(name="proveedor_direccion",joinColumns={@JoinColumn(name="codigo_proveedor")}, inverseJoinColumns={@JoinColumn(name="codigo_direccion")}) private List<Direccion> direcciones; Modified: OpaloERP/src/modelo_objetos/proveedor/ModeloProveedor.java =================================================================== --- OpaloERP/src/modelo_objetos/proveedor/ModeloProveedor.java 2007-09-16 18:38:42 UTC (rev 37) +++ OpaloERP/src/modelo_objetos/proveedor/ModeloProveedor.java 2007-09-16 23:50:57 UTC (rev 38) @@ -11,7 +11,6 @@ import java.util.ArrayList; import java.util.List; -import mensaje_objetos.comunes.Secuencia; import mensaje_objetos.proveedor.Proveedor; import modelo_objetos.acceso_datos.Conexion; import org.hibernate.Query; @@ -78,7 +77,7 @@ return subjectMensaje; } - /**Metodo para insertar un Grupo*/ + /**Metodo para insertar un Proveedor*/ public void addProveedor(Proveedor proveedor){ if(!existProveedor(proveedor)){ Session sl=conn.getSession(); @@ -92,7 +91,7 @@ } } - /**Metodo para borrar un grupo*/ + /**Metodo para borrar un proveedor*/ public void removeProveedor(Proveedor proveedor) { Session sl=conn.getSession(); Transaction tx=sl.beginTransaction(); @@ -102,7 +101,7 @@ getSubjectRemove().notify(ModeloProveedor.class,proveedor,"removeProveedor"); } - /**Metodo para saber si un grupo esta registrado*/ + /**Metodo para saber si un proveedor esta registrado*/ private boolean existProveedor(Proveedor proveedor) { Session ss=conn.getSession(); String hql="From Proveedor P WHERE P.codigo=?"; @@ -118,11 +117,10 @@ } - /**Metodo para actualizar un grupo*/ + /**Metodo para actualizar un proveedor*/ public void updateProveedor(Proveedor proveedor) { Session ss=conn.getSession(); Transaction tx=ss.beginTransaction(); - //sn.update(grupo); ss.merge(proveedor); tx.commit(); ss.close(); @@ -141,7 +139,7 @@ getSubjectUpdate().notify(ModeloProveedor.class,proveedor,"saveOrUpdateProveedor"); } - /**Metodo para consultar todos los clientes*/ + /**Metodo para consultar todos los proveedores*/ public List<Proveedor> getAllProveedores() { List<Proveedor> proveedors=new ArrayList(); String hql="FROM Proveedor P"; @@ -165,7 +163,7 @@ - /**Metodo para consultar cliente por codigo*/ + /**Metodo para consultar proveedor por codigo*/ public List<Proveedor> getProveedorPorCodigo(List<Proveedor> lista,String patronCodigo) { List<Proveedor> proveedors=new ArrayList(); for(Proveedor k:lista) { @@ -179,6 +177,8 @@ } return proveedors; } + + /**Metodo para consultar proveedor por nombre*/ public List<Proveedor> getProveedorPorNombre(List<Proveedor> lista,String patronNombre) { List<Proveedor> proveedors=new ArrayList(); @@ -196,6 +196,7 @@ return proveedors; } + /**Metodo para consultar proveedor por Rnc*/ public List<Proveedor> getProveedorPorRnc(List<Proveedor> lista,String patronNombre) { List<Proveedor> proveedors=new ArrayList(); @@ -213,6 +214,7 @@ return proveedors; } + /**Metodo para consultar proveedor por Cedula*/ public List<Proveedor> getProveedorPorCedula(List<Proveedor> lista,String patronNombre) { List<Proveedor> proveedors=new ArrayList(); @@ -230,7 +232,8 @@ return proveedors; } - public List<Proveedor> getProveedorPorLimiteDeCredito(List<Proveedor> lista,String patronNombre) { + /**Metodo para consultar proveedor por Limite de credito*/ + public List<Proveedor> getProveedorPorLimiteDeCredito(List<Proveedor> lista,String patronNombre) { List<Proveedor> proveedors=new ArrayList(); for(Proveedor k:lista) { @@ -247,6 +250,7 @@ return proveedors; } + /**Metodo para consultar proveedor por Limite de dias*/ public List<Proveedor> getProveedorPorLimiteDeDias(List<Proveedor> lista,String patronNombre) { List<Proveedor> proveedors=new ArrayList(); @@ -264,6 +268,7 @@ return proveedors; } + /**Metodo para consultar proveedor por porcentaje de mora*/ public List<Proveedor> getProveedorPorPorcentajeDeMora(List<Proveedor> lista,String patronNombre) { List<Proveedor> proveedors=new ArrayList(); @@ -281,28 +286,5 @@ return proveedors; } - public Secuencia getSecuencia() { - Session ss=conn.getSession(); - Transaction tx=ss.beginTransaction(); - String hql="From Secuencia S where S.tabla=?"; - Query que=ss.createQuery(hql); - que.setString(0,"Proveedor"); - List<Secuencia> secs=que.list(); - Secuencia sec0=secs.get(0); - ss.close(); - return sec0; - } - public void updateSecuencia(int valor) { - Session ss=conn.getSession(); - Transaction tx=ss.beginTransaction(); - Secuencia sec0=new Secuencia(); - sec0.setSecuencia(valor); - sec0.setTabla("Proveedor"); - ss.update(sec0); - tx.commit(); - ss.close(); - } - - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |