package vista;
import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import base.Cliente;
import base.ClienteDTO;
import base.Localidad;
import java.awt.Rectangle;
import java.awt.Dimension;
import java.awt.GridBagLayout;
public class VentanaModificar extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jPanel = null;
private JLabel etiquetaNombre = null;
private Cliente cliente;
public String nombre;
private JTextField textoNombres = null;
private JButton botonAceptar = null;
private JLabel etiquetaTelefono,etiquetaCalle, etiquetaNumero, etiquetaPisoDpto, etiquetaDatosObligatorios, etiquetaTipoIdFiscal, etiquetaIdFiscal, etiquetaNombres, etiquetaApellidos;
private JTextField textoTelefono, textoCalle, textoNumero, textoPiso, textoDpto, textoIdFiscal, textoApellidos;
private JComboBox selectorIdFiscal = null;
private JPanel jPanel1 = null;
private JComboBox jComboBox = null;
/**
* This is the default constructor
*/
public VentanaModificar() {
super();
/*for(int i=0;i<ClienteDTO.listaClientes().size();i++ ){
cliente =(Cliente)ClienteDTO.listaClientes().get(i);
if (cliente.getIdCliente().equals(c.getIdCliente()))
break;
}*/
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(new Dimension(600, 600));
this.setContentPane(getJPanel1());
this.add(getJPanel(), null);
}
private JPanel getJPanel() {
if (jPanel == null) {
etiquetaDatosObligatorios = new JLabel();
etiquetaDatosObligatorios.setBounds(new Rectangle(35, 380, 127, 20));
etiquetaDatosObligatorios.setText("(*) Datos obligatorios");
etiquetaPisoDpto = new JLabel();
etiquetaPisoDpto.setBounds(new Rectangle(35, 330, 90, 20));
etiquetaPisoDpto.setText("Piso/Dpto");
etiquetaNumero = new JLabel();
etiquetaNumero.setBounds(new Rectangle(35, 290, 90, 20));
etiquetaNumero.setText("* Numero:");
etiquetaCalle = new JLabel();
etiquetaCalle.setBounds(new Rectangle(35, 250, 90, 20));
etiquetaCalle.setText("* Calle:");
etiquetaTelefono = new JLabel();
etiquetaTelefono.setBounds(new Rectangle(35, 210, 90, 20));
etiquetaTelefono.setText("* Telefono:");
etiquetaIdFiscal = new JLabel();
etiquetaIdFiscal.setBounds(new Rectangle(35, 170, 90, 20));
etiquetaIdFiscal.setText("* Id Fiscal:");
etiquetaTipoIdFiscal = new JLabel();
etiquetaTipoIdFiscal.setBounds(new Rectangle(35, 130, 90, 20));
etiquetaTipoIdFiscal.setText("* Tipo de id Fiscal:");
etiquetaApellidos = new JLabel();
etiquetaApellidos.setBounds(new Rectangle(35, 90, 90, 20));
etiquetaApellidos.setText("* Apellidos:");
etiquetaNombres = new JLabel();
etiquetaNombres.setBounds(new Rectangle(35, 50, 90, 20));
etiquetaNombres.setText("* Nombres:");
jPanel = new JPanel();
jPanel.setLayout(null);
jPanel.setBounds(new Rectangle(37, 54, 484, 457));
jPanel.add(getTextoNombres(), null);
jPanel.add(getTextoApellidos(), null);
jPanel.setToolTipText("Formulario de Alta de cliente");
jPanel.setOpaque(false);// hacer transparente
jPanel.add(etiquetaNombres, null);
jPanel.add(etiquetaApellidos, null);
//jPanel.add(getBotonAceptar(), null);
jPanel.add(etiquetaTipoIdFiscal, null);
jPanel.add(etiquetaIdFiscal, null);
jPanel.add(getTextoIdFiscal(), null);
jPanel.add(etiquetaTelefono, null);
jPanel.add(etiquetaCalle, null);
jPanel.add(etiquetaNumero, null);
jPanel.add(etiquetaPisoDpto, null);
jPanel.add(getTextoTelefono(), null);
jPanel.add(getTextoCalle(), null);
jPanel.add(getTextoNumero(), null);
jPanel.add(getTextoPiso(), null);
jPanel.add(getTextoDpto(), null);
jPanel.add(getSelectorIdFiscal(), null);
jPanel.add(etiquetaDatosObligatorios, null);
jPanel.add(getBotonAceptar());
}
return jPanel;
}
private JTextField getTextoNombres() {
if (textoNombres == null) {
textoNombres = new JTextField();
textoNombres.setBounds(new Rectangle(130, 50, 230, 20));
textoNombres.setText(cliente.getNombreApellido());
}
return textoNombres;
}
private JTextField getTextoApellidos() {
if (textoApellidos == null) {
textoApellidos = new JTextField();
textoApellidos.setBounds(new Rectangle(130, 90, 230, 20));
textoApellidos.setForeground(Color.BLUE);
}
return textoApellidos;
}
private JButton getBotonAceptar() {
if (botonAceptar == null) {
botonAceptar = new JButton();
botonAceptar.setBounds(new Rectangle(314, 408, 114, 22));
botonAceptar.setText("Aceptar");
botonAceptar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
cliente.setNombreApellido(textoNombres.getText()+ " " + textoApellidos.getText());
cliente.setTipoIdFiscal("111111111");//// hacer con el selector
cliente.setIdFiscal(textoIdFiscal.getText());
cliente.setTelefono(textoTelefono.getText());
cliente.setCalle(textoNombres.getText());
cliente.setNro(Integer.valueOf(textoNumero.getText()));
Localidad l=new Localidad("9100","Trelew");
cliente.setLocalidad(l);
//ct.InsertaCliente(c);
ClienteDTO.UpdateCliente(cliente);
}
});
}
return botonAceptar;
}
private JTextField getTextoIdFiscal() {
if (textoIdFiscal == null) {
textoIdFiscal = new JTextField();
textoIdFiscal.setBounds(new Rectangle(130, 170, 230, 20));
textoIdFiscal.setText(cliente.getIdFiscal());
}
return textoIdFiscal;
}
private JTextField getTextoTelefono() {
if (textoTelefono == null) {
textoTelefono = new JTextField();
textoTelefono.setBounds(new Rectangle(130, 210, 100, 20));
textoTelefono.setText(cliente.getTelefono());
}
return textoTelefono;
}
private JTextField getTextoCalle() {
if (textoCalle == null) {
textoCalle = new JTextField();
textoCalle.setBounds(new Rectangle(130, 250, 100, 20));
textoCalle.setText(cliente.getCalle());
}
return textoCalle;
}
private JTextField getTextoNumero() {
if (textoNumero == null) {
textoNumero = new JTextField();
textoNumero.setBounds(new Rectangle(130, 290, 100, 20));
String numCadena= String.valueOf(cliente.getNro());
textoNumero.setText(numCadena);
}
return textoNumero;
}
private JTextField getTextoPiso() {
if (textoPiso == null) {
textoPiso = new JTextField();
textoPiso.setBounds(new Rectangle(130, 330, 100, 20));
String numCadena= String.valueOf(cliente.getPiso());
textoPiso.setText(numCadena);
}
return textoPiso;
}
private JTextField getTextoDpto() {
if (textoDpto == null) {
textoDpto = new JTextField();
textoDpto.setBounds(new Rectangle(240, 330, 100, 20));
String numCadena= String.valueOf(cliente.getDto());
textoDpto.setText(numCadena);
}
return textoDpto;
}
private JComboBox getSelectorIdFiscal() {
if (selectorIdFiscal == null) {
selectorIdFiscal = new JComboBox();
selectorIdFiscal.setBounds(new Rectangle(130, 130, 100, 20));
}
return selectorIdFiscal;
}
/**
* This method initializes jPanel1
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel1() {
if (jPanel1 == null) {
jPanel1 = new JPanel();
jPanel1.setLayout(null);
jPanel1.add(getJComboBox(), null);
}
return jPanel1;
}
/**
* This method initializes jComboBox
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBox() {
if (jComboBox == null) {
jComboBox = new JComboBox();
jComboBox.setBounds(new Rectangle(222, 219, 159, 27));
jComboBox.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent e) {
System.out.println("itemStateChanged()"); // TODO Auto-generated Event stub itemStateChanged()
}
});
}
return jComboBox;
}
} // @jve:decl-index=0:visual-constraint="10,10"