Generación de asientos con info de la base de datos
This commit is contained in:
parent
7f3c76ea18
commit
fe48c1944f
ProyectoVentaBoletos/src/main/java
|
@ -3,6 +3,8 @@ package controller;
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ItemEvent;
|
||||||
|
import java.awt.event.ItemListener;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
@ -15,27 +17,44 @@ import model.ModeloSQL;
|
||||||
import view.Menu;
|
import view.Menu;
|
||||||
import view.MenuSala;
|
import view.MenuSala;
|
||||||
|
|
||||||
public class MenuController extends WindowAdapter implements ActionListener {
|
public class MenuController extends WindowAdapter implements ActionListener, ItemListener {
|
||||||
private Menu menu;
|
private Menu menu;
|
||||||
|
private MenuSala menuSala;
|
||||||
private ModeloSQL modeloSQL;
|
private ModeloSQL modeloSQL;
|
||||||
|
private String seleccionEventoComboBox;
|
||||||
|
private ArrayList<Evento> arrayListEventos;
|
||||||
|
|
||||||
public MenuController(Menu menu){
|
public MenuController(Menu menu){
|
||||||
this.menu = menu;
|
this.menu = menu;
|
||||||
this.modeloSQL = new ModeloSQL();
|
this.modeloSQL = new ModeloSQL();
|
||||||
|
arrayListEventos = new ArrayList<>();
|
||||||
obtenerEventosDefaultComboBoxMoldel();
|
obtenerEventosDefaultComboBoxMoldel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void actionPerformed(ActionEvent e){
|
public void actionPerformed(ActionEvent e){
|
||||||
Object o = e.getSource();
|
Object o = e.getSource();
|
||||||
|
|
||||||
// Si se presiona el boton de visualizar
|
// Si se presiona el boton de visualizar
|
||||||
if(o.equals(menu.jButtonVisualizar)){
|
if(o.equals(menu.jButtonVisualizar)){
|
||||||
System.out.println("controller.MenuController.actionPerformed(): jButtonVisualizar");
|
// Si se ha seleccionado un evento del comboBox
|
||||||
MenuSala menuSala = new MenuSala();
|
if(seleccionEventoComboBox != null && seleccionEventoComboBox != "Seleccione un evento"){
|
||||||
menu.jPanelMenuSala.removeAll(); // Limpiar panel
|
System.out.println("controller.MenuController.actionPerformed(): visualizar evento de " + seleccionEventoComboBox);
|
||||||
menu.jPanelMenuSala.add(menuSala, BorderLayout.CENTER); // Agrega el nuevo JPanel
|
menuSala = new MenuSala(obtenerIdEventoSeleccionado(seleccionEventoComboBox), seleccionEventoComboBox);
|
||||||
menu.jPanelMenuSala.revalidate(); // Reorganiza los componentes
|
menu.jPanelMenuSala.removeAll(); // Limpiar panel
|
||||||
menu. jPanelMenuSala.repaint(); // Redibuja la interfaz
|
menu.jPanelMenuSala.add(menuSala, BorderLayout.CENTER); // Agrega el nuevo JPanel
|
||||||
|
menu.jPanelMenuSala.revalidate(); // Reorganiza los componentes
|
||||||
|
menu. jPanelMenuSala.repaint(); // Redibuja la interfaz
|
||||||
|
} else {
|
||||||
|
menu.mensaje("Debe seleccionar un evento.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void itemStateChanged(ItemEvent e) {
|
||||||
|
// Obtener evento musical seleccionado del ComboBox
|
||||||
|
if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||||
|
seleccionEventoComboBox = (String) menu.jComboBoxEventos.getSelectedItem();
|
||||||
|
System.out.println("controller.MenuController.itemStateChanged: seleccionó " + seleccionEventoComboBox);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,13 +67,26 @@ public class MenuController extends WindowAdapter implements ActionListener {
|
||||||
// Obtener ResultSet de ModeloSQL y añádir eventos al ComboBoxModel del ComboBox de eventos
|
// Obtener ResultSet de ModeloSQL y añádir eventos al ComboBoxModel del ComboBox de eventos
|
||||||
public void obtenerEventosDefaultComboBoxMoldel(){
|
public void obtenerEventosDefaultComboBoxMoldel(){
|
||||||
ResultSet rs = modeloSQL.obtenerEventos();
|
ResultSet rs = modeloSQL.obtenerEventos();
|
||||||
|
menu.defaultComboBoxModel.addElement("Seleccione un evento");
|
||||||
try {
|
try {
|
||||||
while ( rs.next() ){
|
while ( rs.next() ){
|
||||||
|
arrayListEventos.add(new Evento(rs.getInt("idEvento"), rs.getString("nombre"), rs.getDate("fecha")));
|
||||||
menu.defaultComboBoxModel.addElement(rs.getString("nombre"));
|
menu.defaultComboBoxModel.addElement(rs.getString("nombre"));
|
||||||
System.out.println("MenuController.obtenerEventosDefaultComboBoxMoldel(): + " + rs.getString("nombre"));
|
System.out.println("MenuController.obtenerEventosDefaultComboBoxMoldel(): + " + rs.getString("nombre"));
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
System.out.println("MenuController.obtenerEventosDefaultComboBoxMoldel(): error " + ex);;
|
System.out.println("MenuController.obtenerEventosDefaultComboBoxMoldel(): error " + ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int obtenerIdEventoSeleccionado(String nombreEvento){
|
||||||
|
int idEvento = 0;
|
||||||
|
for(Evento evento: arrayListEventos){
|
||||||
|
if(evento.getNombre().equals(nombreEvento)){
|
||||||
|
idEvento = evento.getIdEvento();
|
||||||
|
System.out.println("MenuController.obtenerIdEventoSeleccionado: " + nombreEvento + " id: " + idEvento );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return idEvento;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,175 @@
|
||||||
|
package controller;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ItemEvent;
|
||||||
|
import java.awt.event.ItemListener;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import javax.swing.JToggleButton;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import model.Asiento;
|
||||||
|
import view.MenuSala;
|
||||||
|
import model.ModeloSQL;
|
||||||
|
|
||||||
|
public class MenuSalaController implements ActionListener, ItemListener{
|
||||||
|
private int idEvento;
|
||||||
|
private MenuSala menuSala;
|
||||||
|
private ModeloSQL modeloSQL = new ModeloSQL();
|
||||||
|
|
||||||
|
private ArrayList<JToggleButton> arrayListAsientosSeleccionados;
|
||||||
|
|
||||||
|
//private int filas = 6;
|
||||||
|
private int columnas = 7;
|
||||||
|
private int largoBoton = 140;
|
||||||
|
private int anchoBoton = 60;
|
||||||
|
|
||||||
|
|
||||||
|
boolean clickAsientosHabilitado = false;// Variable bandera para permitir o no la selección de asientos
|
||||||
|
|
||||||
|
public MenuSalaController(MenuSala menuSala) {
|
||||||
|
this.menuSala = menuSala;
|
||||||
|
this.modeloSQL = new ModeloSQL();
|
||||||
|
this.idEvento = menuSala.getIdEvento();
|
||||||
|
obtenerAsientos(idEvento);// Obtener información del evento seleccionado desde la BD y añadir botones
|
||||||
|
arrayListAsientosSeleccionados = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void obtenerAsientos(int idEvento){
|
||||||
|
arrayListAsientosSeleccionados = null;
|
||||||
|
arrayListAsientosSeleccionados = new ArrayList<>();
|
||||||
|
int ejeX = 20;
|
||||||
|
int ejeY = 20;
|
||||||
|
ResultSet rs = modeloSQL.obtenerAsientosDisponibles(idEvento);
|
||||||
|
int numeroAsiento = 0;
|
||||||
|
try {
|
||||||
|
while ( rs.next() ){
|
||||||
|
int idAsiento = rs.getInt("idAsiento");
|
||||||
|
String fila = rs.getString("fila");
|
||||||
|
int numero = rs.getInt("numero");
|
||||||
|
String estado = rs.getString("estado");
|
||||||
|
|
||||||
|
Asiento asiento = new Asiento(idEvento, fila, numero);// Crear objeto asiento
|
||||||
|
|
||||||
|
JToggleButton botonAsiento = new JToggleButton(fila + ""+ numero + " ("+estado+")");// Crear botón
|
||||||
|
botonAsiento.setBounds(ejeX, ejeY, largoBoton, anchoBoton);// Establecer posición del botón
|
||||||
|
|
||||||
|
// Guadar información dentro del botón
|
||||||
|
botonAsiento.putClientProperty("asiento", asiento);
|
||||||
|
botonAsiento.putClientProperty("idAsiento", idAsiento);
|
||||||
|
botonAsiento.putClientProperty("estado", estado);
|
||||||
|
|
||||||
|
// Si el el asiento está vendido pintarlo de color rojo
|
||||||
|
if(estado.equals("vendido")){
|
||||||
|
//botonAsiento.setEnabled(false);
|
||||||
|
botonAsiento.setBackground(Color.RED);
|
||||||
|
botonAsiento.setForeground(Color.WHITE);
|
||||||
|
} else {// Si el asiento no está vendido pintarlo de color verde
|
||||||
|
botonAsiento.setBackground(Color.GREEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
botonAsiento.addItemListener(this);
|
||||||
|
|
||||||
|
menuSala.jPanelBotones.add(botonAsiento);// Añadir botón al JPanel de MenuSala
|
||||||
|
|
||||||
|
ejeX += 160;// Actualizar posición vertical del siguiente botón
|
||||||
|
numeroAsiento++;
|
||||||
|
|
||||||
|
// Si da igual a 0, significa que el siguiente botón debe ir en la siguiente fila
|
||||||
|
if (numeroAsiento % columnas == 0) {
|
||||||
|
ejeY += 70;// Ajustar posición horizontal para la siguiente fila
|
||||||
|
ejeX = 20;// Ajustar posición vertical ya que es una nueva fila
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
System.out.println("[X] controller.MenuSalaController.obtenerAsientos(): error " + ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e){
|
||||||
|
Object o = e.getSource();
|
||||||
|
|
||||||
|
// Si se presiono el boton para seleccionar asientos para una venta
|
||||||
|
if(o.equals(menuSala.jButtonSeleccionarAsientosVenta)){
|
||||||
|
if (!clickAsientosHabilitado){// Si la selección de asientos está bloqueada
|
||||||
|
clickAsientosHabilitado = true;// Permitir la selección de asientos
|
||||||
|
menuSala.jButtonRealizarVenta.setEnabled(true);
|
||||||
|
menuSala.jPanelBotones.setBackground(Color.decode("#d7f1ce"));
|
||||||
|
menuSala.jButtonSeleccionarAsientosVenta.setBackground(Color.YELLOW);
|
||||||
|
} else {
|
||||||
|
menuSala.jPanelBotones.removeAll();
|
||||||
|
menuSala.revalidate();
|
||||||
|
menuSala.repaint();
|
||||||
|
obtenerAsientos(idEvento);
|
||||||
|
clickAsientosHabilitado = false;
|
||||||
|
menuSala.jButtonRealizarVenta.setEnabled(false);
|
||||||
|
menuSala.jPanelBotones.setBackground(Color.decode("#F6F6F6"));
|
||||||
|
menuSala.jButtonSeleccionarAsientosVenta.setBackground(Color.WHITE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si se presiono el botón realizar venta
|
||||||
|
if(o.equals(menuSala.jButtonRealizarVenta)){
|
||||||
|
// Verificar que se seleccionó por lo menos un asiento
|
||||||
|
if (!arrayListAsientosSeleccionados.isEmpty()) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
menuSala.mensaje("No ha seleccionado ningún asiento.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void itemStateChanged(ItemEvent e){
|
||||||
|
Object componente = e.getSource();
|
||||||
|
if (componente instanceof JToggleButton) {// Si el evento es un botón de asiento
|
||||||
|
JToggleButton botonAsiento = (JToggleButton) componente;// Obtener botón
|
||||||
|
|
||||||
|
String estado = (String) botonAsiento.getClientProperty("estado");// Obtener estado del asiento
|
||||||
|
|
||||||
|
// Si no está habilitada la modificación de asientos (o si el botón está vendo), revertir el cambio de estado
|
||||||
|
if (!clickAsientosHabilitado || estado.equals("vendido")) {
|
||||||
|
botonAsiento.removeItemListener(this);// Remover temporalmente el listener para evitar ciclos infinitos
|
||||||
|
botonAsiento.setSelected(!botonAsiento.isSelected());// Revertir el cambio de estado
|
||||||
|
botonAsiento.addItemListener(this);// Volver a agregar el listener
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Asiento asiento = (Asiento) botonAsiento.getClientProperty("asiento");// Obtener el objeto asiento que estaba dentro del botón
|
||||||
|
int idAsiento = (int) botonAsiento.getClientProperty("idAsiento");
|
||||||
|
|
||||||
|
// Si el botón se ha seleccionado
|
||||||
|
if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||||
|
arrayListAsientosSeleccionados.add(botonAsiento);
|
||||||
|
System.out.println("controller.MenuSalaController.itemStateChanged(): " + asiento.getFila() + "" + asiento.getNumero() + " añadido a arrayListAsientosSeleccionados");
|
||||||
|
System.out.println("controller.MenuSalaController.itemStateChanged(): " + asiento.getFila() + asiento.getNumero() + " seleccionado.");
|
||||||
|
botonAsiento.setBackground(Color.YELLOW);
|
||||||
|
botonAsiento.setForeground(Color.WHITE);
|
||||||
|
|
||||||
|
} else if (e.getStateChange() == ItemEvent.DESELECTED) {// Si el botón se ha deseleccionado
|
||||||
|
if(arrayListAsientosSeleccionados.contains(botonAsiento)){
|
||||||
|
arrayListAsientosSeleccionados.remove(botonAsiento);
|
||||||
|
System.out.println("controller.MenuSalaController.itemStateChanged(): " + asiento.getFila() + "" + asiento.getNumero() + " eliminado de arrayListAsientosSeleccionados");
|
||||||
|
}
|
||||||
|
System.out.println("controller.MenuSalaController.itemStateChanged(): " + asiento.getFila() + asiento.getNumero() + " deseleccionado.");
|
||||||
|
botonAsiento.setBackground(Color.GREEN);
|
||||||
|
botonAsiento.setForeground(Color.BLACK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void realizarVenta(ArrayList<JToggleButton> arrayBotones){
|
||||||
|
ArrayList<Asiento> arrayAsientos = new ArrayList<>();
|
||||||
|
for(JToggleButton boton: arrayBotones){
|
||||||
|
Asiento asiento = (Asiento) boton.getClientProperty("asiento");
|
||||||
|
arrayAsientos.add(asiento);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,14 +1,16 @@
|
||||||
package model;
|
package model;
|
||||||
|
|
||||||
public class Asiento {
|
public class Asiento {
|
||||||
private String idEvento;
|
private int idAsiento;
|
||||||
private String fila;
|
private String fila;
|
||||||
private int numero;
|
private int numero;
|
||||||
|
|
||||||
public void setIdEvento(String idEvento) {
|
|
||||||
this.idEvento = idEvento;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public Asiento(int idAsiento, String fila, int numero) {
|
||||||
|
this.idAsiento = idAsiento;
|
||||||
|
this.fila = fila;
|
||||||
|
this.numero = numero;
|
||||||
|
}
|
||||||
|
|
||||||
public void setFila(String fila) {
|
public void setFila(String fila) {
|
||||||
this.fila = fila;
|
this.fila = fila;
|
||||||
}
|
}
|
||||||
|
@ -17,10 +19,6 @@ public class Asiento {
|
||||||
this.numero = numero;
|
this.numero = numero;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdEvento() {
|
|
||||||
return idEvento;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFila() {
|
public String getFila() {
|
||||||
return fila;
|
return fila;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,17 +8,13 @@ public class Boleto {
|
||||||
private int idAsiento;
|
private int idAsiento;
|
||||||
private double precio;
|
private double precio;
|
||||||
private String estado;
|
private String estado;
|
||||||
private LocalDateTime fechaVenta;
|
|
||||||
private Integer idVenta;
|
private Integer idVenta;
|
||||||
|
|
||||||
public Boleto(int idBoleto, int idEvento, int idAsiento, double precio, String estado, LocalDateTime fechaVenta, Integer idVenta) {
|
public Boleto(int idEvento, int idAsiento, double precio) {
|
||||||
this.idBoleto = idBoleto;
|
|
||||||
this.idEvento = idEvento;
|
this.idEvento = idEvento;
|
||||||
this.idAsiento = idAsiento;
|
this.idAsiento = idAsiento;
|
||||||
this.precio = precio;
|
this.precio = precio;
|
||||||
this.estado = estado;
|
this.estado = "vendido";
|
||||||
this.fechaVenta = fechaVenta;
|
|
||||||
this.idVenta = idVenta;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIdBoleto(int idBoleto) {
|
public void setIdBoleto(int idBoleto) {
|
||||||
|
@ -41,10 +37,6 @@ public class Boleto {
|
||||||
this.estado = estado;
|
this.estado = estado;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFechaVenta(LocalDateTime fechaVenta) {
|
|
||||||
this.fechaVenta = fechaVenta;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIdVenta(Integer idVenta) {
|
public void setIdVenta(Integer idVenta) {
|
||||||
this.idVenta = idVenta;
|
this.idVenta = idVenta;
|
||||||
}
|
}
|
||||||
|
@ -69,13 +61,7 @@ public class Boleto {
|
||||||
return estado;
|
return estado;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDateTime getFechaVenta() {
|
|
||||||
return fechaVenta;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getIdVenta() {
|
public Integer getIdVenta() {
|
||||||
return idVenta;
|
return idVenta;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Método para cambiar estado venderBoleto() que establezca estado, fechaVenta e idVenta.
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
package model;
|
package model;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.sql.Date;
|
||||||
|
|
||||||
public class Evento {
|
public class Evento {
|
||||||
private int idEvento;
|
private int idEvento;
|
||||||
private String nombre;
|
private String nombre;
|
||||||
private LocalDate fecha;
|
private Date fecha;
|
||||||
|
|
||||||
|
public Evento(int idEvento, String nombre, Date fecha){
|
||||||
|
this.idEvento = idEvento;
|
||||||
|
this.nombre = nombre;
|
||||||
|
this.fecha = fecha;
|
||||||
|
}
|
||||||
|
|
||||||
public void setIdEvento(int idEvento) {
|
public void setIdEvento(int idEvento) {
|
||||||
this.idEvento = idEvento;
|
this.idEvento = idEvento;
|
||||||
|
@ -15,7 +21,7 @@ public class Evento {
|
||||||
this.nombre = nombre;
|
this.nombre = nombre;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFecha(LocalDate fecha) {
|
public void setFecha(Date fecha) {
|
||||||
this.fecha = fecha;
|
this.fecha = fecha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +33,7 @@ public class Evento {
|
||||||
return nombre;
|
return nombre;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDate getFecha() {
|
public Date getFecha() {
|
||||||
return fecha;
|
return fecha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,9 @@ public class ModeloSQL {
|
||||||
// Eventos
|
// Eventos
|
||||||
public ResultSet obtenerEventos(){
|
public ResultSet obtenerEventos(){
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
|
String consulta = "SELECT * FROM eventos";
|
||||||
try {
|
try {
|
||||||
Statement st = con.createStatement();
|
Statement st = con.createStatement();
|
||||||
String consulta = "SELECT * FROM eventos";
|
|
||||||
rs = st.executeQuery(consulta);
|
rs = st.executeQuery(consulta);
|
||||||
System.out.println("ModeloSQL.obtenerEventos(): eventos obtenidos.");
|
System.out.println("ModeloSQL.obtenerEventos(): eventos obtenidos.");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
@ -25,7 +25,55 @@ public class ModeloSQL {
|
||||||
return rs;
|
return rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Asientos
|
||||||
|
public ResultSet obtenerAsientosDisponibles(int idEvento){
|
||||||
|
ResultSet rs = null;
|
||||||
|
String consulta = "SELECT a.idAsiento, a.fila, a.numero, IFNULL(b.estado, 'disponible') AS estado " +
|
||||||
|
"FROM asientos a " +
|
||||||
|
"LEFT JOIN boletos b ON a.idAsiento = b.idAsiento AND b.idEvento = "+idEvento+"";
|
||||||
|
try {
|
||||||
|
Statement st = con.createStatement();
|
||||||
|
rs = st.executeQuery(consulta);
|
||||||
|
System.out.println("ModeloSQL.obtenerAsientosDisponibles: asientos obtenidos.");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
}
|
||||||
|
return rs;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Venta
|
||||||
|
public void registrarVenta(int idEvento, int totalBoletos, Double totalMonto){
|
||||||
|
String sql = "INSERT INTO ventas (idEvento, fechaVenta, totalBoletos, totalMonto) VALUES (?, NOW(), ?, ?)";
|
||||||
|
PreparedStatement pst = null;
|
||||||
|
try {
|
||||||
|
pst = con.prepareStatement(sql);
|
||||||
|
pst.setInt(1, idEvento);
|
||||||
|
pst.setInt(2, totalBoletos);
|
||||||
|
pst.setDouble(3, totalMonto);
|
||||||
|
pst.executeUpdate();
|
||||||
|
pst.close();
|
||||||
|
System.out.println("model.ModeloSQL.crearVenta(): venta registrada.");
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
System.out.println("[X] model.ModeloSQL.crearVenta(): " + ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Boleto
|
// Boleto
|
||||||
|
public void registrarBoleto(int idEvento, int idAsiento, double precio, int idVenta){
|
||||||
|
String sql = "INSERT INTO boletos (idEvento, idAsiento, precio, idVenta) VALUES (?, ?, ?, ?)";
|
||||||
|
PreparedStatement pst = null;
|
||||||
|
try {
|
||||||
|
pst = con.prepareStatement(sql);
|
||||||
|
pst.setInt(1, idEvento);
|
||||||
|
pst.setInt(2, idAsiento);
|
||||||
|
pst.setDouble(3, precio);
|
||||||
|
pst.setInt(4, idVenta);
|
||||||
|
pst.executeUpdate();
|
||||||
|
pst.close();
|
||||||
|
System.out.println("model.ModeloSQL.registrarBoleto(): boleto registrado.");
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
System.out.println("[X] model.ModeloSQL.registrarBoleto(): " + ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public ResultSet obtenerBoletosPorEvento(int idEvento){
|
public ResultSet obtenerBoletosPorEvento(int idEvento){
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
package model;
|
package model;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import javax.swing.JToggleButton;
|
||||||
|
|
||||||
public class Venta {
|
public class Venta {
|
||||||
private int idVenta;
|
private int idVenta;
|
||||||
private int idEvento;
|
private int idEvento;
|
||||||
private LocalDateTime fechaVenta;
|
private LocalDateTime fechaVenta;
|
||||||
private String vendedor;
|
private int totalBoletos;
|
||||||
private List<Boleto> boletos;
|
private int totalMonto;
|
||||||
|
private ArrayList<JToggleButton> asientosVenta;
|
||||||
|
|
||||||
public void setIdVenta(int idVenta) {
|
public void setIdVenta(int idVenta) {
|
||||||
this.idVenta = idVenta;
|
this.idVenta = idVenta;
|
||||||
|
@ -22,14 +25,18 @@ public class Venta {
|
||||||
this.fechaVenta = fechaVenta;
|
this.fechaVenta = fechaVenta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBoletos(List<Boleto> boletos) {
|
public void setTotalBoletos(int totalBoletos) {
|
||||||
this.boletos = boletos;
|
this.totalBoletos = totalBoletos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVendedor(String vendedor) {
|
public void setTotalMonto(int totalMonto) {
|
||||||
this.vendedor = vendedor;
|
this.totalMonto = totalMonto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAsientosVenta(ArrayList<JToggleButton> asientosVenta) {
|
||||||
|
this.asientosVenta = asientosVenta;
|
||||||
|
}
|
||||||
|
|
||||||
public int getIdVenta() {
|
public int getIdVenta() {
|
||||||
return idVenta;
|
return idVenta;
|
||||||
}
|
}
|
||||||
|
@ -42,14 +49,16 @@ public class Venta {
|
||||||
return fechaVenta;
|
return fechaVenta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVendedor() {
|
public int getTotalBoletos() {
|
||||||
return vendedor;
|
return totalBoletos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Boleto> getBoletos() {
|
public int getTotalMonto() {
|
||||||
return boletos;
|
return totalMonto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<JToggleButton> getAsientosVenta() {
|
||||||
|
return asientosVenta;
|
||||||
}
|
}
|
||||||
|
|
||||||
// métodos para agregar boletos, calcular total, etc.
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
<Property name="location" type="java.awt.Point" editor="org.netbeans.beaninfo.editors.PointEditor">
|
<Property name="location" type="java.awt.Point" editor="org.netbeans.beaninfo.editors.PointEditor">
|
||||||
<Point value="[0, 0]"/>
|
<Point value="[0, 0]"/>
|
||||||
</Property>
|
</Property>
|
||||||
|
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||||
|
<Dimension value="[1180, 650]"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="resizable" type="boolean" value="false"/>
|
||||||
<Property name="size" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
<Property name="size" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||||
<Dimension value="[0, 0]"/>
|
<Dimension value="[0, 0]"/>
|
||||||
</Property>
|
</Property>
|
||||||
|
@ -35,31 +39,28 @@
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Component id="jPanelMenuSala" max="32767" attributes="0"/>
|
||||||
<Component id="jPanelMenuSala" max="32767" attributes="0"/>
|
|
||||||
<Group type="102" attributes="0">
|
|
||||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
|
||||||
<Component id="jComboBoxEventos" min="-2" pref="170" max="-2" attributes="0"/>
|
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
|
||||||
<Component id="jButtonVisualizar" min="-2" max="-2" attributes="0"/>
|
|
||||||
<EmptySpace min="0" pref="316" max="32767" attributes="0"/>
|
|
||||||
</Group>
|
|
||||||
</Group>
|
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<EmptySpace min="-2" pref="349" max="-2" attributes="0"/>
|
||||||
|
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="jComboBoxEventos" min="-2" pref="170" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="jButtonVisualizar" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
<Group type="103" groupAlignment="3" attributes="0">
|
<Component id="jComboBoxEventos" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
<Component id="jComboBoxEventos" alignment="3" max="32767" attributes="0"/>
|
<Component id="jButtonVisualizar" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
<Component id="jButtonVisualizar" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="jLabel1" alignment="3" max="32767" attributes="0"/>
|
||||||
</Group>
|
|
||||||
<Component id="jLabel1" max="32767" attributes="0"/>
|
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jPanelMenuSala" max="32767" attributes="0"/>
|
<Component id="jPanelMenuSala" max="32767" attributes="0"/>
|
||||||
|
@ -71,9 +72,6 @@
|
||||||
<SubComponents>
|
<SubComponents>
|
||||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
|
||||||
<Font name="Gill Sans MT" size="14" style="0"/>
|
|
||||||
</Property>
|
|
||||||
<Property name="text" type="java.lang.String" value="Seleccione un evento:"/>
|
<Property name="text" type="java.lang.String" value="Seleccione un evento:"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
|
@ -97,11 +95,6 @@
|
||||||
</AuxValues>
|
</AuxValues>
|
||||||
</Component>
|
</Component>
|
||||||
<Container class="javax.swing.JPanel" name="jPanelMenuSala">
|
<Container class="javax.swing.JPanel" name="jPanelMenuSala">
|
||||||
<Properties>
|
|
||||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
|
||||||
<Color blue="fd" green="fa" red="f8" type="rgb"/>
|
|
||||||
</Property>
|
|
||||||
</Properties>
|
|
||||||
<AuxValues>
|
<AuxValues>
|
||||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
|
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
|
||||||
</AuxValues>
|
</AuxValues>
|
||||||
|
@ -109,7 +102,7 @@
|
||||||
<Layout>
|
<Layout>
|
||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
<EmptySpace min="0" pref="1168" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
|
|
|
@ -3,6 +3,7 @@ package view;
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import controller.MenuController;
|
import controller.MenuController;
|
||||||
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.DefaultComboBoxModel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
public class Menu extends javax.swing.JFrame {
|
public class Menu extends javax.swing.JFrame {
|
||||||
|
|
||||||
|
@ -17,9 +18,14 @@ public class Menu extends javax.swing.JFrame {
|
||||||
|
|
||||||
MenuController menuController = new MenuController(this);
|
MenuController menuController = new MenuController(this);
|
||||||
this.jButtonVisualizar.addActionListener(menuController);
|
this.jButtonVisualizar.addActionListener(menuController);
|
||||||
|
this.jComboBoxEventos.addItemListener(menuController);
|
||||||
addWindowListener(menuController);
|
addWindowListener(menuController);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void mensaje(String mensaje){
|
||||||
|
JOptionPane.showMessageDialog(this, mensaje);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
@ -33,22 +39,21 @@ public class Menu extends javax.swing.JFrame {
|
||||||
setTitle("Aplicación de venta de boletos");
|
setTitle("Aplicación de venta de boletos");
|
||||||
setBackground(new java.awt.Color(255, 255, 255));
|
setBackground(new java.awt.Color(255, 255, 255));
|
||||||
setLocation(new java.awt.Point(0, 0));
|
setLocation(new java.awt.Point(0, 0));
|
||||||
|
setPreferredSize(new java.awt.Dimension(1180, 650));
|
||||||
|
setResizable(false);
|
||||||
setSize(new java.awt.Dimension(0, 0));
|
setSize(new java.awt.Dimension(0, 0));
|
||||||
|
|
||||||
jLabel1.setFont(new java.awt.Font("Gill Sans MT", 0, 14)); // NOI18N
|
|
||||||
jLabel1.setText("Seleccione un evento:");
|
jLabel1.setText("Seleccione un evento:");
|
||||||
|
|
||||||
jComboBoxEventos.setModel(defaultComboBoxModel);
|
jComboBoxEventos.setModel(defaultComboBoxModel);
|
||||||
|
|
||||||
jButtonVisualizar.setText("Visualizar");
|
jButtonVisualizar.setText("Visualizar");
|
||||||
|
|
||||||
jPanelMenuSala.setBackground(new java.awt.Color(248, 250, 253));
|
|
||||||
|
|
||||||
javax.swing.GroupLayout jPanelMenuSalaLayout = new javax.swing.GroupLayout(jPanelMenuSala);
|
javax.swing.GroupLayout jPanelMenuSalaLayout = new javax.swing.GroupLayout(jPanelMenuSala);
|
||||||
jPanelMenuSala.setLayout(jPanelMenuSalaLayout);
|
jPanelMenuSala.setLayout(jPanelMenuSalaLayout);
|
||||||
jPanelMenuSalaLayout.setHorizontalGroup(
|
jPanelMenuSalaLayout.setHorizontalGroup(
|
||||||
jPanelMenuSalaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanelMenuSalaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGap(0, 0, Short.MAX_VALUE)
|
.addGap(0, 1168, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
jPanelMenuSalaLayout.setVerticalGroup(
|
jPanelMenuSalaLayout.setVerticalGroup(
|
||||||
jPanelMenuSalaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanelMenuSalaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
@ -61,25 +66,24 @@ public class Menu extends javax.swing.JFrame {
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addComponent(jPanelMenuSala, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(jPanelMenuSala, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
|
||||||
.addComponent(jLabel1)
|
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
||||||
.addComponent(jComboBoxEventos, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
||||||
.addComponent(jButtonVisualizar)
|
|
||||||
.addGap(0, 316, Short.MAX_VALUE)))
|
|
||||||
.addContainerGap())
|
.addContainerGap())
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addGap(349, 349, 349)
|
||||||
|
.addComponent(jLabel1)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(jComboBoxEventos, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(jButtonVisualizar)
|
||||||
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addComponent(jComboBoxEventos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(jComboBoxEventos)
|
.addComponent(jButtonVisualizar)
|
||||||
.addComponent(jButtonVisualizar))
|
|
||||||
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(jPanelMenuSala, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(jPanelMenuSala, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
@ -88,7 +92,8 @@ public class Menu extends javax.swing.JFrame {
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
public javax.swing.JButton jButtonVisualizar;
|
public javax.swing.JButton jButtonVisualizar;
|
||||||
public javax.swing.JComboBox<String> jComboBoxEventos;
|
public javax.swing.JComboBox<String> jComboBoxEventos;
|
||||||
|
|
|
@ -39,11 +39,9 @@
|
||||||
</Layout>
|
</Layout>
|
||||||
<SubComponents>
|
<SubComponents>
|
||||||
<Container class="javax.swing.JPanel" name="jPanelBotones">
|
<Container class="javax.swing.JPanel" name="jPanelBotones">
|
||||||
<Properties>
|
<AuxValues>
|
||||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
|
||||||
<Color blue="ff" green="ff" red="ff" type="rgb"/>
|
</AuxValues>
|
||||||
</Property>
|
|
||||||
</Properties>
|
|
||||||
|
|
||||||
<Layout>
|
<Layout>
|
||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
|
@ -60,9 +58,6 @@
|
||||||
</Container>
|
</Container>
|
||||||
<Container class="javax.swing.JPanel" name="jPanel2">
|
<Container class="javax.swing.JPanel" name="jPanel2">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
|
||||||
<Color blue="fd" green="fa" red="f8" type="rgb"/>
|
|
||||||
</Property>
|
|
||||||
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||||
<Color blue="0" green="0" red="0" type="rgb"/>
|
<Color blue="0" green="0" red="0" type="rgb"/>
|
||||||
</Property>
|
</Property>
|
||||||
|
@ -71,19 +66,27 @@
|
||||||
<Layout>
|
<Layout>
|
||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" attributes="0">
|
||||||
<EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||||
<EmptySpace pref="585" max="32767" attributes="0"/>
|
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="jButtonSeleccionarAsientosVenta" alignment="0" max="32767" attributes="0"/>
|
||||||
|
<Component id="jButtonRealizarVenta" alignment="0" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace pref="444" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace pref="64" max="32767" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="jButtonSeleccionarAsientosVenta" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="jButtonRealizarVenta" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace pref="12" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
|
@ -91,9 +94,28 @@
|
||||||
<SubComponents>
|
<SubComponents>
|
||||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="text" type="java.lang.String" value="jLabel1"/>
|
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||||
|
<Connection code=""Concierto: " + nombre" type="code"/>
|
||||||
|
</Property>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="jButtonSeleccionarAsientosVenta">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Seleccionar asientos para venta"/>
|
||||||
|
</Properties>
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
|
||||||
|
</AuxValues>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="jButtonRealizarVenta">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Realizar venta"/>
|
||||||
|
<Property name="enabled" type="boolean" value="false"/>
|
||||||
|
</Properties>
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
|
||||||
|
</AuxValues>
|
||||||
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Container>
|
</Container>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
|
|
|
@ -1,42 +1,50 @@
|
||||||
/*
|
|
||||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
|
||||||
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JPanel.java to edit this template
|
|
||||||
*/
|
|
||||||
package view;
|
package view;
|
||||||
|
|
||||||
|
import controller.MenuSalaController;
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JToggleButton;
|
import javax.swing.JToggleButton;
|
||||||
|
import model.Boleto;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author vmonge
|
|
||||||
*/
|
|
||||||
public class MenuSala extends javax.swing.JPanel {
|
public class MenuSala extends javax.swing.JPanel {
|
||||||
|
|
||||||
/**
|
private int idEvento;
|
||||||
* Creates new form MenuSala
|
private String nombre;
|
||||||
*/
|
|
||||||
public MenuSala() {
|
public MenuSala(int idEvento, String nombre) {
|
||||||
|
this.idEvento = idEvento;
|
||||||
|
this.nombre = nombre;
|
||||||
initComponents();
|
initComponents();
|
||||||
asientos();
|
//asientos();
|
||||||
|
MenuSalaController menuSalaController = new MenuSalaController(this);
|
||||||
|
jButtonSeleccionarAsientosVenta.addActionListener(menuSalaController);
|
||||||
|
jButtonRealizarVenta.addActionListener(menuSalaController);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int filas = 5;
|
/*
|
||||||
private int columnas = 5;
|
private int filas = 6;
|
||||||
|
private int columnas = 7;
|
||||||
private int largoBoton = 140;
|
private int largoBoton = 140;
|
||||||
private int anchoBoton = 60;
|
private int anchoBoton = 60;
|
||||||
private int ejeX = 20;
|
private int ejeX = 20;
|
||||||
private int ejeY = 20;
|
private int ejeY = 20;
|
||||||
public JToggleButton jtBotones[][];
|
public JToggleButton jtBotones[][];
|
||||||
int numeroAsientos = 0;
|
private ArrayList<Boleto> boletosVendidos = new ArrayList<>();
|
||||||
|
int contadorNumeroAsientos = 0;
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
public void asientos(){
|
public void asientos(){
|
||||||
jtBotones = new JToggleButton[filas][columnas];
|
jtBotones = new JToggleButton[filas][columnas];
|
||||||
for(int i = 0; i < filas; i++){
|
for(int i = 0; i < filas; i++){
|
||||||
for(int j = 0; j < columnas; j++){
|
for(int j = 0; j < columnas; j++){
|
||||||
jtBotones[i][j] = new JToggleButton();
|
jtBotones[i][j] = new JToggleButton();
|
||||||
numeroAsientos++;
|
contadorNumeroAsientos++;
|
||||||
jtBotones[i][j].setBounds(ejeX, ejeY, largoBoton, anchoBoton);
|
jtBotones[i][j].setBounds(ejeX, ejeY, largoBoton, anchoBoton);
|
||||||
jtBotones[i][j].setText("Asiento: " + numeroAsientos);
|
jtBotones[i][j].setText("Asiento: " + contadorNumeroAsientos);
|
||||||
jPanelBotones.add(jtBotones[i][j]);
|
jPanelBotones.add(jtBotones[i][j]);
|
||||||
ejeX += 160;
|
ejeX += 160;
|
||||||
|
|
||||||
|
@ -48,12 +56,16 @@ public class MenuSala extends javax.swing.JPanel {
|
||||||
ejeX = 20;
|
ejeX = 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
public int getIdEvento() {
|
||||||
* This method is called from within the constructor to initialize the form.
|
return idEvento;
|
||||||
* WARNING: Do NOT modify this code. The content of this method is always
|
}
|
||||||
* regenerated by the Form Editor.
|
|
||||||
*/
|
public void mensaje(String mensaje){
|
||||||
|
JOptionPane.showMessageDialog(this, mensaje);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
@ -61,8 +73,8 @@ public class MenuSala extends javax.swing.JPanel {
|
||||||
jPanelBotones = new javax.swing.JPanel();
|
jPanelBotones = new javax.swing.JPanel();
|
||||||
jPanel2 = new javax.swing.JPanel();
|
jPanel2 = new javax.swing.JPanel();
|
||||||
jLabel1 = new javax.swing.JLabel();
|
jLabel1 = new javax.swing.JLabel();
|
||||||
|
jButtonSeleccionarAsientosVenta = new javax.swing.JButton();
|
||||||
jPanelBotones.setBackground(new java.awt.Color(255, 255, 255));
|
jButtonRealizarVenta = new javax.swing.JButton();
|
||||||
|
|
||||||
javax.swing.GroupLayout jPanelBotonesLayout = new javax.swing.GroupLayout(jPanelBotones);
|
javax.swing.GroupLayout jPanelBotonesLayout = new javax.swing.GroupLayout(jPanelBotones);
|
||||||
jPanelBotones.setLayout(jPanelBotonesLayout);
|
jPanelBotones.setLayout(jPanelBotonesLayout);
|
||||||
|
@ -75,26 +87,37 @@ public class MenuSala extends javax.swing.JPanel {
|
||||||
.addGap(0, 448, Short.MAX_VALUE)
|
.addGap(0, 448, Short.MAX_VALUE)
|
||||||
);
|
);
|
||||||
|
|
||||||
jPanel2.setBackground(new java.awt.Color(248, 250, 253));
|
|
||||||
jPanel2.setForeground(new java.awt.Color(0, 0, 0));
|
jPanel2.setForeground(new java.awt.Color(0, 0, 0));
|
||||||
|
|
||||||
jLabel1.setText("jLabel1");
|
jLabel1.setText("Concierto: " + nombre);
|
||||||
|
|
||||||
|
jButtonSeleccionarAsientosVenta.setText("Seleccionar asientos para venta");
|
||||||
|
|
||||||
|
jButtonRealizarVenta.setText("Realizar venta");
|
||||||
|
jButtonRealizarVenta.setEnabled(false);
|
||||||
|
|
||||||
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
|
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
|
||||||
jPanel2.setLayout(jPanel2Layout);
|
jPanel2.setLayout(jPanel2Layout);
|
||||||
jPanel2Layout.setHorizontalGroup(
|
jPanel2Layout.setHorizontalGroup(
|
||||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||||
.addGap(28, 28, 28)
|
.addContainerGap()
|
||||||
.addComponent(jLabel1)
|
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||||
.addContainerGap(585, Short.MAX_VALUE))
|
.addComponent(jLabel1)
|
||||||
|
.addComponent(jButtonSeleccionarAsientosVenta, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(jButtonRealizarVenta, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
|
.addContainerGap(444, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
jPanel2Layout.setVerticalGroup(
|
jPanel2Layout.setVerticalGroup(
|
||||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||||
.addGap(20, 20, 20)
|
.addContainerGap()
|
||||||
.addComponent(jLabel1)
|
.addComponent(jLabel1)
|
||||||
.addContainerGap(64, Short.MAX_VALUE))
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(jButtonSeleccionarAsientosVenta)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(jButtonRealizarVenta)
|
||||||
|
.addContainerGap(12, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
|
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
|
@ -120,8 +143,10 @@ public class MenuSala extends javax.swing.JPanel {
|
||||||
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
public javax.swing.JButton jButtonRealizarVenta;
|
||||||
|
public javax.swing.JButton jButtonSeleccionarAsientosVenta;
|
||||||
private javax.swing.JLabel jLabel1;
|
private javax.swing.JLabel jLabel1;
|
||||||
private javax.swing.JPanel jPanel2;
|
private javax.swing.JPanel jPanel2;
|
||||||
private javax.swing.JPanel jPanelBotones;
|
public javax.swing.JPanel jPanelBotones;
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue