Examen 2025/05/09 y librerias generales
This commit is contained in:
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@@ -1,3 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="MavenProjectsManager">
|
<component name="MavenProjectsManager">
|
||||||
@@ -7,7 +8,7 @@
|
|||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="homebrew-22" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="homebrew-23" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
60
.idea/workspace.xml
generated
60
.idea/workspace.xml
generated
@@ -5,19 +5,33 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="e2c4f742-461e-4c7a-a6e0-b5f4b8e8f229" name="Changes" comment="Examen 2025/03/21">
|
<list default="true" id="e2c4f742-461e-4c7a-a6e0-b5f4b8e8f229" name="Changes" comment="Examen 2025/03/21">
|
||||||
<change afterPath="$PROJECT_DIR$/ExamenesProgramacion.eml" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/librerias/EclipseLink2.5.2/jlib/eclipselink.jar" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/ExamenesProgramacion.userlibraries" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/librerias/EclipseLink2.5.2/jlib/jpa/javax.persistence_2.1.0.v201304241213.jar" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/librerias/Driver_MySQL_Connector_J/mysql-connector-java-8.0.19.jar" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/librerias/EclipseLink2.5.2/jlib/jpa/org.eclipse.persistence.jpa.modelgen_2.5.2.v20140319-9ad6abd.jar" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250321/controlador/ControladorInquilino.java" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/librerias/EclipseLink2.5.2/jlib/jpa/org.eclipse.persistence.jpars_2.5.2.v20140319-9ad6abd.jar" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250321/controlador/ControladorLocalidad.java" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/librerias/EclipseLink2.5.2/jlib/moxy/com.sun.tools.xjc_2.2.0.jar" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250321/controlador/ControladorMorosidad.java" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/librerias/EclipseLink2.5.2/jlib/moxy/com.sun.xml.bind_2.2.0.v201004141950.jar" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250321/controlador/ControladorVivienda.java" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/librerias/EclipseLink2.5.2/jlib/moxy/javax.activation_1.1.0.v201108011116.jar" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250321/controlador/GestorConexiones.java" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/librerias/EclipseLink2.5.2/jlib/moxy/javax.mail_1.4.0.v201005080615.jar" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250321/modelo/Inquilino.java" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/librerias/EclipseLink2.5.2/jlib/moxy/javax.xml.bind_2.2.0.v201105210648.jar" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250321/modelo/Localidad.java" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/librerias/EclipseLink2.5.2/jlib/moxy/javax.xml.stream_1.0.1.v201004272200.jar" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250321/modelo/Morosidad.java" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/librerias/JDBC_Oracle_Connection_Pool/ucp.jar" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250321/modelo/Vivienda.java" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/librerias/Jackson/jackson-annotations-2.9.0.jar" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250321/vista/GestionAlquiler.java" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/librerias/Jackson/jackson-core-2.9.5.jar" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/librerias/Jackson/jackson-databind-2.9.5.jar" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/librerias/mongoDB-Java-driver/mongo-java-driver-3.12.12.jar" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250509/controlador/ControladorConcierto.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250509/controlador/ControladorGrupo.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250509/controlador/ControladorSala.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250509/controlador/GestorConexiones.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250509/modelo/Concierto.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250509/modelo/Grupo.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250509/modelo/Sala.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250509/vista/EstadisticasConciertos.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250509/vista/FiltradoConciertos.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250509/vista/GestionConciertos.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/main/java/examenes/examen20250509/vista/MainView.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
@@ -40,7 +54,7 @@
|
|||||||
"associatedIndex": 1
|
"associatedIndex": 1
|
||||||
}</component>
|
}</component>
|
||||||
<component name="ProjectId" id="2nvRIu3ZfVBKxiIKkbDGfwPAbgr" />
|
<component name="ProjectId" id="2nvRIu3ZfVBKxiIKkbDGfwPAbgr" />
|
||||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
|
<component name="ProjectLevelVcsManager">
|
||||||
<ConfirmationsSetting value="2" id="Add" />
|
<ConfirmationsSetting value="2" id="Add" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectViewState">
|
<component name="ProjectViewState">
|
||||||
@@ -56,6 +70,7 @@
|
|||||||
"Application.Ejercicio_e.executor": "Run",
|
"Application.Ejercicio_e.executor": "Run",
|
||||||
"Application.GestionAlquiler.executor": "Run",
|
"Application.GestionAlquiler.executor": "Run",
|
||||||
"Application.Main.executor": "Run",
|
"Application.Main.executor": "Run",
|
||||||
|
"Application.MainView.executor": "Run",
|
||||||
"Application.Zoologico.executor": "Run",
|
"Application.Zoologico.executor": "Run",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
@@ -63,10 +78,10 @@
|
|||||||
"dart.analysis.tool.window.visible": "false",
|
"dart.analysis.tool.window.visible": "false",
|
||||||
"git-widget-placeholder": "main",
|
"git-widget-placeholder": "main",
|
||||||
"kotlin-language-version-configured": "true",
|
"kotlin-language-version-configured": "true",
|
||||||
"last_opened_file_path": "/Users/h4ckx0r/IdeaProjects/ExamenesProgramacion/librerias",
|
"last_opened_file_path": "/Users/h4ckx0r/IdeaProjects/ExamenesProgramacion",
|
||||||
"onboarding.tips.debug.path": "/Users/h4ckx0r/IdeaProjects/ExamenesProgramacion/src/main/java/net/h4ckx0r/Main.java",
|
"onboarding.tips.debug.path": "/Users/h4ckx0r/IdeaProjects/ExamenesProgramacion/src/main/java/net/h4ckx0r/Main.java",
|
||||||
"project.structure.last.edited": "Libraries",
|
"project.structure.last.edited": "Libraries",
|
||||||
"project.structure.proportion": "0.0",
|
"project.structure.proportion": "0.15",
|
||||||
"project.structure.side.proportion": "0.2",
|
"project.structure.side.proportion": "0.2",
|
||||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||||
"show.migrate.to.gradle.popup": "false"
|
"show.migrate.to.gradle.popup": "false"
|
||||||
@@ -74,16 +89,17 @@
|
|||||||
}]]></component>
|
}]]></component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
|
<recent name="$PROJECT_DIR$" />
|
||||||
<recent name="$PROJECT_DIR$/librerias" />
|
<recent name="$PROJECT_DIR$/librerias" />
|
||||||
<recent name="$PROJECT_DIR$/src/main/java/examenes/examen20250221/ejercicio04" />
|
<recent name="$PROJECT_DIR$/src/main/java/examenes/examen20250221/ejercicio04" />
|
||||||
<recent name="$PROJECT_DIR$/src/main/java/examenes/examen20250131/ejercicio04" />
|
<recent name="$PROJECT_DIR$/src/main/java/examenes/examen20250131/ejercicio04" />
|
||||||
</key>
|
</key>
|
||||||
<key name="CopyClassDialog.RECENTS_KEY">
|
<key name="CopyClassDialog.RECENTS_KEY">
|
||||||
|
<recent name="examenes.examen20250509.controlador" />
|
||||||
<recent name="examenes.examen20250321.controlador" />
|
<recent name="examenes.examen20250321.controlador" />
|
||||||
<recent name="examenes.examen20250221.ejercicio04" />
|
<recent name="examenes.examen20250221.ejercicio04" />
|
||||||
<recent name="examenes.examen20241213" />
|
<recent name="examenes.examen20241213" />
|
||||||
<recent name="examenes.examen20241122" />
|
<recent name="examenes.examen20241122" />
|
||||||
<recent name="examenes.examen20241025" />
|
|
||||||
</key>
|
</key>
|
||||||
</component>
|
</component>
|
||||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||||
@@ -207,7 +223,15 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1740142696710</updated>
|
<updated>1740142696710</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="15" />
|
<task id="LOCAL-00015" summary="Examen 2025/03/21">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1742562132199</created>
|
||||||
|
<option name="number" value="00015" />
|
||||||
|
<option name="presentableId" value="LOCAL-00015" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1742562132199</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="16" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="Vcs.Log.Tabs.Properties">
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
|
|||||||
BIN
librerias/EclipseLink2.5.2/jlib/eclipselink.jar
Normal file
BIN
librerias/EclipseLink2.5.2/jlib/eclipselink.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
librerias/EclipseLink2.5.2/jlib/moxy/com.sun.tools.xjc_2.2.0.jar
Normal file
BIN
librerias/EclipseLink2.5.2/jlib/moxy/com.sun.tools.xjc_2.2.0.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
librerias/JDBC_Oracle_Connection_Pool/ucp.jar
Normal file
BIN
librerias/JDBC_Oracle_Connection_Pool/ucp.jar
Normal file
Binary file not shown.
BIN
librerias/Jackson/jackson-annotations-2.9.0.jar
Normal file
BIN
librerias/Jackson/jackson-annotations-2.9.0.jar
Normal file
Binary file not shown.
BIN
librerias/Jackson/jackson-core-2.9.5.jar
Normal file
BIN
librerias/Jackson/jackson-core-2.9.5.jar
Normal file
Binary file not shown.
BIN
librerias/Jackson/jackson-databind-2.9.5.jar
Normal file
BIN
librerias/Jackson/jackson-databind-2.9.5.jar
Normal file
Binary file not shown.
BIN
librerias/mongoDB-Java-driver/mongo-java-driver-3.12.12.jar
Normal file
BIN
librerias/mongoDB-Java-driver/mongo-java-driver-3.12.12.jar
Normal file
Binary file not shown.
@@ -0,0 +1,208 @@
|
|||||||
|
package examenes.examen20250509.controlador;
|
||||||
|
|
||||||
|
import examenes.examen20250509.modelo.Concierto;
|
||||||
|
import examenes.examen20250509.modelo.Grupo;
|
||||||
|
import examenes.examen20250509.modelo.Sala;
|
||||||
|
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ControladorConcierto {
|
||||||
|
public static Concierto getFirstConcierto() {
|
||||||
|
Connection conn = GestorConexiones.getConnection();
|
||||||
|
try {
|
||||||
|
Statement st = conn.createStatement();
|
||||||
|
ResultSet rs = st.executeQuery("select * from concierto limit 1");
|
||||||
|
|
||||||
|
rs.next();
|
||||||
|
return new Concierto(
|
||||||
|
rs.getInt("id"),
|
||||||
|
rs.getDate("fecha"),
|
||||||
|
rs.getFloat("precio"),
|
||||||
|
rs.getBoolean("es_festival"),
|
||||||
|
rs.getInt("sala_id"),
|
||||||
|
rs.getInt("grupo_id")
|
||||||
|
);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Concierto getLastConcierto() {
|
||||||
|
Connection conn = GestorConexiones.getConnection();
|
||||||
|
try {
|
||||||
|
Statement st = conn.createStatement();
|
||||||
|
ResultSet rs = st.executeQuery("select * from concierto order by id desc limit 1");
|
||||||
|
|
||||||
|
rs.next();
|
||||||
|
return new Concierto(
|
||||||
|
rs.getInt("id"),
|
||||||
|
rs.getDate("fecha"),
|
||||||
|
rs.getFloat("precio"),
|
||||||
|
rs.getBoolean("es_festival"),
|
||||||
|
rs.getInt("sala_id"),
|
||||||
|
rs.getInt("grupo_id")
|
||||||
|
);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Concierto getSiguienteConcierto(Concierto c) {
|
||||||
|
Connection conn = GestorConexiones.getConnection();
|
||||||
|
try {
|
||||||
|
PreparedStatement pt = conn.prepareStatement("SELECT * FROM concierto WHERE id > ? LIMIT 1");
|
||||||
|
pt.setInt(1, c.getId());
|
||||||
|
ResultSet rs = pt.executeQuery();
|
||||||
|
|
||||||
|
rs.next();
|
||||||
|
return new Concierto(
|
||||||
|
rs.getInt("id"),
|
||||||
|
rs.getDate("fecha"),
|
||||||
|
rs.getFloat("precio"),
|
||||||
|
rs.getBoolean("es_festival"),
|
||||||
|
rs.getInt("sala_id"),
|
||||||
|
rs.getInt("grupo_id")
|
||||||
|
);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
return c;
|
||||||
|
//throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Concierto getAnteriorConcierto(Concierto c) {
|
||||||
|
Connection conn = GestorConexiones.getConnection();
|
||||||
|
try {
|
||||||
|
PreparedStatement pt = conn.prepareStatement("SELECT * FROM concierto WHERE id < ? ORDER BY id DESC LIMIT 1");
|
||||||
|
pt.setInt(1, c.getId());
|
||||||
|
ResultSet rs = pt.executeQuery();
|
||||||
|
|
||||||
|
rs.next();
|
||||||
|
return new Concierto(
|
||||||
|
rs.getInt("id"),
|
||||||
|
rs.getDate("fecha"),
|
||||||
|
rs.getFloat("precio"),
|
||||||
|
rs.getBoolean("es_festival"),
|
||||||
|
rs.getInt("sala_id"),
|
||||||
|
rs.getInt("grupo_id")
|
||||||
|
);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
return c;
|
||||||
|
//throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static int guardarConcierto(Concierto c) {
|
||||||
|
if (c.getId() == -1) {
|
||||||
|
return nuevoConcierto(c);
|
||||||
|
} else {
|
||||||
|
Connection conn = GestorConexiones.getConnection();
|
||||||
|
try {
|
||||||
|
PreparedStatement pt = conn.prepareStatement("UPDATE concierto SET fecha = ? , precio = ? , es_festival = ?, sala_id = ?, grupo_id = ? WHERE id = ?");
|
||||||
|
pt.setDate(1, new Date(c.getFecha().getTime()));
|
||||||
|
pt.setFloat(2, c.getPrecio());
|
||||||
|
pt.setBoolean(3, c.isEs_festival());
|
||||||
|
pt.setInt(4, c.getSala_id());
|
||||||
|
pt.setInt(5, c.getGrupo_id());
|
||||||
|
pt.setInt(6, c.getId());
|
||||||
|
return pt.executeUpdate();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static List<Concierto> filtrarConciertos(Sala s, String grupo) {
|
||||||
|
Connection conn = GestorConexiones.getConnection();
|
||||||
|
List<Concierto> conciertos = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
PreparedStatement pt = conn.prepareStatement("SELECT c.* FROM concierto c join grupo g on c.grupo_id = g.id where c.sala_id = ? and g.nombre like ?");
|
||||||
|
pt.setInt(1, s.getId());
|
||||||
|
pt.setString(2, "%" + grupo + "%");
|
||||||
|
ResultSet rs = pt.executeQuery();
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
conciertos.add(new Concierto(
|
||||||
|
rs.getInt("id"),
|
||||||
|
rs.getDate("fecha"),
|
||||||
|
rs.getFloat("precio"),
|
||||||
|
rs.getBoolean("es_festival"),
|
||||||
|
rs.getInt("sala_id"),
|
||||||
|
rs.getInt("grupo_id")));
|
||||||
|
}
|
||||||
|
return conciertos;
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
return conciertos;
|
||||||
|
//throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int obtenerRecuentoFestivalesPorCiudad(String ciudad) {
|
||||||
|
Connection conn = GestorConexiones.getConnection();
|
||||||
|
try {
|
||||||
|
PreparedStatement pt = conn.prepareStatement("select count(*) recuento from concierto c join sala s on c.sala_id = s.id where c.es_festival = 1 and s.ciudad = ?");
|
||||||
|
pt.setString(1, ciudad);
|
||||||
|
ResultSet rs = pt.executeQuery();
|
||||||
|
|
||||||
|
rs.next();
|
||||||
|
|
||||||
|
return rs.getInt("recuento");
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float calcularPrecioMedio() {
|
||||||
|
Connection conn = GestorConexiones.getConnection();
|
||||||
|
try {
|
||||||
|
Statement st = conn.createStatement();
|
||||||
|
ResultSet rs = st.executeQuery("select avg(c.precio) media from concierto c");
|
||||||
|
|
||||||
|
rs.next();
|
||||||
|
|
||||||
|
return rs.getFloat("media");
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int nuevoConcierto(Concierto c) {
|
||||||
|
Connection conn = GestorConexiones.getConnection();
|
||||||
|
try {
|
||||||
|
|
||||||
|
PreparedStatement pt = conn.prepareStatement("INSERT INTO concierto (id,fecha,precio,es_festival,sala_id,grupo_id) VALUES (?,?,?,?,?,?)");
|
||||||
|
pt.setInt(1, getLastConcierto().getId() + 1);
|
||||||
|
pt.setDate(2, new Date(c.getFecha().getTime()));
|
||||||
|
pt.setFloat(3, c.getPrecio());
|
||||||
|
pt.setBoolean(4, c.isEs_festival());
|
||||||
|
pt.setInt(5, c.getSala_id());
|
||||||
|
pt.setInt(6, c.getGrupo_id());
|
||||||
|
|
||||||
|
return pt.executeUpdate();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int borrarConcierto(Concierto c) {
|
||||||
|
Connection conn = GestorConexiones.getConnection();
|
||||||
|
try {
|
||||||
|
PreparedStatement pt = conn.prepareStatement("DELETE FROM concierto WHERE id = ?");
|
||||||
|
pt.setInt(1, c.getId());
|
||||||
|
return pt.executeUpdate();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
return 0;
|
||||||
|
//throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package examenes.examen20250509.controlador;
|
||||||
|
|
||||||
|
import examenes.examen20250509.modelo.Grupo;
|
||||||
|
import examenes.examen20250509.modelo.Sala;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ControladorGrupo {
|
||||||
|
public static List<Grupo> getAllGrupos() {
|
||||||
|
Connection conn = GestorConexiones.getConnection();
|
||||||
|
List<Grupo> grupos = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
Statement st = conn.createStatement();
|
||||||
|
ResultSet rs = st.executeQuery("select * from grupo");
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
grupos.add(new Grupo(
|
||||||
|
rs.getInt("id"),
|
||||||
|
rs.getString("nombre"),
|
||||||
|
rs.getString("estilo")
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return grupos;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Grupo getGrupoById(int id) {
|
||||||
|
Connection conn = GestorConexiones.getConnection();
|
||||||
|
try {
|
||||||
|
PreparedStatement pt = conn.prepareStatement("select * from grupo where id = ?");
|
||||||
|
pt.setInt(1, id);
|
||||||
|
ResultSet rs = pt.executeQuery();
|
||||||
|
|
||||||
|
rs.next();
|
||||||
|
|
||||||
|
return new Grupo(
|
||||||
|
rs.getInt("id"),
|
||||||
|
rs.getString("nombre"),
|
||||||
|
rs.getString("estilo")
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object[] obtenerGrupoConMasConciertos() {
|
||||||
|
Connection conn = GestorConexiones.getConnection();
|
||||||
|
try {
|
||||||
|
Statement st = conn.createStatement();
|
||||||
|
ResultSet rs = st.executeQuery("select g.*, count(*) recuento from concierto c join grupo g on g.id = c.grupo_id group by id order by recuento desc limit 1");
|
||||||
|
|
||||||
|
rs.next();
|
||||||
|
|
||||||
|
return new Object[]{new Grupo(
|
||||||
|
rs.getInt("id"),
|
||||||
|
rs.getString("nombre"),
|
||||||
|
rs.getString("estilo")
|
||||||
|
), rs.getInt("recuento")};
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package examenes.examen20250509.controlador;
|
||||||
|
|
||||||
|
import examenes.examen20250509.modelo.Concierto;
|
||||||
|
import examenes.examen20250509.modelo.Sala;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ControladorSala {
|
||||||
|
public static List<Sala> getAllSalas() {
|
||||||
|
Connection conn = GestorConexiones.getConnection();
|
||||||
|
List<Sala> salas = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
Statement st = conn.createStatement();
|
||||||
|
ResultSet rs = st.executeQuery("select * from sala");
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
salas.add(new Sala(
|
||||||
|
rs.getInt("id"),
|
||||||
|
rs.getString("nombre"),
|
||||||
|
rs.getString("ciudad"),
|
||||||
|
rs.getInt("aforo")
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return salas;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Sala getSalaById(int id) {
|
||||||
|
Connection conn = GestorConexiones.getConnection();
|
||||||
|
try {
|
||||||
|
PreparedStatement pt = conn.prepareStatement("select * from sala where id = ?");
|
||||||
|
pt.setInt(1, id);
|
||||||
|
ResultSet rs = pt.executeQuery();
|
||||||
|
|
||||||
|
rs.next();
|
||||||
|
|
||||||
|
return new Sala(
|
||||||
|
rs.getInt("id"),
|
||||||
|
rs.getString("nombre"),
|
||||||
|
rs.getString("ciudad"),
|
||||||
|
rs.getInt("aforo")
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> obtenerCiudades() {
|
||||||
|
Connection conn = GestorConexiones.getConnection();
|
||||||
|
List<String> ciudades = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
Statement pt = conn.createStatement();
|
||||||
|
ResultSet rs = pt.executeQuery("select distinct ciudad from sala");
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
ciudades.add(rs.getString("ciudad"));
|
||||||
|
}
|
||||||
|
return ciudades;
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package examenes.examen20250509.controlador;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
|
||||||
|
public class GestorConexiones {
|
||||||
|
|
||||||
|
private static Connection openConnection;
|
||||||
|
|
||||||
|
private static String getMySQLConnectionString() {
|
||||||
|
String host = "127.0.0.1:3310";
|
||||||
|
String schema = "conciertos_grupos_salas";
|
||||||
|
String properties = "?autoReconnect=true&serverTimezone=Europe/Madrid&useSSL=False&allowPublicKeyRetrieval=TRUE";
|
||||||
|
String user = "root";
|
||||||
|
String password = "1234";
|
||||||
|
|
||||||
|
return "jdbc:mysql://" + user + ":" + password + "@" + host + "/" + schema + properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Connection getConnection() {
|
||||||
|
if (openConnection == null) {
|
||||||
|
try {
|
||||||
|
//Class.forName(getMySQLDriver());
|
||||||
|
openConnection = DriverManager.getConnection(getMySQLConnectionString());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return openConnection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getMySQLDriver() {
|
||||||
|
return "com.mysql.cj.jdbc.Driver";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
81
src/main/java/examenes/examen20250509/modelo/Concierto.java
Normal file
81
src/main/java/examenes/examen20250509/modelo/Concierto.java
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
package examenes.examen20250509.modelo;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class Concierto {
|
||||||
|
private int id;
|
||||||
|
private Date fecha;
|
||||||
|
private float precio;
|
||||||
|
private boolean es_festival;
|
||||||
|
private int sala_id;
|
||||||
|
private int grupo_id;
|
||||||
|
|
||||||
|
public Concierto(int id, Date fecha, float precio, boolean es_festival, int sala_id, int grupo_id) {
|
||||||
|
this.id = id;
|
||||||
|
this.fecha = fecha;
|
||||||
|
this.precio = precio;
|
||||||
|
this.es_festival = es_festival;
|
||||||
|
this.sala_id = sala_id;
|
||||||
|
this.grupo_id = grupo_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getFecha() {
|
||||||
|
return fecha;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFecha(Date fecha) {
|
||||||
|
this.fecha = fecha;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getPrecio() {
|
||||||
|
return precio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrecio(float precio) {
|
||||||
|
this.precio = precio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEs_festival() {
|
||||||
|
return es_festival;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEs_festival(boolean es_festival) {
|
||||||
|
this.es_festival = es_festival;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSala_id() {
|
||||||
|
return sala_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSala_id(int sala_id) {
|
||||||
|
this.sala_id = sala_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGrupo_id() {
|
||||||
|
return grupo_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGrupo_id(int grupo_id) {
|
||||||
|
this.grupo_id = grupo_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Concierto{" +
|
||||||
|
"id=" + id +
|
||||||
|
", fecha=" + fecha +
|
||||||
|
", precio=" + precio +
|
||||||
|
", es_festival=" + es_festival +
|
||||||
|
", sala_id=" + sala_id +
|
||||||
|
", grupo_id=" + grupo_id +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
42
src/main/java/examenes/examen20250509/modelo/Grupo.java
Normal file
42
src/main/java/examenes/examen20250509/modelo/Grupo.java
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package examenes.examen20250509.modelo;
|
||||||
|
|
||||||
|
public class Grupo {
|
||||||
|
private int id;
|
||||||
|
private String nombre;
|
||||||
|
private String estilo;
|
||||||
|
|
||||||
|
public Grupo(int id, String nombre, String estilo) {
|
||||||
|
this.id = id;
|
||||||
|
this.nombre = nombre;
|
||||||
|
this.estilo = estilo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNombre() {
|
||||||
|
return nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNombre(String nombre) {
|
||||||
|
this.nombre = nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEstilo() {
|
||||||
|
return estilo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEstilo(String estilo) {
|
||||||
|
this.estilo = estilo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return nombre;
|
||||||
|
}
|
||||||
|
}
|
||||||
52
src/main/java/examenes/examen20250509/modelo/Sala.java
Normal file
52
src/main/java/examenes/examen20250509/modelo/Sala.java
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
package examenes.examen20250509.modelo;
|
||||||
|
|
||||||
|
public class Sala {
|
||||||
|
private int id;
|
||||||
|
private String nombre;
|
||||||
|
private String ciudad;
|
||||||
|
private int aforo;
|
||||||
|
|
||||||
|
public Sala(int id, String nombre, String ciudad, int aforo) {
|
||||||
|
this.id = id;
|
||||||
|
this.nombre = nombre;
|
||||||
|
this.ciudad = ciudad;
|
||||||
|
this.aforo = aforo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNombre() {
|
||||||
|
return nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNombre(String nombre) {
|
||||||
|
this.nombre = nombre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCiudad() {
|
||||||
|
return ciudad;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCiudad(String ciudad) {
|
||||||
|
this.ciudad = ciudad;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAforo() {
|
||||||
|
return aforo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAforo(int aforo) {
|
||||||
|
this.aforo = aforo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return nombre;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
package examenes.examen20250509.vista;
|
||||||
|
|
||||||
|
import examenes.examen20250509.controlador.ControladorConcierto;
|
||||||
|
import examenes.examen20250509.controlador.ControladorGrupo;
|
||||||
|
import examenes.examen20250509.controlador.ControladorSala;
|
||||||
|
import examenes.examen20250509.modelo.Grupo;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class EstadisticasConciertos extends JPanel {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private JTable tablaDatos;
|
||||||
|
private JTextField textFieldPrecioMedio;
|
||||||
|
private JTextField textFieldMasConciertos;
|
||||||
|
private DefaultTableModel dtm = new DefaultTableModel(obtenerDatos(), new String[]{"Ciudad", "Nº Festivales"});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the panel.
|
||||||
|
*/
|
||||||
|
public EstadisticasConciertos() {
|
||||||
|
setLayout(new BorderLayout(0, 0));
|
||||||
|
|
||||||
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
|
add(scrollPane, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
tablaDatos = new JTable(dtm);
|
||||||
|
scrollPane.setViewportView(tablaDatos);
|
||||||
|
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
add(panel, BorderLayout.SOUTH);
|
||||||
|
GridBagLayout gbl_panel = new GridBagLayout();
|
||||||
|
gbl_panel.columnWidths = new int[]{194, 61, 0};
|
||||||
|
gbl_panel.rowHeights = new int[]{16, 0, 0};
|
||||||
|
gbl_panel.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
|
||||||
|
panel.setLayout(gbl_panel);
|
||||||
|
|
||||||
|
JButton btnNewButton = new JButton("Calcular Precio Medio");
|
||||||
|
btnNewButton.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
textFieldPrecioMedio.setText(ControladorConcierto.calcularPrecioMedio() + " €");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
|
||||||
|
gbc_btnNewButton.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_btnNewButton.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_btnNewButton.gridx = 0;
|
||||||
|
gbc_btnNewButton.gridy = 0;
|
||||||
|
panel.add(btnNewButton, gbc_btnNewButton);
|
||||||
|
|
||||||
|
textFieldPrecioMedio = new JTextField();
|
||||||
|
textFieldPrecioMedio.setEditable(false);
|
||||||
|
GridBagConstraints gbc_textFieldPrecioMedio = new GridBagConstraints();
|
||||||
|
gbc_textFieldPrecioMedio.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_textFieldPrecioMedio.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_textFieldPrecioMedio.gridx = 1;
|
||||||
|
gbc_textFieldPrecioMedio.gridy = 0;
|
||||||
|
panel.add(textFieldPrecioMedio, gbc_textFieldPrecioMedio);
|
||||||
|
textFieldPrecioMedio.setColumns(10);
|
||||||
|
|
||||||
|
JButton btnNewButton_1 = new JButton("Calcular Grupo con más Conciertos");
|
||||||
|
btnNewButton_1.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
Object[] datos = ControladorGrupo.obtenerGrupoConMasConciertos();
|
||||||
|
textFieldMasConciertos.setText(((Grupo) datos[0]).getNombre() + " - " + datos[1]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnNewButton_1 = new GridBagConstraints();
|
||||||
|
gbc_btnNewButton_1.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_btnNewButton_1.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_btnNewButton_1.gridx = 0;
|
||||||
|
gbc_btnNewButton_1.gridy = 1;
|
||||||
|
panel.add(btnNewButton_1, gbc_btnNewButton_1);
|
||||||
|
|
||||||
|
textFieldMasConciertos = new JTextField();
|
||||||
|
textFieldMasConciertos.setEditable(false);
|
||||||
|
GridBagConstraints gbc_textFieldMasConciertos = new GridBagConstraints();
|
||||||
|
gbc_textFieldMasConciertos.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_textFieldMasConciertos.gridx = 1;
|
||||||
|
gbc_textFieldMasConciertos.gridy = 1;
|
||||||
|
panel.add(textFieldMasConciertos, gbc_textFieldMasConciertos);
|
||||||
|
textFieldMasConciertos.setColumns(10);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object[][] obtenerDatos() {
|
||||||
|
List<String> ciudades = ControladorSala.obtenerCiudades();
|
||||||
|
Object[][] datos = new Object[ciudades.size()][2];
|
||||||
|
for (int i = 0; i < ciudades.size(); i++) {
|
||||||
|
datos[i][0] = ciudades.get(i);
|
||||||
|
datos[i][1] = ControladorConcierto.obtenerRecuentoFestivalesPorCiudad(ciudades.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return datos;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
package examenes.examen20250509.vista;
|
||||||
|
|
||||||
|
import examenes.examen20250509.controlador.ControladorConcierto;
|
||||||
|
import examenes.examen20250509.controlador.ControladorGrupo;
|
||||||
|
import examenes.examen20250509.controlador.ControladorSala;
|
||||||
|
import examenes.examen20250509.modelo.Concierto;
|
||||||
|
import examenes.examen20250509.modelo.Sala;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.util.List;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
|
public class FiltradoConciertos extends JPanel {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private JTextField textFieldGrupo;
|
||||||
|
private JComboBox<Sala> comboBoxSala;
|
||||||
|
private JTextField textField;
|
||||||
|
private DefaultListModel<String> dlm = new DefaultListModel<>();
|
||||||
|
private JList listaSalas;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the panel.
|
||||||
|
*/
|
||||||
|
public FiltradoConciertos() {
|
||||||
|
setLayout(new BorderLayout(0, 0));
|
||||||
|
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
add(panel, BorderLayout.NORTH);
|
||||||
|
GridBagLayout gbl_panel = new GridBagLayout();
|
||||||
|
gbl_panel.columnWidths = new int[]{0, 0, 0, 0};
|
||||||
|
gbl_panel.rowHeights = new int[]{0, 0, 0};
|
||||||
|
gbl_panel.columnWeights = new double[]{0.0, 1.0, 1.0, Double.MIN_VALUE};
|
||||||
|
gbl_panel.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
|
||||||
|
panel.setLayout(gbl_panel);
|
||||||
|
|
||||||
|
JLabel lblNewLabel_1 = new JLabel("Sala:");
|
||||||
|
GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
|
||||||
|
gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblNewLabel_1.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblNewLabel_1.gridx = 0;
|
||||||
|
gbc_lblNewLabel_1.gridy = 0;
|
||||||
|
panel.add(lblNewLabel_1, gbc_lblNewLabel_1);
|
||||||
|
|
||||||
|
comboBoxSala = new JComboBox<>();
|
||||||
|
GridBagConstraints gbc_comboBox = new GridBagConstraints();
|
||||||
|
gbc_comboBox.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_comboBox.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_comboBox.gridx = 1;
|
||||||
|
gbc_comboBox.gridy = 0;
|
||||||
|
panel.add(comboBoxSala, gbc_comboBox);
|
||||||
|
|
||||||
|
JLabel lblNewLabel = new JLabel("Grupo:");
|
||||||
|
GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
|
||||||
|
gbc_lblNewLabel.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblNewLabel.gridx = 0;
|
||||||
|
gbc_lblNewLabel.gridy = 1;
|
||||||
|
panel.add(lblNewLabel, gbc_lblNewLabel);
|
||||||
|
|
||||||
|
textFieldGrupo = new JTextField();
|
||||||
|
GridBagConstraints gbc_textField = new GridBagConstraints();
|
||||||
|
gbc_textField.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_textField.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_textField.gridx = 1;
|
||||||
|
gbc_textField.gridy = 1;
|
||||||
|
panel.add(textFieldGrupo, gbc_textField);
|
||||||
|
textFieldGrupo.setColumns(10);
|
||||||
|
|
||||||
|
JButton btnNewButton = new JButton("Buscar");
|
||||||
|
btnNewButton.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
cargarLista();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
|
||||||
|
gbc_btnNewButton.anchor = GridBagConstraints.WEST;
|
||||||
|
gbc_btnNewButton.gridx = 2;
|
||||||
|
gbc_btnNewButton.gridy = 1;
|
||||||
|
panel.add(btnNewButton, gbc_btnNewButton);
|
||||||
|
|
||||||
|
JPanel panel_1 = new JPanel();
|
||||||
|
add(panel_1, BorderLayout.EAST);
|
||||||
|
panel_1.setLayout(new BoxLayout(panel_1, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
JButton btnNewButton_1 = new JButton("Añadir Concierto");
|
||||||
|
btnNewButton_1.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
dlm.addElement(textField.getText());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
btnNewButton_1.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
panel_1.add(btnNewButton_1);
|
||||||
|
|
||||||
|
textField = new JTextField();
|
||||||
|
panel_1.add(textField);
|
||||||
|
textField.setColumns(3);
|
||||||
|
|
||||||
|
JSeparator separator = new JSeparator();
|
||||||
|
panel_1.add(separator);
|
||||||
|
|
||||||
|
JButton btnNewButton_2 = new JButton("Eliminar Concierto");
|
||||||
|
btnNewButton_2.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
int[] listaAEliminar = listaSalas.getSelectedIndices();
|
||||||
|
for (int i = listaAEliminar.length - 1; i >= 0; i--) {
|
||||||
|
dlm.removeElementAt(listaAEliminar[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
btnNewButton_2.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
panel_1.add(btnNewButton_2);
|
||||||
|
|
||||||
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
|
add(scrollPane, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
listaSalas = new JList(dlm);
|
||||||
|
listaSalas.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||||
|
scrollPane.setViewportView(listaSalas);
|
||||||
|
|
||||||
|
cargarAlInicio();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cargarAlInicio() {
|
||||||
|
List<Sala> salas = ControladorSala.getAllSalas();
|
||||||
|
for (Sala s : salas) {
|
||||||
|
comboBoxSala.addItem(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
cargarLista();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cargarLista() {
|
||||||
|
dlm.clear();
|
||||||
|
List<Concierto> conciertos = ControladorConcierto.filtrarConciertos((Sala) comboBoxSala.getSelectedItem(), textFieldGrupo.getText());
|
||||||
|
for (Concierto c : conciertos) {
|
||||||
|
dlm.addElement(c.getFecha().toString() + " - " + ControladorGrupo.getGrupoById(c.getGrupo_id()) + " - " + ((Sala) comboBoxSala.getSelectedItem()).getNombre());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,323 @@
|
|||||||
|
package examenes.examen20250509.vista;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.Insets;
|
||||||
|
|
||||||
|
import examenes.examen20250509.controlador.ControladorConcierto;
|
||||||
|
import examenes.examen20250509.controlador.ControladorGrupo;
|
||||||
|
import examenes.examen20250509.controlador.ControladorSala;
|
||||||
|
import examenes.examen20250509.modelo.Concierto;
|
||||||
|
import examenes.examen20250509.modelo.Grupo;
|
||||||
|
import examenes.examen20250509.modelo.Sala;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.awt.Color;
|
||||||
|
|
||||||
|
public class GestionConciertos extends JPanel {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private Concierto conciertoActual;
|
||||||
|
|
||||||
|
private JTextField tfFecha;
|
||||||
|
private JTextField tfPrecio;
|
||||||
|
private JComboBox<Grupo> comboBoxGrupo;
|
||||||
|
private JComboBox<Sala> comboBoxSala;
|
||||||
|
private JCheckBox checkBoxFestival;
|
||||||
|
private JLabel mensajePrecio;
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the panel.
|
||||||
|
*/
|
||||||
|
public GestionConciertos() {
|
||||||
|
setLayout(new BorderLayout(0, 0));
|
||||||
|
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
||||||
|
gridBagLayout.columnWidths = new int[]{0, 0, 0};
|
||||||
|
gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0};
|
||||||
|
gridBagLayout.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
|
||||||
|
gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
||||||
|
panel.setLayout(gridBagLayout);
|
||||||
|
add(panel);
|
||||||
|
|
||||||
|
|
||||||
|
JLabel lblNewLabel = new JLabel("Fecha:");
|
||||||
|
GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
|
||||||
|
gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblNewLabel.gridx = 0;
|
||||||
|
gbc_lblNewLabel.gridy = 0;
|
||||||
|
panel.add(lblNewLabel, gbc_lblNewLabel);
|
||||||
|
|
||||||
|
tfFecha = new JTextField();
|
||||||
|
GridBagConstraints gbc_textField = new GridBagConstraints();
|
||||||
|
gbc_textField.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_textField.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_textField.gridx = 1;
|
||||||
|
gbc_textField.gridy = 0;
|
||||||
|
panel.add(tfFecha, gbc_textField);
|
||||||
|
tfFecha.setColumns(10);
|
||||||
|
|
||||||
|
JLabel lblNewLabel_1 = new JLabel("Precio:");
|
||||||
|
GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
|
||||||
|
gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblNewLabel_1.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblNewLabel_1.gridx = 0;
|
||||||
|
gbc_lblNewLabel_1.gridy = 1;
|
||||||
|
panel.add(lblNewLabel_1, gbc_lblNewLabel_1);
|
||||||
|
|
||||||
|
checkBoxFestival = new JCheckBox("");
|
||||||
|
checkBoxFestival.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
establecerCheckbox(checkBoxFestival.isSelected());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tfPrecio = new JTextField();
|
||||||
|
GridBagConstraints gbc_textField_1 = new GridBagConstraints();
|
||||||
|
gbc_textField_1.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_textField_1.gridx = 1;
|
||||||
|
gbc_textField_1.gridy = 1;
|
||||||
|
panel.add(tfPrecio, gbc_textField_1);
|
||||||
|
tfPrecio.setColumns(10);
|
||||||
|
|
||||||
|
mensajePrecio = new JLabel("");
|
||||||
|
mensajePrecio.setForeground(new Color(169, 0, 0));
|
||||||
|
GridBagConstraints gbc_mensajePrecio = new GridBagConstraints();
|
||||||
|
gbc_mensajePrecio.anchor = GridBagConstraints.WEST;
|
||||||
|
gbc_mensajePrecio.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_mensajePrecio.gridx = 1;
|
||||||
|
gbc_mensajePrecio.gridy = 2;
|
||||||
|
panel.add(mensajePrecio, gbc_mensajePrecio);
|
||||||
|
|
||||||
|
checkBoxFestival.setHorizontalAlignment(SwingConstants.LEFT);
|
||||||
|
GridBagConstraints gbc_chckbxNewCheckBox = new GridBagConstraints();
|
||||||
|
gbc_chckbxNewCheckBox.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_chckbxNewCheckBox.anchor = GridBagConstraints.WEST;
|
||||||
|
gbc_chckbxNewCheckBox.gridx = 1;
|
||||||
|
gbc_chckbxNewCheckBox.gridy = 3;
|
||||||
|
panel.add(checkBoxFestival, gbc_chckbxNewCheckBox);
|
||||||
|
|
||||||
|
JLabel lblNewLabel_2 = new JLabel("Sala:");
|
||||||
|
GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
|
||||||
|
gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_lblNewLabel_2.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblNewLabel_2.gridx = 0;
|
||||||
|
gbc_lblNewLabel_2.gridy = 4;
|
||||||
|
panel.add(lblNewLabel_2, gbc_lblNewLabel_2);
|
||||||
|
|
||||||
|
comboBoxSala = new JComboBox<>();
|
||||||
|
GridBagConstraints gbc_comboBox = new GridBagConstraints();
|
||||||
|
gbc_comboBox.insets = new Insets(0, 0, 5, 5);
|
||||||
|
gbc_comboBox.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_comboBox.gridx = 1;
|
||||||
|
gbc_comboBox.gridy = 4;
|
||||||
|
panel.add(comboBoxSala, gbc_comboBox);
|
||||||
|
|
||||||
|
JLabel lblNewLabel_3 = new JLabel("Grupo:");
|
||||||
|
GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints();
|
||||||
|
gbc_lblNewLabel_3.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_lblNewLabel_3.anchor = GridBagConstraints.EAST;
|
||||||
|
gbc_lblNewLabel_3.gridx = 0;
|
||||||
|
gbc_lblNewLabel_3.gridy = 5;
|
||||||
|
panel.add(lblNewLabel_3, gbc_lblNewLabel_3);
|
||||||
|
|
||||||
|
comboBoxGrupo = new JComboBox<>();
|
||||||
|
GridBagConstraints gbc_comboBox_1 = new GridBagConstraints();
|
||||||
|
gbc_comboBox_1.insets = new Insets(0, 0, 0, 5);
|
||||||
|
gbc_comboBox_1.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_comboBox_1.gridx = 1;
|
||||||
|
gbc_comboBox_1.gridy = 5;
|
||||||
|
panel.add(comboBoxGrupo, gbc_comboBox_1);
|
||||||
|
|
||||||
|
JPanel panel_1 = new JPanel();
|
||||||
|
add(panel_1, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
JButton btnNewButton = new JButton("<<");
|
||||||
|
btnNewButton.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
mensajePrecio.setText("");
|
||||||
|
setConcierto(ControladorConcierto.getFirstConcierto());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel_1.add(btnNewButton);
|
||||||
|
|
||||||
|
JButton btnNewButton_1 = new JButton("<");
|
||||||
|
btnNewButton_1.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
mensajePrecio.setText("");
|
||||||
|
setConcierto(ControladorConcierto.getAnteriorConcierto(conciertoActual));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel_1.add(btnNewButton_1);
|
||||||
|
|
||||||
|
JButton btnNewButton_2 = new JButton(">");
|
||||||
|
btnNewButton_2.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
mensajePrecio.setText("");
|
||||||
|
setConcierto(ControladorConcierto.getSiguienteConcierto(conciertoActual));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel_1.add(btnNewButton_2);
|
||||||
|
|
||||||
|
JButton btnNewButton_3 = new JButton(">>");
|
||||||
|
btnNewButton_3.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
mensajePrecio.setText("");
|
||||||
|
setConcierto(ControladorConcierto.getLastConcierto());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel_1.add(btnNewButton_3);
|
||||||
|
|
||||||
|
JSeparator separator = new JSeparator();
|
||||||
|
panel_1.add(separator);
|
||||||
|
|
||||||
|
JButton btnNewButton_4 = new JButton("Nuevo");
|
||||||
|
btnNewButton_4.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
nuevoConcierto();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel_1.add(btnNewButton_4);
|
||||||
|
|
||||||
|
JButton btnNewButton_5 = new JButton("Guardar");
|
||||||
|
btnNewButton_5.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
guardarConcierto();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel_1.add(btnNewButton_5);
|
||||||
|
|
||||||
|
JButton btnNewButton_6 = new JButton("Eliminar");
|
||||||
|
btnNewButton_6.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
eliminarConcierto();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel_1.add(btnNewButton_6);
|
||||||
|
|
||||||
|
cargarAlInicio();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cargarAlInicio() {
|
||||||
|
setConcierto(ControladorConcierto.getFirstConcierto());
|
||||||
|
|
||||||
|
List<Sala> salas = ControladorSala.getAllSalas();
|
||||||
|
for (Sala s : salas) {
|
||||||
|
comboBoxSala.addItem(s);
|
||||||
|
}
|
||||||
|
List<Grupo> grupos = ControladorGrupo.getAllGrupos();
|
||||||
|
for (Grupo g : grupos) {
|
||||||
|
comboBoxGrupo.addItem(g);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setConcierto(Concierto c) {
|
||||||
|
conciertoActual = c;
|
||||||
|
tfFecha.setText(c.getFecha().toString());
|
||||||
|
tfPrecio.setText(String.valueOf(c.getPrecio()));
|
||||||
|
establecerCheckbox(c.isEs_festival());
|
||||||
|
|
||||||
|
|
||||||
|
comboBoxSala.removeAllItems();
|
||||||
|
List<Sala> salas = ControladorSala.getAllSalas();
|
||||||
|
for (Sala s : salas) {
|
||||||
|
comboBoxSala.addItem(s);
|
||||||
|
if (c.getSala_id() == s.getId()) {
|
||||||
|
comboBoxSala.setSelectedItem(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
comboBoxGrupo.removeAllItems();
|
||||||
|
List<Grupo> grupos = ControladorGrupo.getAllGrupos();
|
||||||
|
for (Grupo g : grupos) {
|
||||||
|
comboBoxGrupo.addItem(g);
|
||||||
|
if (c.getSala_id() == g.getId()) {
|
||||||
|
comboBoxGrupo.setSelectedItem(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void establecerCheckbox(boolean b) {
|
||||||
|
if (b) {
|
||||||
|
checkBoxFestival.setText("Es Festival");
|
||||||
|
} else {
|
||||||
|
checkBoxFestival.setText("No es Festival");
|
||||||
|
}
|
||||||
|
checkBoxFestival.setSelected(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void guardarConcierto() {
|
||||||
|
|
||||||
|
if (Float.valueOf(tfPrecio.getText()) >= 0 && Float.valueOf(tfPrecio.getText()) <= 999.99) {
|
||||||
|
mensajePrecio.setText("");
|
||||||
|
try {
|
||||||
|
Concierto concierto = new Concierto(
|
||||||
|
conciertoActual.getId(),
|
||||||
|
sdf.parse(tfFecha.getText()),
|
||||||
|
Float.valueOf(tfPrecio.getText()),
|
||||||
|
checkBoxFestival.isSelected(),
|
||||||
|
((Sala) comboBoxSala.getSelectedItem()).getId(),
|
||||||
|
((Grupo) comboBoxGrupo.getSelectedItem()).getId()
|
||||||
|
);
|
||||||
|
ControladorConcierto.guardarConcierto(concierto);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
//throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mensajePrecio.setText("El precio es incorrecto. Debe estar entre 0 y 999.99");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void nuevoConcierto() {
|
||||||
|
Concierto nuevo = new Concierto(
|
||||||
|
-1,
|
||||||
|
new Date(),
|
||||||
|
0,
|
||||||
|
false,
|
||||||
|
-1,
|
||||||
|
-1
|
||||||
|
);
|
||||||
|
|
||||||
|
tfFecha.setText(sdf.format(nuevo.getFecha()));
|
||||||
|
tfPrecio.setText(String.valueOf(nuevo.getPrecio()));
|
||||||
|
establecerCheckbox(nuevo.isEs_festival());
|
||||||
|
comboBoxSala.setSelectedIndex(-1);
|
||||||
|
comboBoxGrupo.setSelectedIndex(-1);
|
||||||
|
|
||||||
|
conciertoActual = nuevo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void eliminarConcierto() {
|
||||||
|
if (JOptionPane.showConfirmDialog(this, "¿Desea borrar el registro?", "¿Está seguro?", JOptionPane.YES_NO_OPTION) != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Concierto conciertoSiguiente = ControladorConcierto.getSiguienteConcierto(conciertoActual);
|
||||||
|
Concierto conciertoAnterior = ControladorConcierto.getAnteriorConcierto(conciertoActual);
|
||||||
|
|
||||||
|
int resultado = ControladorConcierto.borrarConcierto(conciertoActual);
|
||||||
|
if (resultado > 0) {
|
||||||
|
if (conciertoSiguiente != null) {
|
||||||
|
setConcierto(conciertoSiguiente);
|
||||||
|
} else if (conciertoAnterior != null) {
|
||||||
|
setConcierto(conciertoAnterior);
|
||||||
|
} else {
|
||||||
|
nuevoConcierto();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
56
src/main/java/examenes/examen20250509/vista/MainView.java
Normal file
56
src/main/java/examenes/examen20250509/vista/MainView.java
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
package examenes.examen20250509.vista;
|
||||||
|
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.nio.file.FileStore;
|
||||||
|
import javax.swing.JTabbedPane;
|
||||||
|
|
||||||
|
public class MainView extends JFrame {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private JPanel contentPane;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launch the application.
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
EventQueue.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
MainView frame = new MainView();
|
||||||
|
frame.setVisible(true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the frame.
|
||||||
|
*/
|
||||||
|
public MainView() {
|
||||||
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
setBounds(0, 0, 800, 500);
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
contentPane = new JPanel();
|
||||||
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
|
||||||
|
setContentPane(contentPane);
|
||||||
|
contentPane.setLayout(new BorderLayout(0, 0));
|
||||||
|
|
||||||
|
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
||||||
|
contentPane.add(tabbedPane, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
tabbedPane.addTab("Gestión", null, new GestionConciertos(), null);
|
||||||
|
|
||||||
|
tabbedPane.addTab("Filtrado", null, new FiltradoConciertos(), null);
|
||||||
|
|
||||||
|
tabbedPane.addTab("Estadísticas", null, new EstadisticasConciertos(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user