public void recibirTelefono(String tipoTelefono, String nroTelefono, String observacion) { if (modelo.existeTelefono(nroTelefono)) { JOptionPane.showMessageDialog( vista, "Telefono en uso.", "Atención", JOptionPane.ERROR_MESSAGE); } else { Object[] fila = {nroTelefono, tipoTelefono, observacion}; modelo.dtmTelefono.addRow(fila); this.vista.jtTelefono.updateUI(); } }
private void inicializarVista() { this.vista.jtContacto.setModel(modelo.dtmContacto); this.vista.jtSucursal.setModel(modelo.dtmSucursal); this.vista.jtSucursal.setModel(modelo.dtmSucursal); this.vista.jtTelefono.setModel(modelo.dtmTelefono); this.vista.jbQuitarSucursal.setEnabled(false); this.vista.jbQuitarTelefono.setEnabled(false); this.vista.jbModTelefono.setEnabled(false); this.vista.jbModSucursal.setEnabled(false); this.vista.jbModContacto.setEnabled(false); this.vista.jbQuitarContacto.setEnabled(false); Vector tipo_cliente = modelo.obtenerTipoCliente(); for (int i = 0; i < tipo_cliente.size(); i++) { this.vista.jcbTipoCliente.addItem(tipo_cliente.get(i)); } Vector categoria_cliente = modelo.obtenerCategoriaCliente(); for (int i = 0; i < categoria_cliente.size(); i++) { this.vista.jcbCategoriaCliente.addItem(categoria_cliente.get(i)); } }
public void modificarTelefono(String tipoTelefono, String nroTelefono, String observacion) { if (modelo.existeTelefono(nroTelefono)) { JOptionPane.showMessageDialog( vista, "Telefono en uso.", "Atención", JOptionPane.ERROR_MESSAGE); } else { int row = this.vista.jtTelefono.getSelectedRow(); modelo.dtmTelefono.setValueAt(nroTelefono, row, 0); modelo.dtmTelefono.setValueAt(tipoTelefono, row, 1); modelo.dtmTelefono.setValueAt(observacion, row, 2); this.vista.jbQuitarTelefono.setEnabled(false); this.vista.jbModTelefono.setEnabled(false); } }
private void actualizarTablaClientes() { this.padre.vista.jtCliente.setModel(modelo.consultarCliente("", false, true, true)); }
private void validarDatos() { int cantTel = modelo.dtmTelefono.getRowCount(); M_telefono[] telefono = new M_telefono[cantTel]; for (int i = 0; i < cantTel; i++) { telefono[i] = new M_telefono(); telefono[i].setCategoria(modelo.dtmTelefono.getValueAt(i, 1).toString()); telefono[i].setNumero(modelo.dtmTelefono.getValueAt(i, 0).toString()); String obs = modelo.dtmTelefono.getValueAt(i, 2).toString(); if (obs.isEmpty()) { telefono[i].setObservacion(null); } else { telefono[i].setObservacion(obs); } } int cantSuc = modelo.dtmSucursal.getRowCount(); M_sucursal[] sucursal = new M_sucursal[cantSuc]; for (int i = 0; i < cantSuc; i++) { sucursal[i] = new M_sucursal(); sucursal[i].setDireccion(modelo.dtmSucursal.getValueAt(i, 0).toString()); if (modelo.dtmSucursal.getValueAt(i, 1) != null) { String tel = modelo.dtmSucursal.getValueAt(i, 1).toString(); if (tel.isEmpty()) { sucursal[i].setTelefono(null); } else { sucursal[i].setTelefono(tel); } } } /* * VALIDAR RAZON SOCIAL 60 caracteres maximo */ String entidad; if (this.vista.jtfRazonSocial.getText().isEmpty()) { this.vista.jtfRazonSocial.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog( this.vista, "El campo Razón social esta vacio", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); this.vista.jtpCenter.setSelectedComponent(vista.jpDatosGenerales); return; } else if (this.vista.jtfRazonSocial.getText().length() > 60) { this.vista.jtfRazonSocial.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog( this.vista, "El máximo permitido de caracteres es 60 para Razón social.", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); this.vista.jtpCenter.setSelectedComponent(vista.jpDatosGenerales); return; } else { entidad = this.vista.jtfRazonSocial.getText().trim(); } /* * VALIDAR NOMBRE FANTASIA */ String nombreFantasia = this.vista.jtfNombreFantasia.getText().trim(); if (nombreFantasia.length() > 120) { this.vista.jtfRazonSocial.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog( this.vista, "El máximo permitido de caracteres es 60 para Razón social.", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); this.vista.jtpCenter.setSelectedComponent(vista.jpDatosGenerales); return; } else if (nombreFantasia.isEmpty()) { nombreFantasia = null; } /* * VALIDAR R.U.C. */ String ruc = this.vista.jtfRUC.getText().trim(); if (ruc.length() > 30) { this.vista.jtfRUC.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog( this.vista, "El máximo permitido de caracteres es 30 para R.U.C.", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); this.vista.jtpCenter.setSelectedComponent(vista.jpDatosGenerales); return; } else if (ruc.isEmpty()) { ruc = null; } /* * VALIDAR R.U.C. ID */ String rucId = this.vista.jtfRUC_ID.getText().trim(); if (rucId.length() > 30) { this.vista.jtfRUC_ID.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog( this.vista, "El máximo permitido de caracteres es 3 para Division R.U.C.", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); this.vista.jtpCenter.setSelectedComponent(vista.jpDatosGenerales); return; } else if (rucId.isEmpty()) { rucId = null; } /* if (this.vista.jtfRUC_ID.getText().isEmpty()) { this.vista.jtfRUC_ID.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog(this.vista, "El campo R.U.C. División esta vacio", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); this.vista.jtpCenter.setSelectedComponent(vista.jpDatosGenerales); return; } else { rucId = this.vista.jtfRUC_ID.getText(); }*/ String direccion = this.vista.jtfDireccion.getText().trim(); if (direccion.length() > 120) { this.vista.jtfDireccion.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog( this.vista, "El máximo permitido de caracteres es 120 para dirección.", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); this.vista.jtpCenter.setSelectedComponent(vista.jpDatosGenerales); return; } else if (direccion.isEmpty()) { direccion = null; } String email = this.vista.jtfemail.getText().trim(); if (email.length() > 120) { this.vista.jtfemail.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog( this.vista, "El máximo permitido de caracteres es 30 para e-mail.", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); this.vista.jtpCenter.setSelectedComponent(vista.jpDatosGenerales); return; } else if (email.isEmpty()) { email = null; } String pagWeb = this.vista.jtfPaginaWeb.getText().trim(); if (pagWeb.length() > 120) { this.vista.jtfPaginaWeb.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog( this.vista, "El máximo permitido de caracteres es 30 para Web.", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); this.vista.jtpCenter.setSelectedComponent(vista.jpDatosGenerales); return; } else if (pagWeb.isEmpty()) { pagWeb = null; } String obs = this.vista.jtaNota.getText().trim(); if (obs.length() > 120) { this.vista.jtaNota.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog( this.vista, "El máximo permitido de caracteres es 120 para Observacion.", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); this.vista.jtpCenter.setSelectedComponent(vista.jpDatosGenerales); return; } else if (obs.isEmpty()) { obs = null; } String categoria = this.vista.jcbCategoriaCliente.getSelectedItem().toString(); String tipo = this.vista.jcbTipoCliente.getSelectedItem().toString(); M_cliente cliente = new M_cliente(); cliente.setEntidad(entidad); cliente.setNombre(nombreFantasia); cliente.setRuc(ruc); cliente.setRucId(rucId); cliente.setDireccion(direccion); cliente.setEmail(email); cliente.setTipo(tipo); cliente.setCategoria(categoria); cliente.setPaginaWeb(pagWeb); cliente.setObservacion(obs); boolean b = modelo.insertarCliente(cliente, telefono, sucursal); if (b) { actualizarTablaClientes(); cerrar(); } }