Creando orden de compra y aceptandolas

Esta por terminar la funcionalidad
This commit is contained in:
Daniel Cortés
2019-07-01 19:28:11 -04:00
parent e211385447
commit 6b4f55d752
30 changed files with 2043 additions and 841 deletions

View File

@@ -30,9 +30,6 @@ import xyz.danielcortes.controllers.cliente.telefono.ClienteTelefonoCreateContro
import xyz.danielcortes.controllers.cliente.telefono.ClienteTelefonoSearchController;
import xyz.danielcortes.controllers.cliente.telefono.ClienteTelefonoUpdateController;
import xyz.danielcortes.controllers.cliente.telefono.ClienteTelefonoViewController;
import xyz.danielcortes.controllers.comprar.ComprarComprarController;
import xyz.danielcortes.controllers.comprar.ComprarSearchController;
import xyz.danielcortes.controllers.comprar.ComprarSeleccionarController;
import xyz.danielcortes.controllers.distribuidor.DistribuidorCreateController;
import xyz.danielcortes.controllers.distribuidor.DistribuidorSearchController;
import xyz.danielcortes.controllers.distribuidor.DistribuidorUpdateController;
@@ -65,6 +62,10 @@ import xyz.danielcortes.controllers.libro.LibroCreateController;
import xyz.danielcortes.controllers.libro.LibroSearchController;
import xyz.danielcortes.controllers.libro.LibroUpdateController;
import xyz.danielcortes.controllers.libro.LibroViewController;
import xyz.danielcortes.controllers.orden_compra.OrdenCompraAceptarController;
import xyz.danielcortes.controllers.orden_compra.OrdenCompraCrearController;
import xyz.danielcortes.controllers.orden_compra.OrdenCompraSearchController;
import xyz.danielcortes.controllers.orden_compra.OrdenCompraViewController;
import xyz.danielcortes.controllers.trabajador.TrabajadorCreateController;
import xyz.danielcortes.controllers.trabajador.TrabajadorSearchController;
import xyz.danielcortes.controllers.trabajador.TrabajadorUpdateController;
@@ -100,9 +101,6 @@ import xyz.danielcortes.views.cliente.ClienteCreatePanel;
import xyz.danielcortes.views.cliente.ClienteSearchPanel;
import xyz.danielcortes.views.cliente.ClienteUpdatePanel;
import xyz.danielcortes.views.cliente.ClienteViewPanel;
import xyz.danielcortes.views.comprar.ComprarComprarPanel;
import xyz.danielcortes.views.comprar.ComprarSearchPanel;
import xyz.danielcortes.views.comprar.ComprarSeleccionarPanel;
import xyz.danielcortes.views.correo.CorreoCreatePanel;
import xyz.danielcortes.views.correo.CorreoSearchPanel;
import xyz.danielcortes.views.correo.CorreoUpdatePanel;
@@ -131,6 +129,10 @@ import xyz.danielcortes.views.libro.LibroCreatePanel;
import xyz.danielcortes.views.libro.LibroSearchPanel;
import xyz.danielcortes.views.libro.LibroUpdatePanel;
import xyz.danielcortes.views.libro.LibroViewPanel;
import xyz.danielcortes.views.orden_compra.OrdenCompraAceptarPanel;
import xyz.danielcortes.views.orden_compra.OrdenCompraCrearPanel;
import xyz.danielcortes.views.orden_compra.OrdenCompraSearchPanel;
import xyz.danielcortes.views.orden_compra.OrdenCompraViewPanel;
import xyz.danielcortes.views.telefono.TelefonoCreatePanel;
import xyz.danielcortes.views.telefono.TelefonoSearchPanel;
import xyz.danielcortes.views.telefono.TelefonoUpdatePanel;
@@ -292,9 +294,10 @@ public class LaunchController {
this.controllers.put(PanelName.DISTRIBUIDOR_DIRECCION_CREATE, new DistribuidorDireccionCreateController(new DireccionCreatePanel(), this));
this.controllers.put(PanelName.DISTRIBUIDOR_DIRECCION_UPDATE, new DistribuidorDireccionUpdateController(new DireccionUpdatePanel(), this));
this.controllers.put(PanelName.COMPRAR_SEARCH, new ComprarSearchController(new ComprarSearchPanel(), this));
this.controllers.put(PanelName.COMPRAR_COMPRAR, new ComprarComprarController(new ComprarComprarPanel(), this));
this.controllers.put(PanelName.COMPRAR_SELECCIONAR, new ComprarSeleccionarController(new ComprarSeleccionarPanel(), this));
this.controllers.put(PanelName.ORDEN_COMPRA_SEARCH, new OrdenCompraSearchController(new OrdenCompraSearchPanel(), this));
this.controllers.put(PanelName.ORDEN_COMPRA_CREAR, new OrdenCompraCrearController(new OrdenCompraCrearPanel(), this));
this.controllers.put(PanelName.ORDEN_COMPRA_VIEW, new OrdenCompraViewController(new OrdenCompraViewPanel(), this));
this.controllers.put(PanelName.ORDEN_COMPRA_ACEPTAR, new OrdenCompraAceptarController(new OrdenCompraAceptarPanel(), this));
for (Entry<PanelName, BaseController> entry : this.controllers.entrySet()) {
this.frame.addCard(entry.getValue().getView().getContentPane(), entry.getKey());
@@ -362,17 +365,17 @@ public class LaunchController {
private JMenu createComprarMenu() {
JMenu comprarMenu = new JMenu("Compra, Venta y Arriendo");
JMenuItem comprarLibroItem = new JMenuItem("Comprar Libro");
JMenuItem venderLibroItem = new JMenuItem("Vender Libro");
JMenuItem arrendarLibroItem = new JMenuItem("Arrendar Libro");
JMenuItem ordenDeCompraItem = new JMenuItem("Orden de compra");
JMenuItem venderEjemplarItem = new JMenuItem("Vender Ejemplar");
JMenuItem arrendarEjemplarItem = new JMenuItem("Arrendar Ejemplar");
comprarLibroItem.addActionListener(e -> this.showCard(PanelName.COMPRAR_SEARCH));
venderLibroItem.addActionListener(e -> this.showCard(PanelName.VENDER_SEARCH));
arrendarLibroItem.addActionListener(e -> this.showCard(PanelName.ARRENDAR_SEARCH));
ordenDeCompraItem.addActionListener(e -> this.showCard(PanelName.ORDEN_COMPRA_SEARCH));
venderEjemplarItem.addActionListener(e -> this.showCard(PanelName.VENDER_SEARCH));
arrendarEjemplarItem.addActionListener(e -> this.showCard(PanelName.ARRENDAR_SEARCH));
comprarMenu.add(comprarLibroItem);
comprarMenu.add(venderLibroItem);
comprarMenu.add(arrendarLibroItem);
comprarMenu.add(ordenDeCompraItem);
comprarMenu.add(venderEjemplarItem);
comprarMenu.add(arrendarEjemplarItem);
return comprarMenu;
}

View File

@@ -1,48 +0,0 @@
package xyz.danielcortes.controllers.comprar;
import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.framework.BaseController;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.repository.CompraRepository;
import xyz.danielcortes.repository.DistribuidorRepository;
import xyz.danielcortes.validator.CompraValidator;
import xyz.danielcortes.views.comprar.ComprarComprarPanel;
public class ComprarComprarController extends BaseController {
private ComprarComprarPanel view;
private CompraRepository compraRepository;
private DistribuidorRepository distribuidorRepository;
private CompraValidator validator;
public ComprarComprarController(ComprarComprarPanel view, LaunchController parent) {
super(parent);
this.view = view;
this.compraRepository = new CompraRepository();
this.distribuidorRepository = new DistribuidorRepository();
this.validator = new CompraValidator(this.compraRepository);
this.setupListeners();
}
public void setupListeners() {
this.view.getVolverButton().addActionListener(e -> this.parentController.showCard(PanelName.COMPRAR_SEARCH));
this.view.getSeleccionarButton().addActionListener(e -> this.parentController.showCard(PanelName.COMPRAR_SELECCIONAR));
}
@Override
public void show() {
this.fillDistribuidores();
}
private void fillDistribuidores() {
this.view.getDistribuidorModel().removeAllElements();
this.view.getDistribuidorModel().addAll(this.distribuidorRepository.getAll());
}
@Override
public BasePanel getView() {
return this.view;
}
}

View File

@@ -1,92 +0,0 @@
package xyz.danielcortes.controllers.comprar;
import java.util.List;
import javax.swing.JOptionPane;
import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.framework.BaseController;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.framework.BaseTableModel;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.models.Compra;
import xyz.danielcortes.repository.CompraRepository;
import xyz.danielcortes.validator.CompraValidator;
import xyz.danielcortes.views.comprar.ComprarSearchPanel;
public class ComprarSearchController extends BaseController {
private ComprarSearchPanel view;
private CompraRepository repository;
private CompraValidator validator;
public ComprarSearchController(ComprarSearchPanel view, LaunchController parent) {
super(parent);
this.view = view;
this.repository = new CompraRepository();
this.validator = new CompraValidator(this.repository);
this.setupListeners();
}
private void setupListeners() {
this.view.getComprarButton().addActionListener(e -> this.getParentController().showCard(PanelName.COMPRAR_COMPRAR));
this.view.getBuscarButton().addActionListener(e -> this.search());
this.view.getSearchField().addActionListener(e -> this.search());
this.view.getVerButton().addActionListener(e -> this.view());
}
private void search() {
String term = this.view.getSearchField().getText();
List<Compra> compras = this.repository.search(term);
this.loadComprarTable(compras);
}
private void view() {
Compra compra = this.getSelectedCompra();
if (compra != null) {
// CompraViewController controller = (CompraViewController) this.getParentController().getCard(PanelName.COMPRAR_VIEW);
// controller.setCompra(compra);
// this.getParentController().showCard(PanelName.COMPRAR_VIEW);
}
}
private void loadComprarTable(List<Compra> compras) {
BaseTableModel<Compra> model = this.view.getModel();
model.setRows(compras);
}
private Compra getSelectedCompra() {
int selectedRow = this.view.getTable().getSelectedRow();
if (selectedRow == -1) {
JOptionPane.showMessageDialog(
null,
"No hay copra seleccionada",
"Error",
JOptionPane.ERROR_MESSAGE
);
return null;
}
return this.view.getModel().getRow(selectedRow);
}
@Override
public void show() {
this.reload();
}
public void reload() {
this.loadComprarTable();
this.view.getSearchField().requestFocus();
this.view.getTable().setRowSelectionInterval(0, 0);
}
private void loadComprarTable() {
List<Compra> compra = this.repository.getAll();
this.loadComprarTable(compra);
}
@Override
public BasePanel getView() {
return this.view;
}
}

View File

@@ -1,133 +0,0 @@
package xyz.danielcortes.controllers.comprar;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;
import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.framework.BaseController;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.framework.ValidationResult;
import xyz.danielcortes.models.Ejemplar;
import xyz.danielcortes.models.Estado;
import xyz.danielcortes.models.Libro;
import xyz.danielcortes.repository.EjemplarRepository;
import xyz.danielcortes.repository.LibroRepository;
import xyz.danielcortes.validator.EjemplarValidator;
import xyz.danielcortes.views.comprar.ComprarSeleccionarPanel;
public class ComprarSeleccionarController extends BaseController {
private ComprarSeleccionarPanel view;
private LibroRepository libroRepository;
private EjemplarValidator ejemplarValidator;
private List<Ejemplar> ejemplares;
private List<Ejemplar> editing;
public ComprarSeleccionarController(ComprarSeleccionarPanel view, LaunchController parent) {
super(parent);
this.view = view;
this.libroRepository = new LibroRepository();
this.ejemplarValidator = new EjemplarValidator(new EjemplarRepository());
this.ejemplares = new ArrayList<>();
this.editing = new ArrayList<>();
this.setupListeners();
}
public void setupListeners() {
this.view.getGuardarButton().addActionListener(e -> this.save());
this.view.getVolverButton().addActionListener(e -> this.volver());
this.view.getRemoverButton().addActionListener(e -> this.remove());
this.view.getAgregarButton().addActionListener(e -> this.agregar());
}
private void save() {
this.ejemplares.clear();
this.ejemplares.addAll(this.editing);
this.getParentController().showCard(PanelName.COMPRAR_COMPRAR);
}
private void volver() {
this.editing.clear();
this.editing.addAll(this.ejemplares);
this.parentController.showCard(PanelName.COMPRAR_COMPRAR);
}
private void remove() {
Ejemplar ejemplar = this.getSelectedEjemplar();
if (ejemplar == null)
return;
int index = this.view.getEjemplaresTable().getSelectedRow();
this.view.getEjemplaresTableModel().removeRow(index);
this.editing.remove(ejemplar);
}
private void agregar() {
Libro libro = (Libro) this.view.getLibrosCombo().getSelectedItem();
if (libro == null)
return;
String serie = this.view.getSerieField().getText();
ValidationResult serieValidation = this.ejemplarValidator.validateSerie(serie, libro.getId(), this.editing);
if (serieValidation.hasError()) {
serieValidation.showErrorDialog();
return;
}
Ejemplar ejemplar = new Ejemplar();
ejemplar.setLibro(libro);
ejemplar.setSerie(serie);
ejemplar.setEstado(new Estado());
this.editing.add(ejemplar);
this.view.getEjemplaresTableModel().addRow(ejemplar);
this.view.getLibrosCombo().setSelectedIndex(0);
this.view.getSerieField().setText("");
}
private Ejemplar getSelectedEjemplar() {
int selectedRow = this.view.getEjemplaresTable().getSelectedRow();
if (selectedRow == -1) {
JOptionPane.showMessageDialog(
null,
"No hay ningun ejemplar seleccionado",
"Error",
JOptionPane.ERROR_MESSAGE
);
return null;
}
return this.view.getEjemplaresTableModel().getRow(selectedRow);
}
@Override
public void show() {
this.editing.clear();
this.editing.addAll(this.ejemplares);
this.fillLibros();
this.view.getLibrosCombo().setSelectedIndex(0);
}
private void fillLibros() {
this.view.getLibrosComboModel().removeAllElements();
this.view.getLibrosComboModel().addAll(this.libroRepository.getAll());
this.view.getEjemplaresTableModel().setRows(this.ejemplares);
}
@Override
public BasePanel getView() {
return this.view;
}
public List<Ejemplar> getEjemplares() {
return this.ejemplares;
}
}

View File

@@ -0,0 +1,59 @@
package xyz.danielcortes.controllers.orden_compra;
import java.time.LocalDate;
import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.framework.BaseController;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.framework.ChangeListener;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.models.OrdenCompra;
import xyz.danielcortes.views.orden_compra.OrdenCompraAceptarPanel;
public class OrdenCompraAceptarController extends BaseController {
private OrdenCompraAceptarPanel view;
private OrdenCompra ordenCompra;
public OrdenCompraAceptarController(OrdenCompraAceptarPanel view, LaunchController parent) {
super(parent);
this.view = view;
this.setupListeners();
}
private void setupListeners() {
this.view.getVolverButton().addActionListener(e -> this.parentController.showCard(PanelName.ORDEN_COMPRA_SEARCH));
this.view.getPrecioNetoField().getDocument().addDocumentListener((ChangeListener) e -> this.calculatePrice());
}
private void calculatePrice() {
try {
int neto = Integer.parseInt(this.view.getPrecioNetoField().getText());
float iva = (float) neto * .19f;
this.view.getIvaField().setText(String.valueOf(iva));
this.view.getTotalField().setText(String.valueOf(iva + neto));
} catch (NumberFormatException e) {
this.view.getIvaField().setText("0");
this.view.getTotalField().setText("0");
}
}
public void setOrdenCompra(OrdenCompra ordenCompra) {
this.ordenCompra = ordenCompra;
}
@Override
public void show() {
this.view.getAsignarButton().requestFocus();
this.view.getFechaEmisionPicker().setDate(LocalDate.now());
this.view.getIvaField().setText("0");
this.view.getPrecioNetoField().setText("0");
this.view.getTotalField().setText("0");
}
@Override
public BasePanel getView() {
return this.view;
}
}

View File

@@ -0,0 +1,129 @@
package xyz.danielcortes.controllers.orden_compra;
import java.util.List;
import javax.swing.JOptionPane;
import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.framework.BaseController;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.framework.ValidationResult;
import xyz.danielcortes.models.Distribuidor;
import xyz.danielcortes.models.Libro;
import xyz.danielcortes.models.OrdenCompra;
import xyz.danielcortes.repository.DistribuidorRepository;
import xyz.danielcortes.repository.LibroRepository;
import xyz.danielcortes.repository.OrdenCompraRepository;
import xyz.danielcortes.validator.OrdenCompraValidator;
import xyz.danielcortes.views.orden_compra.OrdenCompraCrearPanel;
public class OrdenCompraCrearController extends BaseController {
private OrdenCompraCrearPanel view;
private LibroRepository libroRepository;
private DistribuidorRepository distribuidorRepository;
private OrdenCompraRepository ordenCompraRepository;
private OrdenCompraValidator validator;
public OrdenCompraCrearController(OrdenCompraCrearPanel view, LaunchController parent) {
super(parent);
this.view = view;
this.libroRepository = new LibroRepository();
this.distribuidorRepository = new DistribuidorRepository();
this.ordenCompraRepository = new OrdenCompraRepository();
this.validator = new OrdenCompraValidator();
this.setupListeners();
}
public void setupListeners() {
this.view.getGuardarButton().addActionListener(e -> this.save());
this.view.getVolverButton().addActionListener(e -> this.volver());
this.view.getRemoverButton().addActionListener(e -> this.remove());
this.view.getAgregarButton().addActionListener(e -> this.agregar());
}
private void save() {
List<Libro> libros = this.view.getLibroTableModel().getRows();
ValidationResult librosValidation = this.validator.validateLibros(libros);
if (librosValidation.hasError()) {
librosValidation.showErrorDialog();
return;
}
Distribuidor distribuidor = (Distribuidor) this.view.getDistribuidorCombo().getSelectedItem();
ValidationResult distribuidorValidation = this.validator.validateDistribuidor(distribuidor);
if (distribuidorValidation.hasError()) {
distribuidorValidation.showErrorDialog();
return;
}
OrdenCompra ordenCompra = new OrdenCompra();
ordenCompra.setDistribuidor(distribuidor);
ordenCompra.setEstado("En Curso");
ordenCompra.setLibros(libros);
this.ordenCompraRepository.save(ordenCompra);
this.parentController.showCard(PanelName.ORDEN_COMPRA_SEARCH);
}
private void volver() {
this.parentController.showCard(PanelName.ORDEN_COMPRA_SEARCH);
}
private void remove() {
Libro libro = this.getSelectedLibro();
if (libro == null)
return;
this.view.getLibroTableModel().removeRow(libro);
}
private void agregar() {
Libro libro = (Libro) this.view.getLibrosCombo().getSelectedItem();
if (libro == null)
return;
int cantidad = (int) this.view.getCantidadSpinner().getValue();
for (int i = 0; i < cantidad; i++) {
this.view.getLibroTableModel().addRow(libro);
}
}
private Libro getSelectedLibro() {
int selectedRow = this.view.getLibrosTable().getSelectedRow();
if (selectedRow == -1) {
JOptionPane.showMessageDialog(
null,
"No hay ningun libro seleccionado",
"Error",
JOptionPane.ERROR_MESSAGE
);
return null;
}
return this.view.getLibroTableModel().getRow(selectedRow);
}
@Override
public void show() {
this.fillLibros();
this.fillDistribuidor();
this.view.getLibrosCombo().setSelectedIndex(0);
this.view.getDistribuidorCombo().setSelectedIndex(0);
this.view.getLibroTableModel().removeRows();
this.view.getLibrosTable().clearSelection();
}
private void fillLibros() {
this.view.getLibrosComboModel().removeAllElements();
this.view.getLibrosComboModel().addAll(this.libroRepository.getAll());
}
private void fillDistribuidor() {
this.view.getDistribuidorComboModel().removeAllElements();
this.view.getDistribuidorComboModel().addAll(this.distribuidorRepository.getAll());
}
@Override
public BasePanel getView() {
return this.view;
}
}

View File

@@ -0,0 +1,172 @@
package xyz.danielcortes.controllers.orden_compra;
import java.util.List;
import javax.swing.JOptionPane;
import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.framework.BaseController;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.framework.BaseTableModel;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.models.OrdenCompra;
import xyz.danielcortes.repository.OrdenCompraRepository;
import xyz.danielcortes.views.orden_compra.OrdenCompraSearchPanel;
public class OrdenCompraSearchController extends BaseController {
private OrdenCompraSearchPanel view;
private OrdenCompraRepository repository;
public OrdenCompraSearchController(OrdenCompraSearchPanel view, LaunchController parent) {
super(parent);
this.view = view;
this.repository = new OrdenCompraRepository();
this.setupListeners();
}
private void setupListeners() {
this.view.getBuscarButton().addActionListener(e -> this.search());
this.view.getSearchField().addActionListener(e -> this.search());
this.view.getCrearButton().addActionListener(e -> this.getParentController().showCard(PanelName.ORDEN_COMPRA_CREAR));
this.view.getVerButton().addActionListener(e -> this.view());
this.view.getCancelarButton().addActionListener(e -> this.cancelar());
this.view.getAceptarButton().addActionListener(e -> this.aceptar());
}
private void search() {
String term = this.view.getSearchField().getText();
List<OrdenCompra> ordenCompras = this.repository.search(term);
this.loadComprarTable(ordenCompras);
}
private void view() {
OrdenCompra ordenCompra = this.getSelectedOrdenCompra();
if (ordenCompra != null) {
OrdenCompraViewController controller = (OrdenCompraViewController) this.getParentController().getCard(PanelName.ORDEN_COMPRA_VIEW);
controller.setOrdenCompra(ordenCompra);
this.getParentController().showCard(PanelName.ORDEN_COMPRA_VIEW);
}
}
private void cancelar() {
OrdenCompra ordenCompra = this.getSelectedOrdenCompra();
if (ordenCompra == null)
return;
if (ordenCompra.getEstado().equals("Cancelada")) {
JOptionPane.showMessageDialog(
null,
"La orden ya esta cancelada",
"Error",
JOptionPane.ERROR_MESSAGE
);
return;
} else if (ordenCompra.getEstado().equals("Aceptada")) {
JOptionPane.showMessageDialog(
null,
"La orden ya fue aceptada",
"Error",
JOptionPane.ERROR_MESSAGE
);
return;
} else if (!ordenCompra.getEstado().equals("En Curso")) {
JOptionPane.showMessageDialog(
null,
"La orden esta en un estado imposible, corre!",
"Error",
JOptionPane.ERROR_MESSAGE
);
return;
}
int result = JOptionPane.showConfirmDialog(
null,
"Esta seguro de cancelar esta orden de compra?",
"Confirmar",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE
);
if (result == JOptionPane.YES_OPTION) {
ordenCompra.setEstado("Cancelada");
this.repository.update(ordenCompra);
}
}
private void aceptar() {
OrdenCompra ordenCompra = this.getSelectedOrdenCompra();
if (ordenCompra == null)
return;
if (ordenCompra.getEstado().equals("Cancelada")) {
JOptionPane.showMessageDialog(
null,
"La orden fue cancelada, no se pude aceptar",
"Error",
JOptionPane.ERROR_MESSAGE
);
return;
} else if (ordenCompra.getEstado().equals("Aceptada")) {
JOptionPane.showMessageDialog(
null,
"La orden ya fue aceptada",
"Error",
JOptionPane.ERROR_MESSAGE
);
return;
} else if (!ordenCompra.getEstado().equals("En Curso")) {
JOptionPane.showMessageDialog(
null,
"La orden está en un estado imposible, corre!",
"Error",
JOptionPane.ERROR_MESSAGE
);
return;
}
OrdenCompraAceptarController controller = (OrdenCompraAceptarController) this.getParentController().getCard(PanelName.ORDEN_COMPRA_ACEPTAR);
controller.setOrdenCompra(ordenCompra);
this.getParentController().showCard(PanelName.ORDEN_COMPRA_ACEPTAR);
}
private void loadComprarTable(List<OrdenCompra> ordenCompra) {
BaseTableModel<OrdenCompra> model = this.view.getModel();
model.setRows(ordenCompra);
}
private OrdenCompra getSelectedOrdenCompra() {
int selectedRow = this.view.getTable().getSelectedRow();
if (selectedRow == -1) {
JOptionPane.showMessageDialog(
null,
"No hay orden de compra seleccionada",
"Error",
JOptionPane.ERROR_MESSAGE
);
return null;
}
return this.view.getModel().getRow(selectedRow);
}
@Override
public void show() {
this.reload();
}
public void reload() {
this.loadComprarTable();
this.view.getSearchField().requestFocus();
this.view.getTable().setRowSelectionInterval(0, 0);
}
private void loadComprarTable() {
List<OrdenCompra> ordenCompra = this.repository.getAll();
this.loadComprarTable(ordenCompra);
}
@Override
public BasePanel getView() {
return this.view;
}
}

View File

@@ -0,0 +1,45 @@
package xyz.danielcortes.controllers.orden_compra;
import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.framework.BaseController;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.models.OrdenCompra;
import xyz.danielcortes.views.orden_compra.OrdenCompraViewPanel;
public class OrdenCompraViewController extends BaseController {
private OrdenCompraViewPanel view;
private OrdenCompra ordenCompra;
public OrdenCompraViewController(OrdenCompraViewPanel view, LaunchController parent) {
super(parent);
this.view = view;
this.setupListeners();
}
private void setupListeners() {
this.view.getVolverButton().addActionListener(e -> this.parentController.showCard(PanelName.ORDEN_COMPRA_SEARCH));
}
public void setOrdenCompra(OrdenCompra ordenCompra) {
this.ordenCompra = ordenCompra;
}
@Override
public void show() {
this.view.getDistribuidorField().setText(this.ordenCompra.getDistribuidor().getRut());
this.fillTable();
}
@Override
public BasePanel getView() {
return this.view;
}
private void fillTable() {
if (this.ordenCompra != null) {
this.view.getLibroTableModel().setRows(this.ordenCompra.getLibros());
}
}
}

View File

@@ -24,7 +24,7 @@ public class BaseTableModel<T> extends AbstractTableModel {
* @param valueAt TriFunction la cual recibe por parametros: - La lista de filas de la tabla - Un Integer indicando la fila del que se necesita el
* valor - Un Integer indicando la columna de la que se necesita el valor Y esta debe retornar un objeto con toString para poder ser mostrado en la
* tabla
*
* <p>
* Se sugiere el siguiente tipo de implementacion para la funcion (row, rowIndex, colIndex) -> { switch (colIndex) { case 0: return
* row.get(rowIndex).getColumn1(); case 1: return row.get(rowIndex).getColumn2(); case 2: return row.get(rowIndex).getColumn3(); case 3: return
* row.get(rowIndex).getColumn4(); } return null; }
@@ -61,6 +61,30 @@ public class BaseTableModel<T> extends AbstractTableModel {
return this.valueAt.apply(this.rows, rowIndex, columnIndex);
}
public void removeRow(int row) {
this.rows.remove(row);
this.fireTableRowsDeleted(row, row);
}
public void removeRow(T t) {
int removed = this.rows.indexOf(t);
this.rows.remove(removed);
this.fireTableRowsDeleted(removed, removed);
}
public T getRow(int row) {
if (row > -1 || row < this.getRowCount()) {
return this.rows.get(row);
} else {
return null;
}
}
public List<T> getRows() {
return this.rows;
}
public void setRows(List<T> items) {
this.removeRows();
this.rows.addAll(items);
@@ -74,17 +98,4 @@ public class BaseTableModel<T> extends AbstractTableModel {
this.fireTableRowsDeleted(0, rowCount - 1);
}
}
public void removeRow(int row) {
this.rows.remove(row);
this.fireTableRowsDeleted(row, row);
}
public T getRow(int row) {
if (row > -1 || row < this.getRowCount()) {
return this.rows.get(row);
} else {
return null;
}
}
}

View File

@@ -0,0 +1,24 @@
package xyz.danielcortes.framework;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
public interface ChangeListener extends DocumentListener {
@Override
default void insertUpdate(DocumentEvent e) {
this.changed(e);
}
@Override
default void removeUpdate(DocumentEvent e) {
this.changed(e);
}
@Override
default void changedUpdate(DocumentEvent e) {
this.changed(e);
}
void changed(DocumentEvent e);
}

View File

@@ -97,10 +97,10 @@ public enum PanelName {
CLIENTE_DIRECCION_CREATE,
CLIENTE_DIRECCION_UPDATE,
COMPRAR_SEARCH,
COMPRAR_SELECCIONAR,
COMPRAR_VIEW,
COMPRAR_COMPRAR,
ORDEN_COMPRA_SEARCH,
ORDEN_COMPRA_ACEPTAR,
ORDEN_COMPRA_VIEW,
ORDEN_COMPRA_CREAR,
VENDER_SEARCH,
VENDER_VENDER,

View File

@@ -66,6 +66,14 @@ public class Libro {
)
private List<Categoria> categorias;
@ManyToMany
@JoinTable(
name = "libro_orden_compra",
joinColumns = @JoinColumn(name = "libro_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "orden_compra_id", referencedColumnName = "id")
)
private List<OrdenCompra> ordenCompras;
@ManyToOne
@JoinColumn(name = "editorial_id")
private Editorial editorial;
@@ -170,6 +178,15 @@ public class Libro {
this.ejemplares = ejemplar;
}
public List<OrdenCompra> getOrdenCompras() {
if (this.ordenCompras == null)
this.ordenCompras = new ArrayList<>();
return this.ordenCompras;
}
public void setOrdenCompras(List<OrdenCompra> ordenCompras) {
this.ordenCompras = ordenCompras;
}
@Override
public String toString() {

View File

@@ -0,0 +1,96 @@
package xyz.danielcortes.models;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "orden_compra")
public class OrdenCompra {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Integer id;
@Column(name = "estado")
private String estado;
@ManyToMany
@JoinTable(
name = "libro_orden_compra",
joinColumns = @JoinColumn(name = "orden_compra_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "libro_id", referencedColumnName = "id"))
private List<Libro> libros;
@ManyToOne
@JoinColumn(name = "distribuidor_id")
private Distribuidor distribuidor;
@ManyToOne
@JoinColumn(name = "compra_id")
private Compra compra;
@Column(name = "inserted_at")
private LocalDateTime insertedAt;
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public String getEstado() {
return this.estado;
}
public void setEstado(String estado) {
this.estado = estado;
}
public List<Libro> getLibros() {
if (this.libros == null)
this.libros = new ArrayList<>();
return this.libros;
}
public void setLibros(List<Libro> libros) {
this.libros = libros;
}
public Distribuidor getDistribuidor() {
return this.distribuidor;
}
public void setDistribuidor(Distribuidor distribuidor) {
this.distribuidor = distribuidor;
}
public Compra getCompra() {
return this.compra;
}
public void setCompra(Compra compra) {
this.compra = compra;
}
public LocalDateTime getInsertedAt() {
return this.insertedAt;
}
public void setInsertedAt(LocalDateTime insertedAt) {
this.insertedAt = insertedAt;
}
}

View File

@@ -0,0 +1,19 @@
package xyz.danielcortes.repository;
import java.util.List;
import javax.persistence.Query;
import xyz.danielcortes.framework.BaseRepository;
import xyz.danielcortes.models.OrdenCompra;
public class OrdenCompraRepository extends BaseRepository<OrdenCompra> {
public OrdenCompraRepository() {
super(OrdenCompra.class);
}
public List<OrdenCompra> search(String term) {
Query query = this.em.createQuery("SELECT o FROM OrdenCompra o WHERE LOWER(o.estado) LIKE :term");
query.setParameter("term", "%" + term.toLowerCase() + "%");
return query.getResultList();
}
}

View File

@@ -0,0 +1,50 @@
package xyz.danielcortes.validator;
import java.util.List;
import xyz.danielcortes.framework.ValidationResult;
import xyz.danielcortes.models.Compra;
import xyz.danielcortes.models.Distribuidor;
import xyz.danielcortes.models.Libro;
public class OrdenCompraValidator {
public ValidationResult validateEstado(String estado) {
if (estado == null) {
return new ValidationResult("No hay estado");
}
if (estado.isBlank()) {
return new ValidationResult("El estado esta vacio");
}
//Lo siento, me vi en la necesidad de hacer la validacion asi
// se ve mas cul
switch (estado) {
case "En Curso":
case "Aceptada":
case "Cancelada":
return ValidationResult.NON_ERROR;
default:
return new ValidationResult("El estado no es valido");
}
}
public ValidationResult validateLibros(List<Libro> libros) {
if (libros == null || libros.isEmpty()) {
return new ValidationResult("No hay libros");
}
return ValidationResult.NON_ERROR;
}
public ValidationResult validateDistribuidor(Distribuidor distribuidor) {
if (distribuidor == null) {
return new ValidationResult("No hay distribuidor");
}
return ValidationResult.NON_ERROR;
}
public ValidationResult validateCompra(Compra compra) {
if (compra == null) {
return new ValidationResult("No hay compra");
}
return ValidationResult.NON_ERROR;
}
}

View File

@@ -1,186 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.comprar.ComprarComprarPanel">
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="7" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="20" left="20" bottom="20" right="20"/>
<constraints>
<xy x="20" y="20" width="518" height="530"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="de524" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Libros:"/>
</properties>
</component>
<vspacer id="36014">
<constraints>
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<hspacer id="11118">
<constraints>
<grid row="6" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="43954">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="847b5" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Distribuidor:"/>
</properties>
</component>
<component id="66798" class="javax.swing.JComboBox" binding="distribuidorCombo" custom-create="true">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="400" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="2b462" class="javax.swing.JButton" binding="seleccionarButton" default-binding="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Seleccionar"/>
</properties>
</component>
<grid id="15262" layout-manager="GridLayoutManager" row-count="10" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="line" title="Factura"/>
<children>
<component id="3164e" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Folio:"/>
</properties>
</component>
<component id="3a289" class="javax.swing.JTextField" binding="folioField">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="400" height="-1"/>
</grid>
</constraints>
<properties>
<text value=""/>
</properties>
</component>
<component id="66882" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Precio Neto:"/>
</properties>
</component>
<component id="38890" class="javax.swing.JTextField" binding="precioNetoField">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="400" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="94d68" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Precio IVA:"/>
</properties>
</component>
<component id="2b4c9" class="javax.swing.JTextField" binding="precioIVAField">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="400" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="56f53" class="javax.swing.JLabel">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Precio Bruto:"/>
</properties>
</component>
<component id="bf663" class="javax.swing.JTextField" binding="precioBrutoField">
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="400" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="552e6" class="javax.swing.JLabel">
<constraints>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Fecha compra:"/>
</properties>
</component>
<component id="51579" class="com.github.lgooddatepicker.components.DatePicker" binding="fechaCompraField">
<constraints>
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="400" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
</children>
</grid>
<grid id="17d46" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="74b0c" class="javax.swing.JButton" binding="guardarButton" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value="Guardar"/>
</properties>
</component>
<component id="45282" class="javax.swing.JButton" binding="volverButton" default-binding="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value="Volver"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</form>

View File

@@ -1,200 +0,0 @@
package xyz.danielcortes.views.comprar;
import com.github.lgooddatepicker.components.DatePicker;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Insets;
import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.models.Distribuidor;
public class ComprarComprarPanel extends BasePanel {
private JPanel contentPane;
private JComboBox<Distribuidor> distribuidorCombo;
private DefaultComboBoxModel<Distribuidor> distribuidorModel;
private JButton seleccionarButton;
private JTextField folioField;
private JTextField precioNetoField;
private JTextField precioIVAField;
private JTextField precioBrutoField;
private DatePicker fechaCompraField;
private JButton guardarButton;
private JButton volverButton;
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
this.$$$setupUI$$$();
}
@Override
public JPanel getContentPane() {
return this.contentPane;
}
public JComboBox getDistribuidorCombo() {
return this.distribuidorCombo;
}
public JButton getSeleccionarButton() {
return this.seleccionarButton;
}
public JTextField getFolioField() {
return this.folioField;
}
public JTextField getPrecioNetoField() {
return this.precioNetoField;
}
public JTextField getPrecioIVAField() {
return this.precioIVAField;
}
public JTextField getPrecioBrutoField() {
return this.precioBrutoField;
}
public DatePicker getFechaCompraField() {
return this.fechaCompraField;
}
public JButton getGuardarButton() {
return this.guardarButton;
}
public JButton getVolverButton() {
return this.volverButton;
}
public DefaultComboBoxModel<Distribuidor> getDistribuidorModel() {
return this.distribuidorModel;
}
/**
* Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
createUIComponents();
contentPane = new JPanel();
contentPane.setLayout(new GridLayoutManager(7, 3, new Insets(20, 20, 20, 20), -1, -1));
final JLabel label1 = new JLabel();
label1.setText("Libros:");
contentPane.add(label1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final Spacer spacer1 = new Spacer();
contentPane.add(spacer1,
new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null,
null, null, 0, false));
final Spacer spacer2 = new Spacer();
contentPane.add(spacer2,
new GridConstraints(6, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null,
null, null, 0, false));
final Spacer spacer3 = new Spacer();
contentPane.add(spacer3,
new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null,
null, null, 0, false));
final JLabel label2 = new JLabel();
label2.setText("Distribuidor:");
contentPane.add(label2, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
contentPane.add(distribuidorCombo,
new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false));
seleccionarButton = new JButton();
seleccionarButton.setText("Seleccionar");
contentPane.add(seleccionarButton, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(10, 1, new Insets(10, 10, 10, 10), -1, -1));
contentPane.add(panel1, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), "Factura"));
final JLabel label3 = new JLabel();
label3.setText("Folio:");
panel1.add(label3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
folioField = new JTextField();
folioField.setText("");
panel1.add(folioField,
new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false));
final JLabel label4 = new JLabel();
label4.setText("Precio Neto:");
panel1.add(label4, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
precioNetoField = new JTextField();
panel1.add(precioNetoField,
new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false));
final JLabel label5 = new JLabel();
label5.setText("Precio IVA:");
panel1.add(label5, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
precioIVAField = new JTextField();
precioIVAField.setEditable(false);
panel1.add(precioIVAField,
new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false));
final JLabel label6 = new JLabel();
label6.setText("Precio Bruto:");
panel1.add(label6, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
precioBrutoField = new JTextField();
precioBrutoField.setEditable(false);
panel1.add(precioBrutoField,
new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false));
final JLabel label7 = new JLabel();
label7.setText("Fecha compra:");
panel1.add(label7, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
fechaCompraField = new DatePicker();
panel1.add(fechaCompraField,
new GridConstraints(9, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false));
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel2, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
guardarButton = new JButton();
guardarButton.setText("Guardar");
panel2.add(guardarButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
null, 0, false));
volverButton = new JButton();
volverButton.setText("Volver");
panel2.add(volverButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
null, 0, false));
}
private void createUIComponents() {
this.distribuidorModel = new DefaultComboBoxModel<>();
this.distribuidorCombo = new JComboBox<>(this.distribuidorModel);
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return contentPane;
}
}

View File

@@ -0,0 +1,158 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.orden_compra.OrdenCompraAceptarPanel">
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="14" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="20" left="20" bottom="20" right="20"/>
<constraints>
<xy x="20" y="20" width="486" height="491"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="a8906" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Folio:"/>
</properties>
</component>
<vspacer id="b5aea">
<constraints>
<grid row="13" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="bd65f" class="javax.swing.JTextField" binding="folioField">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="400" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<hspacer id="9e3ea">
<constraints>
<grid row="13" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="611be">
<constraints>
<grid row="13" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="3bdd0" class="javax.swing.JLabel">
<constraints>
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Precio Neto:"/>
</properties>
</component>
<component id="352ec" class="javax.swing.JTextField" binding="precioNetoField">
<constraints>
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="78cc8" class="javax.swing.JTextField" binding="ivaField">
<constraints>
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="d16b6" class="javax.swing.JTextField" binding="totalField">
<constraints>
<grid row="11" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="57cd3" class="javax.swing.JLabel">
<constraints>
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="IVA:"/>
</properties>
</component>
<component id="bb127" class="javax.swing.JLabel">
<constraints>
<grid row="10" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Total:"/>
</properties>
</component>
<component id="db02f" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Fecha Emision:"/>
</properties>
</component>
<component id="24785" class="com.github.lgooddatepicker.components.DatePicker" binding="fechaEmisionPicker">
<constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<grid id="f1fd0" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="12" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="d3f2e" class="javax.swing.JButton" binding="guardarButton" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value="Guardar"/>
</properties>
</component>
<component id="79e5d" class="javax.swing.JButton" binding="volverButton" default-binding="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value="Volver"/>
</properties>
</component>
</children>
</grid>
<component id="6286" class="javax.swing.JButton" binding="asignarButton" default-binding="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value="Asignar"/>
</properties>
</component>
<component id="c2699" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Ejemplares:"/>
</properties>
</component>
</children>
</grid>
</form>

View File

@@ -0,0 +1,167 @@
package xyz.danielcortes.views.orden_compra;
import com.github.lgooddatepicker.components.DatePicker;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import java.awt.Dimension;
import java.awt.Insets;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import xyz.danielcortes.framework.BasePanel;
public class OrdenCompraAceptarPanel extends BasePanel {
private JPanel contentPane;
private JTextField folioField;
private JTextField precioNetoField;
private JTextField ivaField;
private JTextField totalField;
private DatePicker fechaEmisionPicker;
private JButton asignarButton;
private JButton guardarButton;
private JButton volverButton;
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
this.$$$setupUI$$$();
}
@Override
public JPanel getContentPane() {
return this.contentPane;
}
public JTextField getFolioField() {
return this.folioField;
}
public JTextField getPrecioNetoField() {
return this.precioNetoField;
}
public JTextField getIvaField() {
return this.ivaField;
}
public JTextField getTotalField() {
return this.totalField;
}
public DatePicker getFechaEmisionPicker() {
return this.fechaEmisionPicker;
}
public JButton getAsignarButton() {
return this.asignarButton;
}
public JButton getGuardarButton() {
return this.guardarButton;
}
public JButton getVolverButton() {
return this.volverButton;
}
/**
* Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
contentPane = new JPanel();
contentPane.setLayout(new GridLayoutManager(14, 3, new Insets(20, 20, 20, 20), -1, -1));
final JLabel label1 = new JLabel();
label1.setText("Folio:");
contentPane.add(label1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final Spacer spacer1 = new Spacer();
contentPane.add(spacer1,
new GridConstraints(13, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null,
null, null, 0, false));
folioField = new JTextField();
contentPane.add(folioField,
new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false));
final Spacer spacer2 = new Spacer();
contentPane.add(spacer2,
new GridConstraints(13, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1,
null, null, null, 0, false));
final Spacer spacer3 = new Spacer();
contentPane.add(spacer3,
new GridConstraints(13, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1,
null, null, null, 0, false));
final JLabel label2 = new JLabel();
label2.setText("Precio Neto:");
contentPane.add(label2, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
precioNetoField = new JTextField();
contentPane.add(precioNetoField,
new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
ivaField = new JTextField();
ivaField.setEditable(false);
contentPane.add(ivaField,
new GridConstraints(9, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
totalField = new JTextField();
totalField.setEditable(false);
contentPane.add(totalField,
new GridConstraints(11, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
final JLabel label3 = new JLabel();
label3.setText("IVA:");
contentPane.add(label3, new GridConstraints(8, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JLabel label4 = new JLabel();
label4.setText("Total:");
contentPane.add(label4, new GridConstraints(10, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JLabel label5 = new JLabel();
label5.setText("Fecha Emision:");
contentPane.add(label5, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
fechaEmisionPicker = new DatePicker();
contentPane.add(fechaEmisionPicker,
new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel1, new GridConstraints(12, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
guardarButton = new JButton();
guardarButton.setText("Guardar");
panel1.add(guardarButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
null, 0, false));
volverButton = new JButton();
volverButton.setText("Volver");
panel1.add(volverButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
null, 0, false));
asignarButton = new JButton();
asignarButton.setText("Asignar");
contentPane.add(asignarButton, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
null, 0, false));
final JLabel label6 = new JLabel();
label6.setText("Ejemplares:");
contentPane.add(label6, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return contentPane;
}
}

View File

@@ -1,28 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.comprar.ComprarSeleccionarPanel">
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="5" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.orden_compra.OrdenCompraCrearPanel">
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="8" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="20" left="20" bottom="20" right="20"/>
<constraints>
<xy x="20" y="20" width="631" height="400"/>
<xy x="20" y="20" width="441" height="455"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<vspacer id="13b47">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="7" column="1" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<scrollpane id="3750c">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false">
<grid row="5" column="1" row-span="1" col-span="2" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="400" height="-1"/>
</grid>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="2e370" class="javax.swing.JTable" binding="ejemplaresTable" custom-create="true" default-binding="true">
<component id="2e370" class="javax.swing.JTable" binding="librosTable" custom-create="true">
<constraints/>
<properties/>
</component>
@@ -30,59 +30,25 @@
</scrollpane>
<hspacer id="32a85">
<constraints>
<grid row="4" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="7" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="bd6b7">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<grid id="5d741" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="5d741" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="4" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="db345" class="javax.swing.JComboBox" binding="librosCombo" custom-create="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="350" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="6693" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Libro:"/>
</properties>
</component>
<component id="5aecc" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Serie:"/>
</properties>
</component>
<component id="7cdc5" class="javax.swing.JTextField" binding="serieField">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value=""/>
</properties>
</component>
<component id="5c6b2" class="javax.swing.JButton" binding="agregarButton" default-binding="true">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
@@ -90,19 +56,9 @@
<text value="Agregar"/>
</properties>
</component>
</children>
</grid>
<grid id="ca98b" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="ef939" class="javax.swing.JButton" binding="removerButton">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
@@ -110,6 +66,16 @@
<text value="Remover"/>
</properties>
</component>
</children>
</grid>
<grid id="ca98b" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="6" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="f66dd" class="javax.swing.JButton" binding="guardarButton" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
@@ -132,6 +98,50 @@
</component>
</children>
</grid>
<component id="76afc" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Distribuidor:"/>
</properties>
</component>
<component id="f7fc5" class="javax.swing.JComboBox" binding="distribuidorCombo" custom-create="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="44e2c" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Cantidad:"/>
</properties>
</component>
<component id="6693" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Libro:"/>
</properties>
</component>
<component id="db345" class="javax.swing.JComboBox" binding="librosCombo" custom-create="true">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="51242" class="javax.swing.JSpinner" binding="cantidadSpinner" default-binding="true">
<constraints>
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="50" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
</children>
</grid>
</form>

View File

@@ -1,4 +1,4 @@
package xyz.danielcortes.views.comprar;
package xyz.danielcortes.views.orden_compra;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
@@ -12,25 +12,27 @@ import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.JTable;
import javax.swing.JTextField;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.framework.BaseTableModel;
import xyz.danielcortes.models.Ejemplar;
import xyz.danielcortes.models.Distribuidor;
import xyz.danielcortes.models.Libro;
public class ComprarSeleccionarPanel extends BasePanel {
public class OrdenCompraCrearPanel extends BasePanel {
private JPanel contentPane;
private JTable ejemplaresTable;
private BaseTableModel<Ejemplar> ejemplaresTableModel;
private JTable librosTable;
private BaseTableModel<Libro> libroTableModel;
private JComboBox<Libro> librosCombo;
private DefaultComboBoxModel<Libro> librosComboModel;
private JComboBox<Distribuidor> distribuidorCombo;
private DefaultComboBoxModel<Distribuidor> distribuidorComboModel;
private JButton agregarButton;
private JButton removerButton;
private JButton guardarButton;
private JButton volverButton;
private JTextField serieField;
private JSpinner cantidadSpinner;
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
@@ -44,14 +46,22 @@ public class ComprarSeleccionarPanel extends BasePanel {
return this.contentPane;
}
public JTable getEjemplaresTable() {
return this.ejemplaresTable;
public JTable getLibrosTable() {
return this.librosTable;
}
public JComboBox getLibrosCombo() {
public BaseTableModel<Libro> getLibroTableModel() {
return this.libroTableModel;
}
public JComboBox<Libro> getLibrosCombo() {
return this.librosCombo;
}
public DefaultComboBoxModel<Libro> getLibrosComboModel() {
return this.librosComboModel;
}
public JButton getAgregarButton() {
return this.agregarButton;
}
@@ -68,16 +78,16 @@ public class ComprarSeleccionarPanel extends BasePanel {
return this.volverButton;
}
public BaseTableModel<Ejemplar> getEjemplaresTableModel() {
return this.ejemplaresTableModel;
public JComboBox getDistribuidorCombo() {
return this.distribuidorCombo;
}
public JTextField getSerieField() {
return this.serieField;
public DefaultComboBoxModel<Distribuidor> getDistribuidorComboModel() {
return this.distribuidorComboModel;
}
public DefaultComboBoxModel<Libro> getLibrosComboModel() {
return this.librosComboModel;
public JSpinner getCantidadSpinner() {
return this.cantidadSpinner;
}
/**
@@ -88,60 +98,44 @@ public class ComprarSeleccionarPanel extends BasePanel {
private void $$$setupUI$$$() {
createUIComponents();
contentPane = new JPanel();
contentPane.setLayout(new GridLayoutManager(5, 3, new Insets(20, 20, 20, 20), -1, -1));
contentPane.setLayout(new GridLayoutManager(8, 4, new Insets(20, 20, 20, 20), -1, -1));
final Spacer spacer1 = new Spacer();
contentPane.add(spacer1,
new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null,
new GridConstraints(7, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null,
null, null, 0, false));
final JScrollPane scrollPane1 = new JScrollPane();
contentPane.add(scrollPane1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
contentPane.add(scrollPane1, new GridConstraints(5, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(400, -1), null, 0, false));
scrollPane1.setViewportView(ejemplaresTable);
scrollPane1.setViewportView(librosTable);
final Spacer spacer2 = new Spacer();
contentPane.add(spacer2,
new GridConstraints(4, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null,
new GridConstraints(7, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null,
null, null, 0, false));
final Spacer spacer3 = new Spacer();
contentPane.add(spacer3,
new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null,
new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null,
null, null, 0, false));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel1, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel1, new GridConstraints(4, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
panel1.add(librosCombo,
new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(350, -1), null, 0, false));
final JLabel label1 = new JLabel();
label1.setText("Libro:");
panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JLabel label2 = new JLabel();
label2.setText("Serie:");
panel1.add(label2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
serieField = new JTextField();
serieField.setText("");
panel1.add(serieField,
new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
agregarButton = new JButton();
agregarButton.setText("Agregar");
panel1.add(agregarButton, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
panel1.add(agregarButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
null, 0, false));
removerButton = new JButton();
removerButton.setText("Remover");
panel1.add(removerButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
null, 0, false));
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel2, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel2, new GridConstraints(6, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
removerButton = new JButton();
removerButton.setText("Remover");
panel2.add(removerButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
null, 0, false));
guardarButton = new JButton();
guardarButton.setText("Guardar");
panel2.add(guardarButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
@@ -152,30 +146,53 @@ public class ComprarSeleccionarPanel extends BasePanel {
panel2.add(volverButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
null, 0, false));
final JLabel label1 = new JLabel();
label1.setText("Distribuidor:");
contentPane.add(label1, new GridConstraints(0, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
contentPane.add(distribuidorCombo,
new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JLabel label2 = new JLabel();
label2.setText("Cantidad:");
contentPane.add(label2, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JLabel label3 = new JLabel();
label3.setText("Libro:");
contentPane.add(label3, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
contentPane.add(librosCombo,
new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
cantidadSpinner = new JSpinner();
contentPane.add(cantidadSpinner,
new GridConstraints(3, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(50, -1), null, 0, false));
}
private void createUIComponents() {
this.librosComboModel = new DefaultComboBoxModel<>();
this.librosCombo = new JComboBox<>(this.librosComboModel);
this.ejemplaresTableModel = new BaseTableModel<>(
new String[]{"ISBN", "Titulo", "Precio Referencial", "Serie"},
this.distribuidorComboModel = new DefaultComboBoxModel<>();
this.distribuidorCombo = new JComboBox<>(this.distribuidorComboModel);
this.libroTableModel = new BaseTableModel<>(
new String[]{"ISBN", "Titulo", "Precio Referencial"},
(rows, rowIndex, colIndex) -> {
switch (colIndex) {
case 0:
return rows.get(rowIndex).getLibro().getIsbn();
return rows.get(rowIndex).getIsbn();
case 1:
return rows.get(rowIndex).getLibro().getTitulo();
return rows.get(rowIndex).getTitulo();
case 2:
return rows.get(rowIndex).getLibro().getPrecioReferencia();
case 3:
return rows.get(rowIndex).getSerie();
return rows.get(rowIndex).getPrecioReferencia();
default:
return null;
}
}
);
this.ejemplaresTable = new JTable(this.ejemplaresTableModel);
this.librosTable = new JTable(this.libroTableModel);
}
/**
@@ -184,4 +201,5 @@ public class ComprarSeleccionarPanel extends BasePanel {
public JComponent $$$getRootComponent$$$() {
return contentPane;
}
}

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.comprar.ComprarSearchPanel">
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.orden_compra.OrdenCompraSearchPanel">
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="20" left="20" bottom="20" right="20"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
<xy x="20" y="20" width="510" height="400"/>
</constraints>
<properties/>
<border type="none"/>
@@ -57,14 +57,14 @@
<properties/>
<border type="none"/>
<children>
<component id="dd7c5" class="javax.swing.JButton" binding="comprarButton">
<component id="dd7c5" class="javax.swing.JButton" binding="crearButton">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value="Comprar"/>
<text value="Crear"/>
</properties>
</component>
<component id="5d466" class="javax.swing.JButton" binding="verButton">
@@ -74,7 +74,37 @@
</grid>
</constraints>
<properties>
<text value="Ver Orden de Compra"/>
<text value="Ver"/>
</properties>
</component>
</children>
</grid>
<grid id="c18d" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="c93c1" class="javax.swing.JButton" binding="cancelarButton">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value="Cancelar Orden"/>
</properties>
</component>
<component id="7d93a" class="javax.swing.JButton" binding="aceptarButton">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value="Recibir Orden"/>
</properties>
</component>
</children>

View File

@@ -1,4 +1,4 @@
package xyz.danielcortes.views.comprar;
package xyz.danielcortes.views.orden_compra;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
@@ -13,17 +13,19 @@ import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.framework.BaseTableModel;
import xyz.danielcortes.models.Compra;
import xyz.danielcortes.models.OrdenCompra;
public class ComprarSearchPanel extends BasePanel {
public class OrdenCompraSearchPanel extends BasePanel {
private JPanel contentPane;
private JTextField searchField;
private JButton buscarButton;
private JTable table;
private BaseTableModel<Compra> model;
private JButton comprarButton;
private BaseTableModel<OrdenCompra> model;
private JButton crearButton;
private JButton verButton;
private JButton cancelarButton;
private JButton aceptarButton;
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
@@ -32,6 +34,11 @@ public class ComprarSearchPanel extends BasePanel {
this.$$$setupUI$$$();
}
@Override
public JPanel getContentPane() {
return this.contentPane;
}
public JTextField getSearchField() {
return this.searchField;
}
@@ -44,21 +51,24 @@ public class ComprarSearchPanel extends BasePanel {
return this.table;
}
public BaseTableModel<Compra> getModel() {
public BaseTableModel<OrdenCompra> getModel() {
return this.model;
}
public JButton getComprarButton() {
return this.comprarButton;
public JButton getCrearButton() {
return this.crearButton;
}
public JButton getVerButton() {
return this.verButton;
}
@Override
public JPanel getContentPane() {
return this.contentPane;
public JButton getCancelarButton() {
return this.cancelarButton;
}
public JButton getAceptarButton() {
return this.aceptarButton;
}
/**
@@ -69,7 +79,7 @@ public class ComprarSearchPanel extends BasePanel {
private void $$$setupUI$$$() {
createUIComponents();
contentPane = new JPanel();
contentPane.setLayout(new GridLayoutManager(3, 1, new Insets(20, 20, 20, 20), -1, -1));
contentPane.setLayout(new GridLayoutManager(4, 1, new Insets(20, 20, 20, 20), -1, -1));
final JScrollPane scrollPane1 = new JScrollPane();
contentPane.add(scrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
@@ -94,35 +104,46 @@ public class ComprarSearchPanel extends BasePanel {
contentPane.add(panel2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
comprarButton = new JButton();
comprarButton.setText("Comprar");
panel2.add(comprarButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
crearButton = new JButton();
crearButton.setText("Crear");
panel2.add(crearButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
null, 0, false));
verButton = new JButton();
verButton.setText("Ver Orden de Compra");
verButton.setText("Ver");
panel2.add(verButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
null, 0, false));
final JPanel panel3 = new JPanel();
panel3.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel3, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
cancelarButton = new JButton();
cancelarButton.setText("Cancelar Orden");
panel3.add(cancelarButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
null, 0, false));
aceptarButton = new JButton();
aceptarButton.setText("Recibir Orden");
panel3.add(aceptarButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
null, 0, false));
}
private void createUIComponents() {
this.model = new BaseTableModel<>(
new String[]{"Folio Factura", "Precio Neto", "Precio Bruto", "Distribuidor", "Fecha Compra", "Nº Libros Comprados"},
new String[]{"Distribuidor", "Nº Libros", "Estado", "Fecha Emision"},
(row, rowIndex, colIndex) -> {
switch (colIndex) {
case 0:
return row.get(rowIndex).getFactura().getFolio();
case 1:
return row.get(rowIndex).getFactura().getPrecioNeto();
case 2:
return row.get(rowIndex).getFactura().getPrecioBruto();
case 3:
return row.get(rowIndex).getDistribuidor().getRut();
case 4:
return row.get(rowIndex).getFactura().getFechaVenta();
case 6:
return row.get(rowIndex).getEjemplares().size();
case 1:
return row.get(rowIndex).getLibros().size();
case 2:
return row.get(rowIndex).getEstado();
case 3:
return row.get(rowIndex).getInsertedAt();
default:
return null;
}

View File

@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.orden_compra.OrdenCompraViewPanel">
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="5" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="20" left="20" bottom="20" right="20"/>
<constraints>
<xy x="20" y="20" width="441" height="455"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<vspacer id="13b47">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<scrollpane id="3750c">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="400" height="-1"/>
</grid>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="2e370" class="javax.swing.JTable" binding="librosTable" custom-create="true">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
<hspacer id="32a85">
<constraints>
<grid row="4" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="bd6b7">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<grid id="ca98b" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="90c0e" class="javax.swing.JButton" binding="volverButton" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value="Volver"/>
</properties>
</component>
</children>
</grid>
<component id="76afc" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Distribuidor:"/>
</properties>
</component>
<component id="d0d25" class="javax.swing.JTextField" binding="distribuidorField">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
</children>
</grid>
</form>

View File

@@ -0,0 +1,128 @@
package xyz.danielcortes.views.orden_compra;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import java.awt.Dimension;
import java.awt.Insets;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.framework.BaseTableModel;
import xyz.danielcortes.models.Libro;
public class OrdenCompraViewPanel extends BasePanel {
private JPanel contentPane;
private JTable librosTable;
private BaseTableModel<Libro> libroTableModel;
private JButton volverButton;
private JTextField distribuidorField;
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
this.$$$setupUI$$$();
}
@Override
public JPanel getContentPane() {
return this.contentPane;
}
public JTable getLibrosTable() {
return this.librosTable;
}
public BaseTableModel<Libro> getLibroTableModel() {
return this.libroTableModel;
}
public JButton getVolverButton() {
return this.volverButton;
}
public JTextField getDistribuidorField() {
return this.distribuidorField;
}
/**
* Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
createUIComponents();
contentPane = new JPanel();
contentPane.setLayout(new GridLayoutManager(5, 3, new Insets(20, 20, 20, 20), -1, -1));
final Spacer spacer1 = new Spacer();
contentPane.add(spacer1,
new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null,
null, null, 0, false));
final JScrollPane scrollPane1 = new JScrollPane();
contentPane.add(scrollPane1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(400, -1), null, 0, false));
scrollPane1.setViewportView(librosTable);
final Spacer spacer2 = new Spacer();
contentPane.add(spacer2,
new GridConstraints(4, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null,
null, null, 0, false));
final Spacer spacer3 = new Spacer();
contentPane.add(spacer3,
new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null,
null, null, 0, false));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel1, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
volverButton = new JButton();
volverButton.setText("Volver");
panel1.add(volverButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1),
null, 0, false));
final JLabel label1 = new JLabel();
label1.setText("Distribuidor:");
contentPane.add(label1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
distribuidorField = new JTextField();
distribuidorField.setEditable(false);
contentPane.add(distribuidorField,
new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
}
private void createUIComponents() {
this.libroTableModel = new BaseTableModel<>(
new String[]{"ISBN", "Titulo", "Precio Referencial"},
(rows, rowIndex, colIndex) -> {
switch (colIndex) {
case 0:
return rows.get(rowIndex).getIsbn();
case 1:
return rows.get(rowIndex).getTitulo();
case 2:
return rows.get(rowIndex).getPrecioReferencia();
default:
return null;
}
}
);
this.librosTable = new JTable(this.libroTableModel);
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return contentPane;
}
}