Skip to content

Commit da4e310

Browse files
committed
Change Vestimeta and Reserva in combobox
1 parent f6e3ec5 commit da4e310

File tree

11 files changed

+134
-36
lines changed

11 files changed

+134
-36
lines changed
-19 Bytes
Binary file not shown.

build/classes/Presentacion/PEmpleado.form

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<Font name="Tahoma" size="24" style="0"/>
5151
</Property>
5252
<Property name="horizontalAlignment" type="int" value="0"/>
53-
<Property name="text" type="java.lang.String" value="Cliente"/>
53+
<Property name="text" type="java.lang.String" value="Empleado"/>
5454
</Properties>
5555
<Constraints>
5656
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
0 Bytes
Binary file not shown.
1.17 KB
Binary file not shown.
0 Bytes
Binary file not shown.
1.22 KB
Binary file not shown.

nbproject/private/private.xml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
33
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
44
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
5-
<group>
6-
<file>file:/D:/Semestre/Final/Arquitectura%20de%20software/Proyecto/AlquilajeTraje/src/Negocio/NVestimenta.java</file>
7-
<file>file:/D:/Semestre/Final/Arquitectura%20de%20software/Proyecto/AlquilajeTraje/src/Presentacion/PVestimenta.java</file>
8-
<file>file:/D:/Semestre/Final/Arquitectura%20de%20software/Proyecto/AlquilajeTraje/src/Negocio/NDetallePrenda.java</file>
9-
<file>file:/D:/Semestre/Final/Arquitectura%20de%20software/Proyecto/AlquilajeTraje/src/Datos/DVestimenta.java</file>
10-
<file>file:/D:/Semestre/Final/Arquitectura%20de%20software/Proyecto/AlquilajeTraje/src/Datos/DDetallePrenda.java</file>
11-
</group>
5+
<group/>
126
</open-files>
137
</project-private>

src/Presentacion/PEmpleado.form

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<Font name="Tahoma" size="24" style="0"/>
5151
</Property>
5252
<Property name="horizontalAlignment" type="int" value="0"/>
53-
<Property name="text" type="java.lang.String" value="Cliente"/>
53+
<Property name="text" type="java.lang.String" value="Empleado"/>
5454
</Properties>
5555
<Constraints>
5656
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">

