Panel de Estudiante con TipologiaSexo
This commit is contained in:
@@ -21,7 +21,8 @@ public class ControladorEstudiante {
|
|||||||
rs.getString("dni"),
|
rs.getString("dni"),
|
||||||
rs.getString("direccion"),
|
rs.getString("direccion"),
|
||||||
rs.getString("email"),
|
rs.getString("email"),
|
||||||
rs.getString("telefono")
|
rs.getString("telefono"),
|
||||||
|
rs.getInt("idTipologiaSexo")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +49,8 @@ public class ControladorEstudiante {
|
|||||||
rs.getString("dni"),
|
rs.getString("dni"),
|
||||||
rs.getString("direccion"),
|
rs.getString("direccion"),
|
||||||
rs.getString("email"),
|
rs.getString("email"),
|
||||||
rs.getString("telefono")
|
rs.getString("telefono"),
|
||||||
|
rs.getInt("idTipologiaSexo")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +77,8 @@ public class ControladorEstudiante {
|
|||||||
rs.getString("dni"),
|
rs.getString("dni"),
|
||||||
rs.getString("direccion"),
|
rs.getString("direccion"),
|
||||||
rs.getString("email"),
|
rs.getString("email"),
|
||||||
rs.getString("telefono")
|
rs.getString("telefono"),
|
||||||
|
rs.getInt("idTipologiaSexo")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +106,8 @@ public class ControladorEstudiante {
|
|||||||
rs.getString("dni"),
|
rs.getString("dni"),
|
||||||
rs.getString("direccion"),
|
rs.getString("direccion"),
|
||||||
rs.getString("email"),
|
rs.getString("email"),
|
||||||
rs.getString("telefono")
|
rs.getString("telefono"),
|
||||||
|
rs.getInt("idTipologiaSexo")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +138,7 @@ public class ControladorEstudiante {
|
|||||||
}
|
}
|
||||||
Connection conn = GestorConexiones.getConexion();
|
Connection conn = GestorConexiones.getConexion();
|
||||||
try {
|
try {
|
||||||
PreparedStatement pst = conn.prepareStatement("UPDATE estudiante SET descripcion = ?, apellido1 = ?, apellido2 = ?, dni = ?, direccion = ?, email = ?, telefono = ? WHERE id = ?");
|
PreparedStatement pst = conn.prepareStatement("UPDATE estudiante SET nombre = ?, apellido1 = ?, apellido2 = ?, dni = ?, direccion = ?, email = ?, telefono = ?, idTipologiaSexo = ? WHERE id = ?");
|
||||||
pst.setString(1, estudiante.getNombre());
|
pst.setString(1, estudiante.getNombre());
|
||||||
pst.setString(2, estudiante.getApellido1());
|
pst.setString(2, estudiante.getApellido1());
|
||||||
pst.setString(3, estudiante.getApellido2());
|
pst.setString(3, estudiante.getApellido2());
|
||||||
@@ -142,7 +146,8 @@ public class ControladorEstudiante {
|
|||||||
pst.setString(5, estudiante.getDireccion());
|
pst.setString(5, estudiante.getDireccion());
|
||||||
pst.setString(6, estudiante.getEmail());
|
pst.setString(6, estudiante.getEmail());
|
||||||
pst.setString(7, estudiante.getTelefono());
|
pst.setString(7, estudiante.getTelefono());
|
||||||
pst.setInt(8, estudiante.getId());
|
pst.setInt(8, estudiante.getIdTipologiaSexo());
|
||||||
|
pst.setInt(9, estudiante.getId());
|
||||||
return pst.executeUpdate();
|
return pst.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -153,7 +158,7 @@ public class ControladorEstudiante {
|
|||||||
public static int nuevoEstudiante(Estudiante estudiante) {
|
public static int nuevoEstudiante(Estudiante estudiante) {
|
||||||
Connection conn = GestorConexiones.getConexion();
|
Connection conn = GestorConexiones.getConexion();
|
||||||
try {
|
try {
|
||||||
PreparedStatement pst = conn.prepareStatement("INSERT INTO estudiante (id,nombre,apellido1,apellido2,dni,direccion,email,telefono) VALUES (?,?,?,?,?,?)");
|
PreparedStatement pst = conn.prepareStatement("INSERT INTO estudiante (id,nombre,apellido1,apellido2,dni,direccion,email,telefono,idTipologiaSexo) VALUES (?,?,?,?,?,?,?)");
|
||||||
pst.setInt(1, estudiante.getId());
|
pst.setInt(1, estudiante.getId());
|
||||||
pst.setString(2, estudiante.getNombre());
|
pst.setString(2, estudiante.getNombre());
|
||||||
pst.setString(3, estudiante.getApellido1());
|
pst.setString(3, estudiante.getApellido1());
|
||||||
@@ -162,6 +167,7 @@ public class ControladorEstudiante {
|
|||||||
pst.setString(6, estudiante.getDireccion());
|
pst.setString(6, estudiante.getDireccion());
|
||||||
pst.setString(7, estudiante.getEmail());
|
pst.setString(7, estudiante.getEmail());
|
||||||
pst.setString(8, estudiante.getTelefono());
|
pst.setString(8, estudiante.getTelefono());
|
||||||
|
pst.setInt(9, estudiante.getIdTipologiaSexo());
|
||||||
return pst.executeUpdate();
|
return pst.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package net.h4ckx0r.controlador;
|
||||||
|
|
||||||
|
import net.h4ckx0r.modelo.TipologiaSexo;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ControladorTipologiaSexo {
|
||||||
|
public static List<TipologiaSexo> getAllSexos() {
|
||||||
|
Connection conn = GestorConexiones.getConexion();
|
||||||
|
List<TipologiaSexo> sexos = new ArrayList<>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Statement st = conn.createStatement();
|
||||||
|
ResultSet rs = st.executeQuery("SELECT * FROM tipologiaSexo");
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
sexos.add(new TipologiaSexo(rs.getInt("id"), rs.getString("descripcion")));
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sexos;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ package net.h4ckx0r.modelo;
|
|||||||
|
|
||||||
public class Estudiante extends Persona {
|
public class Estudiante extends Persona {
|
||||||
|
|
||||||
public Estudiante(int id, String nombre, String apellido1, String apellido2, String dni, String direccion, String email, String telefono) {
|
public Estudiante(int id, String nombre, String apellido1, String apellido2, String dni, String direccion, String email, String telefono, int idTipologiaSexo) {
|
||||||
super(id, nombre, apellido1, apellido2, dni, direccion, email, telefono);
|
super(id, nombre, apellido1, apellido2, dni, direccion, email, telefono, idTipologiaSexo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,9 @@ public class Persona {
|
|||||||
private String direccion;
|
private String direccion;
|
||||||
private String email;
|
private String email;
|
||||||
private String telefono;
|
private String telefono;
|
||||||
|
private int idTipologiaSexo;
|
||||||
|
|
||||||
public Persona(int id, String nombre, String apellido1, String apellido2, String dni, String direccion, String email, String telefono) {
|
public Persona(int id, String nombre, String apellido1, String apellido2, String dni, String direccion, String email, String telefono, int idTipologiaSexo) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.nombre = nombre;
|
this.nombre = nombre;
|
||||||
this.apellido1 = apellido1;
|
this.apellido1 = apellido1;
|
||||||
@@ -19,6 +20,7 @@ public class Persona {
|
|||||||
this.direccion = direccion;
|
this.direccion = direccion;
|
||||||
this.email = email;
|
this.email = email;
|
||||||
this.telefono = telefono;
|
this.telefono = telefono;
|
||||||
|
this.idTipologiaSexo = idTipologiaSexo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
@@ -85,6 +87,14 @@ public class Persona {
|
|||||||
this.telefono = telefono;
|
this.telefono = telefono;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getIdTipologiaSexo() {
|
||||||
|
return idTipologiaSexo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdTipologiaSexo(int idTipologiaSexo) {
|
||||||
|
this.idTipologiaSexo = idTipologiaSexo;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Persona{" +
|
return "Persona{" +
|
||||||
@@ -96,6 +106,7 @@ public class Persona {
|
|||||||
", direccion='" + direccion + '\'' +
|
", direccion='" + direccion + '\'' +
|
||||||
", email='" + email + '\'' +
|
", email='" + email + '\'' +
|
||||||
", telefono='" + telefono + '\'' +
|
", telefono='" + telefono + '\'' +
|
||||||
|
", idTipologiaSexo=" + idTipologiaSexo +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package net.h4ckx0r.modelo;
|
package net.h4ckx0r.modelo;
|
||||||
|
|
||||||
public class Profesor extends Persona{
|
public class Profesor extends Persona{
|
||||||
public Profesor(int id, String nombre, String apellido1, String apellido2, String dni, String direccion, String email, String telefono) {
|
public Profesor(int id, String nombre, String apellido1, String apellido2, String dni, String direccion, String email, String telefono, int idTipologiaSexo) {
|
||||||
super(id, nombre, apellido1, apellido2, dni, direccion, email, telefono);
|
super(id, nombre, apellido1, apellido2, dni, direccion, email, telefono, idTipologiaSexo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
32
src/main/java/net/h4ckx0r/modelo/TipologiaSexo.java
Normal file
32
src/main/java/net/h4ckx0r/modelo/TipologiaSexo.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package net.h4ckx0r.modelo;
|
||||||
|
|
||||||
|
public class TipologiaSexo {
|
||||||
|
private int id;
|
||||||
|
private String descripcion;
|
||||||
|
|
||||||
|
public TipologiaSexo(int id, String descripcion) {
|
||||||
|
this.id = id;
|
||||||
|
this.descripcion = descripcion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescripcion() {
|
||||||
|
return descripcion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescripcion(String descripcion) {
|
||||||
|
this.descripcion = descripcion;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return descripcion;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -259,7 +259,7 @@ public class MainView extends JFrame {
|
|||||||
} else if (tabbedPane.getSelectedComponent() == panelMaterias) {
|
} else if (tabbedPane.getSelectedComponent() == panelMaterias) {
|
||||||
panelMaterias.setMateriaActual(new Materia(-1, "", "", -1));
|
panelMaterias.setMateriaActual(new Materia(-1, "", "", -1));
|
||||||
} else if (tabbedPane.getSelectedComponent() == panelEstudiantes) {
|
} else if (tabbedPane.getSelectedComponent() == panelEstudiantes) {
|
||||||
panelEstudiantes.setEstudianteActual(new Estudiante(-1, "", "", "", "", "", "", ""));
|
panelEstudiantes.setEstudianteActual(new Estudiante(-1, "", "", "", "", "", "", "", -1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package net.h4ckx0r.vista.panels;
|
package net.h4ckx0r.vista.panels;
|
||||||
|
|
||||||
import net.h4ckx0r.modelo.Estudiante;
|
import net.h4ckx0r.controlador.ControladorCurso;
|
||||||
import net.h4ckx0r.modelo.Persona;
|
import net.h4ckx0r.controlador.ControladorTipologiaSexo;
|
||||||
import net.h4ckx0r.modelo.Profesor;
|
import net.h4ckx0r.modelo.*;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class PanelPersona extends JPanel {
|
public class PanelPersona extends JPanel {
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ public class PanelPersona extends JPanel {
|
|||||||
private JTextField tfDireccion;
|
private JTextField tfDireccion;
|
||||||
private JTextField tfEmail;
|
private JTextField tfEmail;
|
||||||
private JTextField tfTelefono;
|
private JTextField tfTelefono;
|
||||||
|
private JComboBox<TipologiaSexo> comboBoxSexo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the panel.
|
* Create the panel.
|
||||||
@@ -29,9 +31,9 @@ public class PanelPersona extends JPanel {
|
|||||||
public PanelPersona() {
|
public PanelPersona() {
|
||||||
GridBagLayout gridBagLayout = new GridBagLayout();
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
||||||
gridBagLayout.columnWidths = new int[]{0, 0, 0};
|
gridBagLayout.columnWidths = new int[]{0, 0, 0};
|
||||||
gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0};
|
gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
gridBagLayout.columnWeights = new double[]{0.2, 1.0, Double.MIN_VALUE};
|
gridBagLayout.columnWeights = new double[]{0.2, 1.0, Double.MIN_VALUE};
|
||||||
gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
|
gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
|
||||||
setLayout(gridBagLayout);
|
setLayout(gridBagLayout);
|
||||||
|
|
||||||
JLabel lblNewLabel = new JLabel("Nombre:");
|
JLabel lblNewLabel = new JLabel("Nombre:");
|
||||||
@@ -85,12 +87,28 @@ public class PanelPersona extends JPanel {
|
|||||||
add(tfApellido2, gbc_textField_2);
|
add(tfApellido2, gbc_textField_2);
|
||||||
tfApellido2.setColumns(10);
|
tfApellido2.setColumns(10);
|
||||||
|
|
||||||
|
JLabel lblNewLabel_7 = new JLabel("Sexo:");
|
||||||
|
GridBagConstraints gbc_lblNewLabel_7 = new GridBagConstraints();
|
||||||
|
gbc_lblNewLabel_7.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblNewLabel_7.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblNewLabel_7.gridx = 0;
|
||||||
|
gbc_lblNewLabel_7.gridy = 3;
|
||||||
|
add(lblNewLabel_7, gbc_lblNewLabel_7);
|
||||||
|
|
||||||
|
comboBoxSexo = new JComboBox<>();
|
||||||
|
GridBagConstraints gbc_comboBoxSexo = new GridBagConstraints();
|
||||||
|
gbc_comboBoxSexo.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_comboBoxSexo.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_comboBoxSexo.gridx = 1;
|
||||||
|
gbc_comboBoxSexo.gridy = 3;
|
||||||
|
add(comboBoxSexo, gbc_comboBoxSexo);
|
||||||
|
|
||||||
JLabel lblNewLabel_3 = new JLabel("DNI:");
|
JLabel lblNewLabel_3 = new JLabel("DNI:");
|
||||||
GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints();
|
GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints();
|
||||||
gbc_lblNewLabel_3.anchor = GridBagConstraints.EAST;
|
gbc_lblNewLabel_3.anchor = GridBagConstraints.EAST;
|
||||||
gbc_lblNewLabel_3.insets = new Insets(0, 0, 5, 5);
|
gbc_lblNewLabel_3.insets = new Insets(0, 0, 5, 5);
|
||||||
gbc_lblNewLabel_3.gridx = 0;
|
gbc_lblNewLabel_3.gridx = 0;
|
||||||
gbc_lblNewLabel_3.gridy = 3;
|
gbc_lblNewLabel_3.gridy = 4;
|
||||||
add(lblNewLabel_3, gbc_lblNewLabel_3);
|
add(lblNewLabel_3, gbc_lblNewLabel_3);
|
||||||
|
|
||||||
tfDNI = new JTextField();
|
tfDNI = new JTextField();
|
||||||
@@ -98,7 +116,7 @@ public class PanelPersona extends JPanel {
|
|||||||
gbc_textField_3.insets = new Insets(0, 0, 5, 0);
|
gbc_textField_3.insets = new Insets(0, 0, 5, 0);
|
||||||
gbc_textField_3.fill = GridBagConstraints.HORIZONTAL;
|
gbc_textField_3.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc_textField_3.gridx = 1;
|
gbc_textField_3.gridx = 1;
|
||||||
gbc_textField_3.gridy = 3;
|
gbc_textField_3.gridy = 4;
|
||||||
add(tfDNI, gbc_textField_3);
|
add(tfDNI, gbc_textField_3);
|
||||||
tfDNI.setColumns(10);
|
tfDNI.setColumns(10);
|
||||||
|
|
||||||
@@ -107,7 +125,7 @@ public class PanelPersona extends JPanel {
|
|||||||
gbc_lblNewLabel_4.anchor = GridBagConstraints.EAST;
|
gbc_lblNewLabel_4.anchor = GridBagConstraints.EAST;
|
||||||
gbc_lblNewLabel_4.insets = new Insets(0, 0, 5, 5);
|
gbc_lblNewLabel_4.insets = new Insets(0, 0, 5, 5);
|
||||||
gbc_lblNewLabel_4.gridx = 0;
|
gbc_lblNewLabel_4.gridx = 0;
|
||||||
gbc_lblNewLabel_4.gridy = 4;
|
gbc_lblNewLabel_4.gridy = 5;
|
||||||
add(lblNewLabel_4, gbc_lblNewLabel_4);
|
add(lblNewLabel_4, gbc_lblNewLabel_4);
|
||||||
|
|
||||||
tfDireccion = new JTextField();
|
tfDireccion = new JTextField();
|
||||||
@@ -115,7 +133,7 @@ public class PanelPersona extends JPanel {
|
|||||||
gbc_textField_4.insets = new Insets(0, 0, 5, 0);
|
gbc_textField_4.insets = new Insets(0, 0, 5, 0);
|
||||||
gbc_textField_4.fill = GridBagConstraints.HORIZONTAL;
|
gbc_textField_4.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc_textField_4.gridx = 1;
|
gbc_textField_4.gridx = 1;
|
||||||
gbc_textField_4.gridy = 4;
|
gbc_textField_4.gridy = 5;
|
||||||
add(tfDireccion, gbc_textField_4);
|
add(tfDireccion, gbc_textField_4);
|
||||||
tfDireccion.setColumns(10);
|
tfDireccion.setColumns(10);
|
||||||
|
|
||||||
@@ -124,7 +142,7 @@ public class PanelPersona extends JPanel {
|
|||||||
gbc_lblNewLabel_5.insets = new Insets(0, 0, 5, 5);
|
gbc_lblNewLabel_5.insets = new Insets(0, 0, 5, 5);
|
||||||
gbc_lblNewLabel_5.anchor = GridBagConstraints.EAST;
|
gbc_lblNewLabel_5.anchor = GridBagConstraints.EAST;
|
||||||
gbc_lblNewLabel_5.gridx = 0;
|
gbc_lblNewLabel_5.gridx = 0;
|
||||||
gbc_lblNewLabel_5.gridy = 5;
|
gbc_lblNewLabel_5.gridy = 6;
|
||||||
add(lblNewLabel_5, gbc_lblNewLabel_5);
|
add(lblNewLabel_5, gbc_lblNewLabel_5);
|
||||||
|
|
||||||
tfEmail = new JTextField();
|
tfEmail = new JTextField();
|
||||||
@@ -132,7 +150,7 @@ public class PanelPersona extends JPanel {
|
|||||||
gbc_textField_5.insets = new Insets(0, 0, 5, 0);
|
gbc_textField_5.insets = new Insets(0, 0, 5, 0);
|
||||||
gbc_textField_5.fill = GridBagConstraints.HORIZONTAL;
|
gbc_textField_5.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc_textField_5.gridx = 1;
|
gbc_textField_5.gridx = 1;
|
||||||
gbc_textField_5.gridy = 5;
|
gbc_textField_5.gridy = 6;
|
||||||
add(tfEmail, gbc_textField_5);
|
add(tfEmail, gbc_textField_5);
|
||||||
tfEmail.setColumns(10);
|
tfEmail.setColumns(10);
|
||||||
|
|
||||||
@@ -141,7 +159,7 @@ public class PanelPersona extends JPanel {
|
|||||||
gbc_lblNewLabel_6.insets = new Insets(0, 0, 5, 5);
|
gbc_lblNewLabel_6.insets = new Insets(0, 0, 5, 5);
|
||||||
gbc_lblNewLabel_6.anchor = GridBagConstraints.EAST;
|
gbc_lblNewLabel_6.anchor = GridBagConstraints.EAST;
|
||||||
gbc_lblNewLabel_6.gridx = 0;
|
gbc_lblNewLabel_6.gridx = 0;
|
||||||
gbc_lblNewLabel_6.gridy = 6;
|
gbc_lblNewLabel_6.gridy = 7;
|
||||||
add(lblNewLabel_6, gbc_lblNewLabel_6);
|
add(lblNewLabel_6, gbc_lblNewLabel_6);
|
||||||
|
|
||||||
tfTelefono = new JTextField();
|
tfTelefono = new JTextField();
|
||||||
@@ -149,7 +167,7 @@ public class PanelPersona extends JPanel {
|
|||||||
gbc_textField_6.insets = new Insets(0, 0, 5, 0);
|
gbc_textField_6.insets = new Insets(0, 0, 5, 0);
|
||||||
gbc_textField_6.fill = GridBagConstraints.HORIZONTAL;
|
gbc_textField_6.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc_textField_6.gridx = 1;
|
gbc_textField_6.gridx = 1;
|
||||||
gbc_textField_6.gridy = 6;
|
gbc_textField_6.gridy = 7;
|
||||||
add(tfTelefono, gbc_textField_6);
|
add(tfTelefono, gbc_textField_6);
|
||||||
tfTelefono.setColumns(10);
|
tfTelefono.setColumns(10);
|
||||||
|
|
||||||
@@ -164,12 +182,14 @@ public class PanelPersona extends JPanel {
|
|||||||
tfEmail.setText(persona.getEmail());
|
tfEmail.setText(persona.getEmail());
|
||||||
tfTelefono.setText(persona.getTelefono());
|
tfTelefono.setText(persona.getTelefono());
|
||||||
personaActual = persona;
|
personaActual = persona;
|
||||||
|
actualizarSexo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Persona getPersona() {
|
private Persona getPersona() {
|
||||||
personaActual.setNombre(tfNombre.getText());
|
personaActual.setNombre(tfNombre.getText());
|
||||||
personaActual.setApellido1(tfApellido1.getText());
|
personaActual.setApellido1(tfApellido1.getText());
|
||||||
personaActual.setApellido2(tfApellido2.getText());
|
personaActual.setApellido2(tfApellido2.getText());
|
||||||
|
personaActual.setIdTipologiaSexo(((TipologiaSexo) comboBoxSexo.getSelectedItem()).getId());
|
||||||
personaActual.setDni(tfDNI.getText());
|
personaActual.setDni(tfDNI.getText());
|
||||||
personaActual.setDireccion(tfDireccion.getText());
|
personaActual.setDireccion(tfDireccion.getText());
|
||||||
personaActual.setEmail(tfEmail.getText());
|
personaActual.setEmail(tfEmail.getText());
|
||||||
@@ -193,4 +213,18 @@ public class PanelPersona extends JPanel {
|
|||||||
return (Profesor) getPersona();
|
return (Profesor) getPersona();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void actualizarSexo() {
|
||||||
|
List<TipologiaSexo> sexos = ControladorTipologiaSexo.getAllSexos();
|
||||||
|
comboBoxSexo.removeAllItems();
|
||||||
|
for (TipologiaSexo sexo : sexos) {
|
||||||
|
comboBoxSexo.addItem(sexo);
|
||||||
|
if (personaActual.getIdTipologiaSexo() == sexo.getId()) {
|
||||||
|
comboBoxSexo.setSelectedItem(sexo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (personaActual.getIdTipologiaSexo() == -1) {
|
||||||
|
comboBoxSexo.setSelectedIndex(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user