Skip to content

Commit

Permalink
Change Vestimeta and Reserva in combobox
Browse files Browse the repository at this point in the history
  • Loading branch information
jesuj committed Dec 30, 2021
1 parent f6e3ec5 commit da4e310
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 36 deletions.
Binary file modified build/classes/Presentacion/PEmpleado.class
Binary file not shown.
2 changes: 1 addition & 1 deletion build/classes/Presentacion/PEmpleado.form
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<Font name="Tahoma" size="24" style="0"/>
</Property>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="Cliente"/>
<Property name="text" type="java.lang.String" value="Empleado"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
Expand Down
Binary file modified build/classes/Presentacion/PReserva$11.class
Binary file not shown.
Binary file modified build/classes/Presentacion/PReserva.class
Binary file not shown.
Binary file modified build/classes/Presentacion/PVestimenta$11.class
Binary file not shown.
Binary file modified build/classes/Presentacion/PVestimenta.class
Binary file not shown.
8 changes: 1 addition & 7 deletions nbproject/private/private.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/D:/Semestre/Final/Arquitectura%20de%20software/Proyecto/AlquilajeTraje/src/Negocio/NVestimenta.java</file>
<file>file:/D:/Semestre/Final/Arquitectura%20de%20software/Proyecto/AlquilajeTraje/src/Presentacion/PVestimenta.java</file>
<file>file:/D:/Semestre/Final/Arquitectura%20de%20software/Proyecto/AlquilajeTraje/src/Negocio/NDetallePrenda.java</file>
<file>file:/D:/Semestre/Final/Arquitectura%20de%20software/Proyecto/AlquilajeTraje/src/Datos/DVestimenta.java</file>
<file>file:/D:/Semestre/Final/Arquitectura%20de%20software/Proyecto/AlquilajeTraje/src/Datos/DDetallePrenda.java</file>
</group>
<group/>
</open-files>
</project-private>
2 changes: 1 addition & 1 deletion src/Presentacion/PEmpleado.form
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<Font name="Tahoma" size="24" style="0"/>
</Property>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="Cliente"/>
<Property name="text" type="java.lang.String" value="Empleado"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
Expand Down
4 changes: 2 additions & 2 deletions src/Presentacion/PEmpleado.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class PEmpleado extends javax.swing.JFrame {
private String telefono;
private String fecha_nacimiento;
private String sexo;
private String direccion;


private NEmpleado nempleado;

Expand Down Expand Up @@ -78,7 +78,7 @@ private void initComponents() {

jLabel1.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Cliente");
jLabel1.setText("Empleado");
jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 10, 740, -1));

jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
Expand Down
94 changes: 72 additions & 22 deletions src/Presentacion/PReserva.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public class PReserva extends javax.swing.JFrame {
private String fechaInicio;
private String fechaFin;
private boolean estado;

private int id_cliente;

private NCliente ncliente;

private NVestimenta nvestimenta;

private NReserva nreserva;
private ArrayList<Object[]> agregardetalleReserva;
private ArrayList<Object[]> eliminardetalleReserva;
Expand All @@ -46,10 +46,10 @@ public PReserva() {
initComponents();
this.jtf_id.setEditable(false);
this.jtf_id.setEnabled(false);

this.ncliente = new NCliente();
this.nvestimenta = new NVestimenta();

this.nreserva = new NReserva();

this.cargarCliente();
Expand Down Expand Up @@ -302,6 +302,7 @@ private void jLabel5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:eve
this.apagarbotonCrear(true);
String[] column = {"prenda", "stock", "color"};
this.jt_listar_vestimenta.setModel(new DefaultTableModel(null, column));
this.cargarVestimenta();
}//GEN-LAST:event_jLabel5MouseClicked

private void jtf_garantiaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_garantiaActionPerformed
Expand Down Expand Up @@ -351,25 +352,25 @@ private void jt_listar_reservaMouseClicked(java.awt.event.MouseEvent evt) {//GEN
this.clearLista();

int rowSelected = this.jt_listar_reserva.getSelectedRow();

this.jtf_id.setText(this.jt_listar_reserva.getValueAt(rowSelected, 0).toString());
this.jcb_cliente.setSelectedItem(this.jt_listar_reserva.getValueAt(rowSelected, 1).toString());
this.jtf_titulo.setText(this.jt_listar_reserva.getValueAt(rowSelected, 2).toString());
this.jtf_garantia.setText(this.jt_listar_reserva.getValueAt(rowSelected, 3).toString());
String fechaInicio =this.jt_listar_reserva.getValueAt(rowSelected, 4).toString();
String fechaFin =this.jt_listar_reserva.getValueAt(rowSelected, 5).toString();
String fechaInicio = this.jt_listar_reserva.getValueAt(rowSelected, 4).toString();
String fechaFin = this.jt_listar_reserva.getValueAt(rowSelected, 5).toString();
try {
this.jdc_fachaInicio.setDate(new SimpleDateFormat("yyyy-MM-dd").parse(fechaInicio));
this.jdc_fachaFin.setDate(new SimpleDateFormat("yyyy-MM-dd").parse(fechaFin));
} catch (ParseException ex) {
Logger.getLogger(PCliente.class.getName()).log(Level.SEVERE, null, ex);
}
this.jcb_estado.setSelectedIndex(getIndexEstado(this.jt_listar_reserva.getValueAt(rowSelected, 6).toString()));

this.apagarbotonCrear(false);

int id_vestimenta = (this.jtf_id.getText() == "") ? 0 : Integer.valueOf(this.jtf_id.getText());

listardetalleReserva(id_vestimenta);
}//GEN-LAST:event_jt_listar_reservaMouseClicked

Expand All @@ -378,7 +379,7 @@ private void jbt_agregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
Object[] agregar = {
this.jcb_vestimenta.getSelectedItem().toString(),
this.jsp_cantidad.getValue().toString()};

agregardetalleReserva.add(agregar);

int id_reserva = (this.jtf_id.getText().isEmpty()) ? 0 : Integer.valueOf(this.jtf_id.getText());
Expand Down Expand Up @@ -412,7 +413,7 @@ private boolean buscarEliminar(ArrayList<Object[]> lista, Object[] buscar) {
for (int i = 0; i < lista.size(); i++) {
String vestimenta = String.valueOf(lista.get(i)[0]);
String cantidad = String.valueOf(lista.get(i)[1]);
if (vestimentaBuscar == vestimenta && cantidadBuscar == cantidad ) {
if (vestimentaBuscar == vestimenta && cantidadBuscar == cantidad) {
lista.remove(i);
return true;
}
Expand All @@ -421,7 +422,7 @@ private boolean buscarEliminar(ArrayList<Object[]> lista, Object[] buscar) {
}

private void crear() {
if (this.nreserva.crear(this.id_cliente,this.titulo,this.garantia,this.fechaInicio,this.fechaFin,this.estado, this.agregardetalleReserva)) {
if (this.nreserva.crear(this.id_cliente, this.titulo, this.garantia, this.fechaInicio, this.fechaFin, this.estado, this.agregardetalleReserva)) {
JOptionPane.showMessageDialog(null, "Se Inserto Correctamente", "Crear", JOptionPane.INFORMATION_MESSAGE);
} else {
JOptionPane.showMessageDialog(null, "No se pudo Insertar", "Warning", JOptionPane.WARNING_MESSAGE);
Expand All @@ -441,7 +442,7 @@ private void eliminar() {
}

private void editar() {
if (this.nreserva.editar(this.id, this.id_cliente,this.titulo,this.garantia,this.fechaInicio,this.fechaFin,this.estado, agregardetalleReserva, eliminardetalleReserva)) {
if (this.nreserva.editar(this.id, this.id_cliente, this.titulo, this.garantia, this.fechaInicio, this.fechaFin, this.estado, agregardetalleReserva, eliminardetalleReserva)) {
JOptionPane.showMessageDialog(null, "Se Edito Correctamen", "Edicion", JOptionPane.INFORMATION_MESSAGE);
} else {
JOptionPane.showMessageDialog(null, "No se pudo Editar", "Warning", JOptionPane.WARNING_MESSAGE);
Expand All @@ -463,16 +464,27 @@ private void listar() {
data[i][5] = String.valueOf(reservas.get(i)[5]);
data[i][6] = String.valueOf(reservas.get(i)[6]);
}
String[] column = {"id", "cliente","titulo", "garantia", "fechaInicio", "fechaFin", "estado"};
String[] column = {"id", "cliente", "titulo", "garantia", "fechaInicio", "fechaFin", "estado"};
this.jt_listar_reserva.setModel(new DefaultTableModel(data, column));
}

public int indiceEliminar(String id, ArrayList<Object[]> lista) {
for (int i = 0; i < lista.size(); i++) {
if (id.equals(lista.get(i)[0].toString())) {
return i;
}
}
return -1;
}

private void listardetalleReserva(int id_reserva) {
ArrayList<Object[]> detalleReserva = new ArrayList<>();
detalleReserva = (id_reserva == 0) ? null : this.nreserva.listarDetalleReserva(id_reserva);
int cantidaddetalleprenda = (detalleReserva == null) ? 0 : detalleReserva.size();
int cantidadagregado = (agregardetalleReserva == null) ? 0 : agregardetalleReserva.size();

ActualizarVestimenta(cantidaddetalleprenda, detalleReserva);

int x = cantidaddetalleprenda + cantidadagregado;
System.out.println(x);

Expand All @@ -490,10 +502,45 @@ private void listardetalleReserva(int id_reserva) {
i++;
j++;
}
String[] column = {"prenda", "cantidad"};
String[] column = {"vestimenta", "cantidad"};
this.jt_listar_vestimenta.setModel(new DefaultTableModel(data, column));
}

private void ActualizarVestimenta(int cantidaddetalleprenda, ArrayList<Object[]> detalleReserva) {
ArrayList<Object[]> vestimentas = new ArrayList<>();
vestimentas = this.nvestimenta.listar();
if (cantidaddetalleprenda != 0) {
for (Object[] detalle : detalleReserva) {
String id = detalle[0].toString().split("-")[0];
int indiceAEliminar = indiceEliminar(id, vestimentas);
if (indiceAEliminar != -1) {
vestimentas.remove(indiceAEliminar);
}
}
}

for (Object[] agregar : agregardetalleReserva) {
String id = agregar[0].toString().split("-")[0];
int indiceAEliminar = indiceEliminar(id, vestimentas);
if (indiceAEliminar != -1) {
vestimentas.remove(indiceAEliminar);
}
}
this.jcb_vestimenta.removeAllItems();
if (vestimentas.isEmpty()) {
this.jbt_agregar.setEnabled(false);
this.jcb_vestimenta.setEnabled(false);
this.jsp_cantidad.setEnabled(false);
} else {
for (Object[] vestimenta : vestimentas) {
this.jcb_vestimenta.addItem(vestimenta[0] + "-" + vestimenta[1]);
}
this.jbt_agregar.setEnabled(true);
this.jcb_vestimenta.setEnabled(true);
this.jsp_cantidad.setEnabled(true);
}
}

private void cargarCliente() {
ArrayList<Object[]> clientes = new ArrayList<>();
clientes = this.ncliente.listar();
Expand All @@ -503,11 +550,15 @@ private void cargarCliente() {
}

private void cargarVestimenta() {
this.jcb_vestimenta.removeAllItems();
ArrayList<Object[]> vestimentas = new ArrayList<>();
vestimentas = this.nvestimenta.listar();
for (Object[] vestimenta : vestimentas) {
this.jcb_vestimenta.addItem(vestimenta[0] + "-" + vestimenta[1]);
}
this.jbt_agregar.setEnabled(true);
this.jcb_vestimenta.setEnabled(true);
this.jsp_cantidad.setEnabled(true);
}

private void limpiar() {
Expand All @@ -517,17 +568,16 @@ private void limpiar() {
this.jtf_garantia.setText("");
this.jdc_fachaInicio.setDate(null);
this.jdc_fachaFin.setDate(null);

this.jcb_estado.setSelectedIndex(0);
this.jcb_cliente.setSelectedIndex(0);

//Vestimenta
this.jcb_vestimenta.setSelectedIndex(0);
//this.jcb_vestimenta.setSelectedIndex(0);
this.jsp_cantidad.setValue(0);


this.apagarbotonCrear(true);

//limpiar listas
this.agregardetalleReserva.clear();
this.eliminardetalleReserva.clear();
Expand Down Expand Up @@ -616,11 +666,11 @@ public void run() {
// End of variables declaration//GEN-END:variables

private boolean getEstado(int selectedIndex) {
return (selectedIndex == 0)? true: false;
return (selectedIndex == 0) ? true : false;
}

private int getIndexEstado(String valor) {
return (valor == "true")? 0:1;
return (valor == "true") ? 0 : 1;
}

}
60 changes: 57 additions & 3 deletions src/Presentacion/PVestimenta.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ private void jLabel5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:eve
this.apagarbotonCrear(true);
String[] column = {"prenda", "stock", "color"};
this.jt_listar_prendas.setModel(new DefaultTableModel(null, column));
this.cargarPrenda();
}//GEN-LAST:event_jLabel5MouseClicked

private void jtf_nombreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_nombreActionPerformed
Expand Down Expand Up @@ -354,7 +355,7 @@ private void jt_listar_vestimentasMouseClicked(java.awt.event.MouseEvent evt) {/
this.apagarbotonCrear(false);

int id_vestimenta = (this.jt_listar_vestimentas.getValueAt(rowSelected, 0).toString() == "") ? 0 : Integer.valueOf(this.jt_listar_vestimentas.getValueAt(rowSelected, 0).toString());

listardetallePrenda(id_vestimenta);
}//GEN-LAST:event_jt_listar_vestimentasMouseClicked

Expand Down Expand Up @@ -388,6 +389,15 @@ private void jbt_quitarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI
}
}//GEN-LAST:event_jbt_quitarActionPerformed

public int indiceEliminar(String id, ArrayList<Object[]> lista) {
for (int i = 0; i < lista.size(); i++) {
if (id.equals(lista.get(i)[0].toString())) {
return i;
}
}
return -1;
}

private boolean buscarEliminar(ArrayList<Object[]> lista, Object[] buscar) {
String prendaBuscar = String.valueOf(buscar[0]);
String colorBuscar = String.valueOf(buscar[1]);
Expand Down Expand Up @@ -456,6 +466,8 @@ private void listardetallePrenda(int id_vestimenta) {
int cantidaddetalleprenda = (detallePrenda == null) ? 0 : detallePrenda.size();
int cantidadagregado = (agregardetallePrenda == null) ? 0 : agregardetallePrenda.size();

ActualizarPrenda(cantidaddetalleprenda, detallePrenda);

int x = cantidaddetalleprenda + cantidadagregado;
System.out.println(x);

Expand Down Expand Up @@ -487,6 +499,43 @@ private void cargarEmpleado() {
}
}

private void ActualizarPrenda(int cantidaddetalleprenda, ArrayList<Object[]> detallePrenda) {
ArrayList<Object[]> vestimentas = new ArrayList<>();
vestimentas = this.nprenda.listar();
if (cantidaddetalleprenda != 0) {
for (Object[] detalle : detallePrenda) {
String id = detalle[0].toString().split("-")[0];
int indiceAEliminar = indiceEliminar(id, vestimentas);
if (indiceAEliminar != -1) {
vestimentas.remove(indiceAEliminar);
}
}
}

for (Object[] agregar : agregardetallePrenda) {
String id = agregar[0].toString().split("-")[0];
int indiceAEliminar = indiceEliminar(id, vestimentas);
if (indiceAEliminar != -1) {
vestimentas.remove(indiceAEliminar);
}
}
this.jcb_prenda.removeAllItems();
if (vestimentas.isEmpty()) {
this.jbt_agregar.setEnabled(false);
this.jcb_prenda.setEnabled(false);
this.jtf_color.setEnabled(false);
this.jsp_stock.setEnabled(false);
} else {
for (Object[] vestimenta : vestimentas) {
this.jcb_prenda.addItem(vestimenta[0] + "-" + vestimenta[1]);
}
this.jbt_agregar.setEnabled(true);
this.jcb_prenda.setEnabled(true);
this.jtf_color.setEnabled(true);
this.jsp_stock.setEnabled(true);
}
}

private void cargarCategoria() {
ArrayList<Object[]> categorias = new ArrayList<>();
categorias = this.ncategoria.listar();
Expand All @@ -496,11 +545,16 @@ private void cargarCategoria() {
}

private void cargarPrenda() {
this.jcb_prenda.removeAllItems();
ArrayList<Object[]> categorias = new ArrayList<>();
categorias = this.nprenda.listar();
for (Object[] empleado : categorias) {
this.jcb_prenda.addItem(empleado[0] + "-" + empleado[1]);
}
this.jbt_agregar.setEnabled(true);
this.jcb_prenda.setEnabled(true);
this.jtf_color.setEnabled(true);
this.jsp_stock.setEnabled(true);
}

private void limpiar() {
Expand All @@ -513,12 +567,12 @@ private void limpiar() {
this.jcb_empleado.setSelectedIndex(0);

//Prendas
this.jcb_prenda.setSelectedIndex(0);
//this.jcb_prenda.setSelectedIndex(0);
this.jtf_color.setText("");
this.jsp_stock.setValue(0);

this.apagarbotonCrear(true);

//limpiar listas
this.agregardetallePrenda.clear();
this.eliminardetallePrenda.clear();
Expand Down

0 comments on commit da4e310

Please sign in to comment.