src/Presentacion/PEmpleado.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class PEmpleado extends javax.swing.JFrame {
2323
private String telefono;
2424
private String fecha_nacimiento;
2525
private String sexo;
26-
private String direccion;
26+
2727

2828
private NEmpleado nempleado;
2929

@@ -78,7 +78,7 @@ private void initComponents() {
7878

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

8484
jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

src/Presentacion/PReserva.java

Lines changed: 72 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ public class PReserva extends javax.swing.JFrame {
2828
private String fechaInicio;
2929
private String fechaFin;
3030
private boolean estado;
31-
31+
3232
private int id_cliente;
33-
33+
3434
private NCliente ncliente;
3535

3636
private NVestimenta nvestimenta;
37-
37+
3838
private NReserva nreserva;
3939
private ArrayList<Object[]> agregardetalleReserva;
4040
private ArrayList<Object[]> eliminardetalleReserva;
@@ -46,10 +46,10 @@ public PReserva() {
4646
initComponents();
4747
this.jtf_id.setEditable(false);
4848
this.jtf_id.setEnabled(false);
49-
49+
5050
this.ncliente = new NCliente();
5151
this.nvestimenta = new NVestimenta();
52-
52+
5353
this.nreserva = new NReserva();
5454

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

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

353354
int rowSelected = this.jt_listar_reserva.getSelectedRow();
354-
355+
355356
this.jtf_id.setText(this.jt_listar_reserva.getValueAt(rowSelected, 0).toString());
356357
this.jcb_cliente.setSelectedItem(this.jt_listar_reserva.getValueAt(rowSelected, 1).toString());
357358
this.jtf_titulo.setText(this.jt_listar_reserva.getValueAt(rowSelected, 2).toString());
358359
this.jtf_garantia.setText(this.jt_listar_reserva.getValueAt(rowSelected, 3).toString());
359-
String fechaInicio =this.jt_listar_reserva.getValueAt(rowSelected, 4).toString();
360-
String fechaFin =this.jt_listar_reserva.getValueAt(rowSelected, 5).toString();
360+
String fechaInicio = this.jt_listar_reserva.getValueAt(rowSelected, 4).toString();
361+
String fechaFin = this.jt_listar_reserva.getValueAt(rowSelected, 5).toString();
361362
try {
362363
this.jdc_fachaInicio.setDate(new SimpleDateFormat("yyyy-MM-dd").parse(fechaInicio));
363364
this.jdc_fachaFin.setDate(new SimpleDateFormat("yyyy-MM-dd").parse(fechaFin));
364365
} catch (ParseException ex) {
365366
Logger.getLogger(PCliente.class.getName()).log(Level.SEVERE, null, ex);
366367
}
367368
this.jcb_estado.setSelectedIndex(getIndexEstado(this.jt_listar_reserva.getValueAt(rowSelected, 6).toString()));
368-
369+
369370
this.apagarbotonCrear(false);
370371

371372
int id_vestimenta = (this.jtf_id.getText() == "") ? 0 : Integer.valueOf(this.jtf_id.getText());
372-
373+
373374
listardetalleReserva(id_vestimenta);
374375
}//GEN-LAST:event_jt_listar_reservaMouseClicked
375376

@@ -378,7 +379,7 @@ private void jbt_agregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
378379
Object[] agregar = {
379380
this.jcb_vestimenta.getSelectedItem().toString(),
380381
this.jsp_cantidad.getValue().toString()};
381-
382+
382383
agregardetalleReserva.add(agregar);
383384

384385
int id_reserva = (this.jtf_id.getText().isEmpty()) ? 0 : Integer.valueOf(this.jtf_id.getText());
@@ -412,7 +413,7 @@ private boolean buscarEliminar(ArrayList<Object[]> lista, Object[] buscar) {
412413
for (int i = 0; i < lista.size(); i++) {
413414
String vestimenta = String.valueOf(lista.get(i)[0]);
414415
String cantidad = String.valueOf(lista.get(i)[1]);
415-
if (vestimentaBuscar == vestimenta && cantidadBuscar == cantidad ) {
416+
if (vestimentaBuscar == vestimenta && cantidadBuscar == cantidad) {
416417
lista.remove(i);
417418
return true;
418419
}
@@ -421,7 +422,7 @@ private boolean buscarEliminar(ArrayList<Object[]> lista, Object[] buscar) {
421422
}
422423

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

443444
private void editar() {
444-
if (this.nreserva.editar(this.id, this.id_cliente,this.titulo,this.garantia,this.fechaInicio,this.fechaFin,this.estado, agregardetalleReserva, eliminardetalleReserva)) {
445+
if (this.nreserva.editar(this.id, this.id_cliente, this.titulo, this.garantia, this.fechaInicio, this.fechaFin, this.estado, agregardetalleReserva, eliminardetalleReserva)) {
445446
JOptionPane.showMessageDialog(null, "Se Edito Correctamen", "Edicion", JOptionPane.INFORMATION_MESSAGE);
446447
} else {
447448
JOptionPane.showMessageDialog(null, "No se pudo Editar", "Warning", JOptionPane.WARNING_MESSAGE);
@@ -463,16 +464,27 @@ private void listar() {
463464
data[i][5] = String.valueOf(reservas.get(i)[5]);
464465
data[i][6] = String.valueOf(reservas.get(i)[6]);
465466
}
466-
String[] column = {"id", "cliente","titulo", "garantia", "fechaInicio", "fechaFin", "estado"};
467+
String[] column = {"id", "cliente", "titulo", "garantia", "fechaInicio", "fechaFin", "estado"};
467468
this.jt_listar_reserva.setModel(new DefaultTableModel(data, column));
468469
}
469470

471+
public int indiceEliminar(String id, ArrayList<Object[]> lista) {
472+
for (int i = 0; i < lista.size(); i++) {
473+
if (id.equals(lista.get(i)[0].toString())) {
474+
return i;
475+
}
476+
}
477+
return -1;
478+
}
479+
470480
private void listardetalleReserva(int id_reserva) {
471481
ArrayList<Object[]> detalleReserva = new ArrayList<>();
472482
detalleReserva = (id_reserva == 0) ? null : this.nreserva.listarDetalleReserva(id_reserva);
473483
int cantidaddetalleprenda = (detalleReserva == null) ? 0 : detalleReserva.size();
474484
int cantidadagregado = (agregardetalleReserva == null) ? 0 : agregardetalleReserva.size();
475485

486+
ActualizarVestimenta(cantidaddetalleprenda, detalleReserva);
487+
476488
int x = cantidaddetalleprenda + cantidadagregado;
477489
System.out.println(x);
478490

@@ -490,10 +502,45 @@ private void listardetalleReserva(int id_reserva) {
490502
i++;
491503
j++;
492504
}
493-
String[] column = {"prenda", "cantidad"};
505+
String[] column = {"vestimenta", "cantidad"};
494506
this.jt_listar_vestimenta.setModel(new DefaultTableModel(data, column));
495507
}
496508

509+
private void ActualizarVestimenta(int cantidaddetalleprenda, ArrayList<Object[]> detalleReserva) {
510+
ArrayList<Object[]> vestimentas = new ArrayList<>();
511+
vestimentas = this.nvestimenta.listar();
512+
if (cantidaddetalleprenda != 0) {
513+
for (Object[] detalle : detalleReserva) {
514+
String id = detalle[0].toString().split("-")[0];
515+
int indiceAEliminar = indiceEliminar(id, vestimentas);
516+
if (indiceAEliminar != -1) {
517+
vestimentas.remove(indiceAEliminar);
518+
}
519+
}
520+
}
521+
522+
for (Object[] agregar : agregardetalleReserva) {
523+
String id = agregar[0].toString().split("-")[0];
524+
int indiceAEliminar = indiceEliminar(id, vestimentas);
525+
if (indiceAEliminar != -1) {
526+
vestimentas.remove(indiceAEliminar);
527+
}
528+
}
529+
this.jcb_vestimenta.removeAllItems();
530+
if (vestimentas.isEmpty()) {
531+
this.jbt_agregar.setEnabled(false);
532+
this.jcb_vestimenta.setEnabled(false);
533+
this.jsp_cantidad.setEnabled(false);
534+
} else {
535+
for (Object[] vestimenta : vestimentas) {
536+
this.jcb_vestimenta.addItem(vestimenta[0] + "-" + vestimenta[1]);
537+
}
538+
this.jbt_agregar.setEnabled(true);
539+
this.jcb_vestimenta.setEnabled(true);
540+
this.jsp_cantidad.setEnabled(true);
541+
}
542+
}
543+
497544
private void cargarCliente() {
498545
ArrayList<Object[]> clientes = new ArrayList<>();
499546
clientes = this.ncliente.listar();
@@ -503,11 +550,15 @@ private void cargarCliente() {
503550
}
504551

505552
private void cargarVestimenta() {
553+
this.jcb_vestimenta.removeAllItems();
506554
ArrayList<Object[]> vestimentas = new ArrayList<>();
507555
vestimentas = this.nvestimenta.listar();
508556
for (Object[] vestimenta : vestimentas) {
509557
this.jcb_vestimenta.addItem(vestimenta[0] + "-" + vestimenta[1]);
510558
}
559+
this.jbt_agregar.setEnabled(true);
560+
this.jcb_vestimenta.setEnabled(true);
561+
this.jsp_cantidad.setEnabled(true);
511562
}
512563

513564
private void limpiar() {
@@ -517,17 +568,16 @@ private void limpiar() {
517568
this.jtf_garantia.setText("");
518569
this.jdc_fachaInicio.setDate(null);
519570
this.jdc_fachaFin.setDate(null);
520-
571+
521572
this.jcb_estado.setSelectedIndex(0);
522573
this.jcb_cliente.setSelectedIndex(0);
523574

524575
//Vestimenta
525-
this.jcb_vestimenta.setSelectedIndex(0);
576+
//this.jcb_vestimenta.setSelectedIndex(0);
526577
this.jsp_cantidad.setValue(0);
527-
528578

529579
this.apagarbotonCrear(true);
530-
580+
531581
//limpiar listas
532582
this.agregardetalleReserva.clear();
533583
this.eliminardetalleReserva.clear();
@@ -616,11 +666,11 @@ public void run() {
616666
// End of variables declaration//GEN-END:variables
617667

618668
private boolean getEstado(int selectedIndex) {
619-
return (selectedIndex == 0)? true: false;
669+
return (selectedIndex == 0) ? true : false;
620670
}
621671

622672
private int getIndexEstado(String valor) {
623-
return (valor == "true")? 0:1;
673+
return (valor == "true") ? 0 : 1;
624674
}
625675

626676
}

0 commit comments

Comments
 (0)