From 9d86f759910e95defca129096810d95c39344244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Cort=C3=A9s?= Date: Thu, 13 Jun 2019 13:05:58 -0400 Subject: [PATCH] Clientes <3 --- .idea/saveactions_settings.xml | 18 + .idea/sqldialects.xml | 6 - script.sql => create.sql | 79 ---- data.sql | 354 ++++++++++++++++++ .../controllers/LaunchController.java | 28 +- .../cliente/ClienteCreateController.java | 90 +++++ .../cliente/ClienteSearchController.java | 121 ++++++ .../cliente/ClienteUpdateController.java | 107 ++++++ .../cliente/ClienteViewController.java | 71 ++++ .../correo/CorreoSearchController.java | 14 +- .../xyz/danielcortes/framework/PanelName.java | 5 + .../java/xyz/danielcortes/models/Cliente.java | 123 ++++++ .../java/xyz/danielcortes/models/Correo.java | 29 +- .../xyz/danielcortes/models/Direccion.java | 31 +- .../xyz/danielcortes/models/Telefono.java | 33 +- .../repository/ClienteRespository.java | 29 ++ .../validator/ClienteValidator.java | 88 +++++ .../xyz/danielcortes/views/LaunchFrame.java | 1 + .../cliente/ClienteCreatePanel.form | 138 +++++++ .../cliente/ClienteCreatePanel.java | 151 ++++++++ .../cliente/ClienteSearchPanel.form | 96 +++++ .../cliente/ClienteSearchPanel.java | 154 ++++++++ .../cliente/ClienteUpdatePanel.form | 138 +++++++ .../cliente/ClienteUpdatePanel.java | 151 ++++++++ .../cliente/ClienteViewPanel.form | 169 +++++++++ .../cliente/ClienteViewPanel.java | 177 +++++++++ 26 files changed, 2257 insertions(+), 144 deletions(-) create mode 100644 .idea/saveactions_settings.xml delete mode 100644 .idea/sqldialects.xml rename script.sql => create.sql (84%) create mode 100644 data.sql create mode 100644 src/main/java/xyz/danielcortes/controllers/mantenedores/cliente/ClienteCreateController.java create mode 100644 src/main/java/xyz/danielcortes/controllers/mantenedores/cliente/ClienteSearchController.java create mode 100644 src/main/java/xyz/danielcortes/controllers/mantenedores/cliente/ClienteUpdateController.java create mode 100644 src/main/java/xyz/danielcortes/controllers/mantenedores/cliente/ClienteViewController.java create mode 100644 src/main/java/xyz/danielcortes/models/Cliente.java create mode 100644 src/main/java/xyz/danielcortes/repository/ClienteRespository.java create mode 100644 src/main/java/xyz/danielcortes/validator/ClienteValidator.java create mode 100644 src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteCreatePanel.form create mode 100644 src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteCreatePanel.java create mode 100644 src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteSearchPanel.form create mode 100644 src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteSearchPanel.java create mode 100644 src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteUpdatePanel.form create mode 100644 src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteUpdatePanel.java create mode 100644 src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteViewPanel.form create mode 100644 src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteViewPanel.java diff --git a/.idea/saveactions_settings.xml b/.idea/saveactions_settings.xml new file mode 100644 index 0000000..77a6cdc --- /dev/null +++ b/.idea/saveactions_settings.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml deleted file mode 100644 index acd496b..0000000 --- a/.idea/sqldialects.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/script.sql b/create.sql similarity index 84% rename from script.sql rename to create.sql index 45de6d0..8d8eec2 100644 --- a/script.sql +++ b/create.sql @@ -366,82 +366,3 @@ create table usuario foreign key (trabajador_id) references trabajador (id) on delete cascade on update cascade, inserted_at timestamp default current_timestamp ); - -#--------------------------------------------------------------------------------# -#------------------------Poblar con datos iniciales------------------------------# -#--------------------------------------------------------------------------------# - -insert into estado (nombre) -values ('Vendido'), - ('Arrendado'), - ('Disponible'); - -insert into idioma (nombre) -values ('Español'), - ('Ingles'), - ('Portuges'), - ('Aleman'), - ('Ruso'), - ('Japones'); - -insert into editorial (nombre) -values ('Editorial N1'), - ('Editorial N2'), - ('Editorial N3'); - -insert into categoria (nombre) -values ('Terror'), - ('Aventura'), - ('Fantasia'); - -insert into autor(nombre, apellido_paterno, apellido_materno) -values ('Howard Philips', 'Lovecraft', NULL), - ('Stephen', 'King', NULL), - ('Brandon', 'Sanderson', NULL); - -insert into libro (editorial_id, isbn, ano_publicacion, numero_paginas, titulo, precio_referencia) -values (1, '0-765-31178-X', 2006, 541, 'Mistborn: The Final Empire', 10000), - (1, '0-765-31688-9', 2007, 590, 'Mistborn: The Well of Ascension', 10000), - (1, '978-0-7653-1689-9', 2008, 572, 'Mistborn: The Hero of Ages', 10000), - (2, '1231231231232', 1931, 100, 'The Shadow over Innsmouth', 10000), - (2, '1231231231232', 1933, 100, 'The Dreams in the Witch House', 10000), - (2, '1231231231232', 1936, 100, 'At the Mountains of Madness', 10000), - (3, '0385086954', 1974, 199, 'Carrie', 10000), - (3, '978-0-670-26077-5', 1979, 428, 'The Dead Zone', 10000), - (3, '0-670-81302-8', 1986, 1138, 'It', 10000); - -insert into libro_autor(libro_id, autor_id) -values (1, 3), - (2, 3), - (3, 3), - (4, 1), - (5, 1), - (6, 1), - (7, 2), - (8, 2), - (9, 2); - -insert into libro_categoria(libro_id, categoria_id) -values (1, 3), - (2, 3), - (3, 3), - (4, 1), - (5, 1), - (6, 1), - (7, 1), - (8, 1), - (9, 1); - -insert into libro_idioma(libro_id, idioma_id) -values (1, 2), - (2, 2), - (3, 2), - (4, 2), - (5, 2), - (6, 2), - (7, 2), - (8, 2), - (9, 2); - -INSERT INTO trabajador -VALUES (1, '197638990', 'Daniel', 'Cortes', 'Pincheira', '2019-06-04', '2019-06-04 18:12:55'); \ No newline at end of file diff --git a/data.sql b/data.sql new file mode 100644 index 0000000..db43400 --- /dev/null +++ b/data.sql @@ -0,0 +1,354 @@ +-- MySQL dump 10.17 Distrib 10.3.15-MariaDB, for Linux (x86_64) +-- +-- Host: localhost Database: biblioteca +-- ------------------------------------------------------ +-- Server version 10.3.15-MariaDB + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Dumping data for table `arriendo` +-- + +LOCK TABLES `arriendo` WRITE; +/*!40000 ALTER TABLE `arriendo` DISABLE KEYS */; +/*!40000 ALTER TABLE `arriendo` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `autor` +-- + +LOCK TABLES `autor` WRITE; +/*!40000 ALTER TABLE `autor` DISABLE KEYS */; +INSERT INTO `autor` VALUES (1,'Howard Philips','Lovecraft',NULL,'2019-06-12 16:18:57'),(2,'Stephen','King',NULL,'2019-06-12 16:18:57'),(3,'Brandon','Sanderson',NULL,'2019-06-12 16:18:57'); +/*!40000 ALTER TABLE `autor` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `boleta` +-- + +LOCK TABLES `boleta` WRITE; +/*!40000 ALTER TABLE `boleta` DISABLE KEYS */; +/*!40000 ALTER TABLE `boleta` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `categoria` +-- + +LOCK TABLES `categoria` WRITE; +/*!40000 ALTER TABLE `categoria` DISABLE KEYS */; +INSERT INTO `categoria` VALUES (1,'Terror','2019-06-12 16:18:57'),(2,'Aventura','2019-06-12 16:18:57'),(3,'Fantasia','2019-06-12 16:18:57'); +/*!40000 ALTER TABLE `categoria` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `cliente` +-- + +LOCK TABLES `cliente` WRITE; +/*!40000 ALTER TABLE `cliente` DISABLE KEYS */; +INSERT INTO `cliente` VALUES (1,'21786653-7','Cliente','1','1','2019-06-17','2019-06-13 16:01:33'),(2,'17181388-3','Cliente','2','2','2019-06-13','2019-06-13 16:04:02'); +/*!40000 ALTER TABLE `cliente` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `cliente_correo` +-- + +LOCK TABLES `cliente_correo` WRITE; +/*!40000 ALTER TABLE `cliente_correo` DISABLE KEYS */; +/*!40000 ALTER TABLE `cliente_correo` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `cliente_direccion` +-- + +LOCK TABLES `cliente_direccion` WRITE; +/*!40000 ALTER TABLE `cliente_direccion` DISABLE KEYS */; +/*!40000 ALTER TABLE `cliente_direccion` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `cliente_telefono` +-- + +LOCK TABLES `cliente_telefono` WRITE; +/*!40000 ALTER TABLE `cliente_telefono` DISABLE KEYS */; +/*!40000 ALTER TABLE `cliente_telefono` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `compra` +-- + +LOCK TABLES `compra` WRITE; +/*!40000 ALTER TABLE `compra` DISABLE KEYS */; +/*!40000 ALTER TABLE `compra` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `correo` +-- + +LOCK TABLES `correo` WRITE; +/*!40000 ALTER TABLE `correo` DISABLE KEYS */; +/*!40000 ALTER TABLE `correo` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `direccion` +-- + +LOCK TABLES `direccion` WRITE; +/*!40000 ALTER TABLE `direccion` DISABLE KEYS */; +/*!40000 ALTER TABLE `direccion` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `distribuidor` +-- + +LOCK TABLES `distribuidor` WRITE; +/*!40000 ALTER TABLE `distribuidor` DISABLE KEYS */; +INSERT INTO `distribuidor` VALUES (2,1,'19763899-0','2019-06-13 03:08:17'),(3,2,'19763899-0','2019-06-13 03:08:23'),(4,1,'19763899-0','2019-06-13 03:08:25'),(5,1,'19763899-0','2019-06-13 03:08:27'); +/*!40000 ALTER TABLE `distribuidor` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `distribuidor_correo` +-- + +LOCK TABLES `distribuidor_correo` WRITE; +/*!40000 ALTER TABLE `distribuidor_correo` DISABLE KEYS */; +/*!40000 ALTER TABLE `distribuidor_correo` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `distribuidor_direccion` +-- + +LOCK TABLES `distribuidor_direccion` WRITE; +/*!40000 ALTER TABLE `distribuidor_direccion` DISABLE KEYS */; +/*!40000 ALTER TABLE `distribuidor_direccion` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `distribuidor_telefono` +-- + +LOCK TABLES `distribuidor_telefono` WRITE; +/*!40000 ALTER TABLE `distribuidor_telefono` DISABLE KEYS */; +/*!40000 ALTER TABLE `distribuidor_telefono` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `editorial` +-- + +LOCK TABLES `editorial` WRITE; +/*!40000 ALTER TABLE `editorial` DISABLE KEYS */; +INSERT INTO `editorial` VALUES (1,'Editorial N1','2019-06-12 16:18:57'),(2,'Editorial N2','2019-06-12 16:18:57'),(3,'Editorial N3','2019-06-12 16:18:57'); +/*!40000 ALTER TABLE `editorial` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `ejemplar` +-- + +LOCK TABLES `ejemplar` WRITE; +/*!40000 ALTER TABLE `ejemplar` DISABLE KEYS */; +/*!40000 ALTER TABLE `ejemplar` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `empresa` +-- + +LOCK TABLES `empresa` WRITE; +/*!40000 ALTER TABLE `empresa` DISABLE KEYS */; +INSERT INTO `empresa` VALUES (1,'Empresa 1','2019-06-13 00:39:50'),(2,'Empresa 2','2019-06-13 00:39:52'); +/*!40000 ALTER TABLE `empresa` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `estado` +-- + +LOCK TABLES `estado` WRITE; +/*!40000 ALTER TABLE `estado` DISABLE KEYS */; +INSERT INTO `estado` VALUES (1,'Vendido','2019-06-12 16:18:57'),(2,'Arrendado','2019-06-12 16:18:57'),(3,'Disponible','2019-06-12 16:18:57'); +/*!40000 ALTER TABLE `estado` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `factura` +-- + +LOCK TABLES `factura` WRITE; +/*!40000 ALTER TABLE `factura` DISABLE KEYS */; +/*!40000 ALTER TABLE `factura` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `idioma` +-- + +LOCK TABLES `idioma` WRITE; +/*!40000 ALTER TABLE `idioma` DISABLE KEYS */; +INSERT INTO `idioma` VALUES (1,'Español','2019-06-12 16:18:57'),(2,'Ingles','2019-06-12 16:18:57'),(3,'Portuges','2019-06-12 16:18:57'),(4,'Aleman','2019-06-12 16:18:57'),(5,'Ruso','2019-06-12 16:18:57'),(6,'Japones','2019-06-12 16:18:57'); +/*!40000 ALTER TABLE `idioma` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `libro` +-- + +LOCK TABLES `libro` WRITE; +/*!40000 ALTER TABLE `libro` DISABLE KEYS */; +INSERT INTO `libro` VALUES (1,1,'0-765-31178-X',2006,541,'Mistborn: The Final Empire',10000,'2019-06-12 16:18:57'),(2,1,'0-765-31688-9',2007,590,'Mistborn: The Well of Ascension',10000,'2019-06-12 16:18:57'),(3,1,'978-0-7653-1689-9',2008,572,'Mistborn: The Hero of Ages',10000,'2019-06-12 16:18:57'),(4,2,'1231231231232',1931,100,'The Shadow over Innsmouth',10000,'2019-06-12 16:18:57'),(5,2,'1231231231232',1933,100,'The Dreams in the Witch House',10000,'2019-06-12 16:18:57'),(6,2,'1231231231232',1936,100,'At the Mountains of Madness',10000,'2019-06-12 16:18:57'),(7,3,'0385086954',1974,199,'Carrie',10000,'2019-06-12 16:18:57'),(8,3,'978-0-670-26077-5',1979,428,'The Dead Zone',10000,'2019-06-12 16:18:57'),(9,3,'0-670-81302-8',1986,1138,'It',10000,'2019-06-12 16:18:57'); +/*!40000 ALTER TABLE `libro` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `libro_arriendo` +-- + +LOCK TABLES `libro_arriendo` WRITE; +/*!40000 ALTER TABLE `libro_arriendo` DISABLE KEYS */; +/*!40000 ALTER TABLE `libro_arriendo` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `libro_autor` +-- + +LOCK TABLES `libro_autor` WRITE; +/*!40000 ALTER TABLE `libro_autor` DISABLE KEYS */; +INSERT INTO `libro_autor` VALUES (1,3),(2,3),(3,3),(4,1),(5,1),(6,1),(7,2),(8,2),(9,2); +/*!40000 ALTER TABLE `libro_autor` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `libro_categoria` +-- + +LOCK TABLES `libro_categoria` WRITE; +/*!40000 ALTER TABLE `libro_categoria` DISABLE KEYS */; +INSERT INTO `libro_categoria` VALUES (1,3),(2,3),(3,3),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1); +/*!40000 ALTER TABLE `libro_categoria` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `libro_compra` +-- + +LOCK TABLES `libro_compra` WRITE; +/*!40000 ALTER TABLE `libro_compra` DISABLE KEYS */; +/*!40000 ALTER TABLE `libro_compra` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `libro_idioma` +-- + +LOCK TABLES `libro_idioma` WRITE; +/*!40000 ALTER TABLE `libro_idioma` DISABLE KEYS */; +INSERT INTO `libro_idioma` VALUES (1,2),(2,2),(3,2),(4,2),(5,2),(6,2),(7,2),(8,2),(9,2); +/*!40000 ALTER TABLE `libro_idioma` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `libro_venta` +-- + +LOCK TABLES `libro_venta` WRITE; +/*!40000 ALTER TABLE `libro_venta` DISABLE KEYS */; +/*!40000 ALTER TABLE `libro_venta` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `telefono` +-- + +LOCK TABLES `telefono` WRITE; +/*!40000 ALTER TABLE `telefono` DISABLE KEYS */; +/*!40000 ALTER TABLE `telefono` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `trabajador` +-- + +LOCK TABLES `trabajador` WRITE; +/*!40000 ALTER TABLE `trabajador` DISABLE KEYS */; +INSERT INTO `trabajador` VALUES (2,'19763899-0','Daniel','Cortes','Pincheira','2019-06-13','2019-06-13 16:04:42'),(3,'10768789-0','Trabajador','N','2','2019-06-13','2019-06-13 16:05:17'),(4,'9717478-4','Trabajador','N','3','2019-06-13','2019-06-13 16:05:27'); +/*!40000 ALTER TABLE `trabajador` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `trabajador_correo` +-- + +LOCK TABLES `trabajador_correo` WRITE; +/*!40000 ALTER TABLE `trabajador_correo` DISABLE KEYS */; +/*!40000 ALTER TABLE `trabajador_correo` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `trabajador_direccion` +-- + +LOCK TABLES `trabajador_direccion` WRITE; +/*!40000 ALTER TABLE `trabajador_direccion` DISABLE KEYS */; +/*!40000 ALTER TABLE `trabajador_direccion` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `trabajador_telefono` +-- + +LOCK TABLES `trabajador_telefono` WRITE; +/*!40000 ALTER TABLE `trabajador_telefono` DISABLE KEYS */; +/*!40000 ALTER TABLE `trabajador_telefono` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `usuario` +-- + +LOCK TABLES `usuario` WRITE; +/*!40000 ALTER TABLE `usuario` DISABLE KEYS */; +INSERT INTO `usuario` VALUES (2,'admin',0x243168097E0BA82B896F348BABCEB600A8DCA30488C6F238F97FD8737BD00B27,0x3564ECCCD85CF0583F9C090602E998B7,2,'2019-06-13 16:04:53'); +/*!40000 ALTER TABLE `usuario` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `venta` +-- + +LOCK TABLES `venta` WRITE; +/*!40000 ALTER TABLE `venta` DISABLE KEYS */; +/*!40000 ALTER TABLE `venta` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2019-06-13 12:10:44 diff --git a/src/main/java/xyz/danielcortes/controllers/LaunchController.java b/src/main/java/xyz/danielcortes/controllers/LaunchController.java index 6c02454..532435a 100644 --- a/src/main/java/xyz/danielcortes/controllers/LaunchController.java +++ b/src/main/java/xyz/danielcortes/controllers/LaunchController.java @@ -14,6 +14,10 @@ import xyz.danielcortes.controllers.mantenedores.categoria.CategoriaCreateContro import xyz.danielcortes.controllers.mantenedores.categoria.CategoriaSearchController; import xyz.danielcortes.controllers.mantenedores.categoria.CategoriaUpdateController; import xyz.danielcortes.controllers.mantenedores.categoria.CategoriaViewController; +import xyz.danielcortes.controllers.mantenedores.cliente.ClienteCreateController; +import xyz.danielcortes.controllers.mantenedores.cliente.ClienteSearchController; +import xyz.danielcortes.controllers.mantenedores.cliente.ClienteUpdateController; +import xyz.danielcortes.controllers.mantenedores.cliente.ClienteViewController; import xyz.danielcortes.controllers.mantenedores.distribuidor.DistribuidorCreateController; import xyz.danielcortes.controllers.mantenedores.distribuidor.DistribuidorSearchController; import xyz.danielcortes.controllers.mantenedores.distribuidor.DistribuidorUpdateController; @@ -65,6 +69,10 @@ import xyz.danielcortes.views.mantenedores.categoria.CategoriaCreatePanel; import xyz.danielcortes.views.mantenedores.categoria.CategoriaSearchPanel; import xyz.danielcortes.views.mantenedores.categoria.CategoriaUpdatePanel; import xyz.danielcortes.views.mantenedores.categoria.CategoriaViewPanel; +import xyz.danielcortes.views.mantenedores.cliente.ClienteCreatePanel; +import xyz.danielcortes.views.mantenedores.cliente.ClienteSearchPanel; +import xyz.danielcortes.views.mantenedores.cliente.ClienteUpdatePanel; +import xyz.danielcortes.views.mantenedores.cliente.ClienteViewPanel; import xyz.danielcortes.views.mantenedores.correo.CorreoCreatePanel; import xyz.danielcortes.views.mantenedores.correo.CorreoSearchPanel; import xyz.danielcortes.views.mantenedores.correo.CorreoUpdatePanel; @@ -117,7 +125,7 @@ public class LaunchController { } private void create() { - frame = new LaunchFrame(); + this.frame = new LaunchFrame(); this.createCards(); this.createMenuBar(); } @@ -160,6 +168,11 @@ public class LaunchController { this.controllers.put(PanelName.DISTRIBUIDOR_CREATE, new DistribuidorCreateController(new DistribuidorCreatePanel(), this)); this.controllers.put(PanelName.DISTRIBUIDOR_UPDATE, new DistribuidorUpdateController(new DistribuidorUpdatePanel(), this)); + this.controllers.put(PanelName.CLIENTE_VIEW, new ClienteViewController(new ClienteViewPanel(), this)); + this.controllers.put(PanelName.CLIENTE_SEARCH, new ClienteSearchController(new ClienteSearchPanel(), this)); + this.controllers.put(PanelName.CLIENTE_CREATE, new ClienteCreateController(new ClienteCreatePanel(), this)); + this.controllers.put(PanelName.CLIENTE_UPDATE, new ClienteUpdateController(new ClienteUpdatePanel(), this)); + this.controllers.put(PanelName.EMPRESA_VIEW, new EmpresaViewController(new EmpresaViewPanel(), this)); this.controllers.put(PanelName.EMPRESA_SEARCH, new EmpresaSearchController(new EmpresaSearchPanel(), this)); this.controllers.put(PanelName.EMPRESA_CREATE, new EmpresaCreateController(new EmpresaCreatePanel(), this)); @@ -194,8 +207,8 @@ public class LaunchController { private void createMenuBar() { JMenuBar menuBar = new JMenuBar(); - menuBar.add(createMantenedoresMenu()); - menuBar.add(createComprarMenu()); + menuBar.add(this.createMantenedoresMenu()); + menuBar.add(this.createComprarMenu()); this.frame.setJMenuBar(menuBar); } @@ -211,6 +224,7 @@ public class LaunchController { JMenuItem trabajadoresItem = new JMenuItem("Trabajadores"); JMenuItem empresasItem = new JMenuItem("Empresas"); JMenuItem distribuidoresItem = new JMenuItem("Distribuidores"); + JMenuItem clientesItem = new JMenuItem("Clientes"); autoresItem.addActionListener(e -> this.showCard(PanelName.AUTOR_SEARCH)); idiomasItem.addActionListener(e -> this.showCard(PanelName.IDIOMA_SEARCH)); @@ -218,17 +232,19 @@ public class LaunchController { categoriasItem.addActionListener(e -> this.showCard(PanelName.CATEGORIA_SEARCH)); editorialesItem.addActionListener(e -> this.showCard(PanelName.EDITORIAL_SEARCH)); trabajadoresItem.addActionListener(e -> this.showCard(PanelName.TRABAJADOR_SEARCH)); - empresasItem.addActionListener(e -> this.showCard(PanelName.EMPRESA_SEARCH)); distribuidoresItem.addActionListener(e -> this.showCard(PanelName.DISTRIBUIDOR_SEARCH)); + clientesItem.addActionListener(e -> this.showCard(PanelName.CLIENTE_SEARCH)); + empresasItem.addActionListener(e -> this.showCard(PanelName.EMPRESA_SEARCH)); - mantenedoresMenu.add(librosItem ); + mantenedoresMenu.add(librosItem); mantenedoresMenu.add(autoresItem); mantenedoresMenu.add(idiomasItem); mantenedoresMenu.add(categoriasItem); mantenedoresMenu.add(editorialesItem); mantenedoresMenu.add(trabajadoresItem); - mantenedoresMenu.add(empresasItem); mantenedoresMenu.add(distribuidoresItem); + mantenedoresMenu.add(clientesItem); + mantenedoresMenu.add(empresasItem); return mantenedoresMenu; } diff --git a/src/main/java/xyz/danielcortes/controllers/mantenedores/cliente/ClienteCreateController.java b/src/main/java/xyz/danielcortes/controllers/mantenedores/cliente/ClienteCreateController.java new file mode 100644 index 0000000..eea42b9 --- /dev/null +++ b/src/main/java/xyz/danielcortes/controllers/mantenedores/cliente/ClienteCreateController.java @@ -0,0 +1,90 @@ +package xyz.danielcortes.controllers.mantenedores.cliente; + +import java.time.LocalDate; +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.Cliente; +import xyz.danielcortes.repository.ClienteRespository; +import xyz.danielcortes.validator.ClienteValidator; +import xyz.danielcortes.views.mantenedores.cliente.ClienteCreatePanel; + +public class ClienteCreateController extends BaseController { + + private ClienteCreatePanel view; + private ClienteRespository respository; + private ClienteValidator validator; + + public ClienteCreateController(ClienteCreatePanel view, LaunchController parent) { + super(parent); + this.view = view; + this.respository = new ClienteRespository(); + this.validator = new ClienteValidator(this.respository); + this.setupListeners(); + } + + @Override + public void show() { + this.view.getRutField().requestFocus(); + } + + private void setupListeners() { + this.view.getGuardarButton().addActionListener(e -> this.save()); + this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.CLIENTE_SEARCH)); + } + + private void save() { + String rut = this.view.getRutField().getText(); + ValidationResult rutValidation = this.validator.validateRut(rut); + if (rutValidation.hasError()) { + rutValidation.showErrorDialog(); + return; + } + + String nombre = this.view.getNombreField().getText(); + ValidationResult nombreValidation = this.validator.validateNombre(nombre); + if (nombreValidation.hasError()) { + nombreValidation.showErrorDialog(); + return; + } + + String apellidoPaterno = this.view.getApellidoPaternoField().getText(); + ValidationResult apellidoPaternoValidation = this.validator.validateApellidoPaterno(apellidoPaterno); + if (apellidoPaternoValidation.hasError()) { + apellidoPaternoValidation.showErrorDialog(); + return; + } + + String apellidoMaterno = this.view.getApellidoMaternoField().getText(); + ValidationResult apellidoMaternoValidation = this.validator.validateApellidoMaterno(apellidoMaterno); + if (apellidoMaternoValidation.hasError()) { + apellidoMaternoValidation.showErrorDialog(); + return; + } + + LocalDate fechaNacimiento = this.view.getFechaNacimientoPicker().getDate(); + ValidationResult fechaContratoValidation = this.validator.validateFechaNacimiento(fechaNacimiento); + if (fechaContratoValidation.hasError()) { + fechaContratoValidation.showErrorDialog(); + return; + } + + Cliente cliente = new Cliente(); + cliente.setRut(rut); + cliente.setNombre(nombre); + cliente.setApellidoPaterno(apellidoPaterno); + cliente.setApellidoMaterno(apellidoMaterno); + cliente.setFechaNacimiento(fechaNacimiento); + + this.respository.save(cliente); + + this.getParentController().showCard(PanelName.CLIENTE_SEARCH); + } + + @Override + public BasePanel getView() { + return this.view; + } +} diff --git a/src/main/java/xyz/danielcortes/controllers/mantenedores/cliente/ClienteSearchController.java b/src/main/java/xyz/danielcortes/controllers/mantenedores/cliente/ClienteSearchController.java new file mode 100644 index 0000000..213874d --- /dev/null +++ b/src/main/java/xyz/danielcortes/controllers/mantenedores/cliente/ClienteSearchController.java @@ -0,0 +1,121 @@ +package xyz.danielcortes.controllers.mantenedores.cliente; + +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.Cliente; +import xyz.danielcortes.repository.ClienteRespository; +import xyz.danielcortes.validator.ClienteValidator; +import xyz.danielcortes.views.mantenedores.cliente.ClienteSearchPanel; + +public class ClienteSearchController extends BaseController { + + private ClienteSearchPanel view; + private ClienteRespository clienteRespository; + private ClienteValidator clienteValidator; + + public ClienteSearchController(ClienteSearchPanel view, LaunchController parent) { + super(parent); + this.view = view; + this.clienteRespository = new ClienteRespository(); + this.clienteValidator = new ClienteValidator(this.clienteRespository); + this.setupListeners(); + } + + @Override + public void show() { + this.reload(); + this.view.getClienteTable().clearSelection(); + } + + private void reload() { + this.loadClienteTable(); + } + + private void setupListeners() { + this.view.getCrearButton().addActionListener(e -> this.getParentController().showCard(PanelName.CLIENTE_CREATE)); + this.view.getSearchField().addActionListener(e -> this.search()); + this.view.getBuscarButton().addActionListener(e -> this.search()); + this.view.getVerButton().addActionListener(e -> this.view()); + this.view.getEditarButton().addActionListener(e -> this.edit()); + this.view.getEliminarButton().addActionListener(e -> this.delete()); + } + + private void edit() { + Cliente cliente = this.getSelectedCliente(); + if (cliente != null) { + ClienteUpdateController controller = (ClienteUpdateController) this.getParentController().getCard(PanelName.CLIENTE_UPDATE); + controller.setCliente(cliente); + this.getParentController().showCard(PanelName.CLIENTE_UPDATE); + } + } + + private void delete() { + Cliente cliente = this.getSelectedCliente(); + if (cliente == null) + return; + + int option = JOptionPane.showConfirmDialog( + null, + "¿Estas seguro de que deseas eliminar el cliente?", + "Confirmacion", + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE + ); + + if (option == JOptionPane.NO_OPTION) + return; + + this.clienteRespository.delete(cliente); + this.reload(); + } + + private void view() { + Cliente cliente = this.getSelectedCliente(); + if (cliente != null) { + ClienteViewController controller = (ClienteViewController) this.getParentController().getCard(PanelName.CLIENTE_VIEW); + controller.setCliente(cliente); + this.getParentController().showCard(PanelName.CLIENTE_VIEW); + } + } + + private void search() { + String term = this.view.getSearchField().getText(); + List clientees = this.clienteRespository.search(term); + this.loadClienteTable(clientees); + } + + private void loadClienteTable() { + List clientees = this.clienteRespository.getAll(); + this.loadClienteTable(clientees); + } + + private void loadClienteTable(List clientees) { + BaseTableModel model = this.view.getClienteModel(); + model.setRows(clientees); + } + + private Cliente getSelectedCliente() { + int selectedRow = this.view.getClienteTable().getSelectedRow(); + if (selectedRow == -1) { + JOptionPane.showMessageDialog( + null, + "No hay cliente seleccionado", + "Error", + JOptionPane.ERROR_MESSAGE + ); + return null; + } + return this.view.getClienteModel().getRow(selectedRow); + } + + @Override + public BasePanel getView() { + return this.view; + } + +} diff --git a/src/main/java/xyz/danielcortes/controllers/mantenedores/cliente/ClienteUpdateController.java b/src/main/java/xyz/danielcortes/controllers/mantenedores/cliente/ClienteUpdateController.java new file mode 100644 index 0000000..d367387 --- /dev/null +++ b/src/main/java/xyz/danielcortes/controllers/mantenedores/cliente/ClienteUpdateController.java @@ -0,0 +1,107 @@ +package xyz.danielcortes.controllers.mantenedores.cliente; + +import java.time.LocalDate; +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.Cliente; +import xyz.danielcortes.repository.ClienteRespository; +import xyz.danielcortes.validator.ClienteValidator; +import xyz.danielcortes.views.mantenedores.cliente.ClienteUpdatePanel; + +public class ClienteUpdateController extends BaseController { + + private Cliente cliente; + private ClienteUpdatePanel view; + private ClienteRespository clienteRespository; + private ClienteValidator clienteValidator; + + public ClienteUpdateController(ClienteUpdatePanel view, LaunchController parent) { + super(parent); + this.view = view; + this.clienteRespository = new ClienteRespository(); + this.clienteValidator = new ClienteValidator(this.clienteRespository); + this.setupListeners(); + } + + public void setCliente(Cliente cliente) { + this.cliente = cliente; + } + + @Override + public void show() { + this.fillCliente(); + this.view.getRutField().requestFocus(); + } + + private void fillCliente() { + if (this.clienteRespository == null) + return; + + this.view.getRutField().setText(this.cliente.getRut()); + this.view.getNombreField().setText(this.cliente.getNombre()); + this.view.getApellidoPaternoField().setText(this.cliente.getApellidoPaterno()); + this.view.getApellidoMaternoField().setText(this.cliente.getApellidoMaterno()); + this.view.getFechaNacimientoField().setDate(this.cliente.getFechaNacimiento()); + } + + private void setupListeners() { + this.view.getActualizarButton().addActionListener(e -> this.update()); + this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.CLIENTE_SEARCH)); + } + + private void update() { + String rut = this.view.getRutField().getText(); + ValidationResult rutValidation = this.clienteValidator.validateRut(rut); + if (rutValidation.hasError()) { + rutValidation.showErrorDialog(); + return; + } + + String nombre = this.view.getNombreField().getText(); + ValidationResult nombreValidation = this.clienteValidator.validateNombre(nombre); + if (nombreValidation.hasError()) { + nombreValidation.showErrorDialog(); + return; + } + + String apellidoPaterno = this.view.getApellidoPaternoField().getText(); + ValidationResult apellidoPaternoValidation = this.clienteValidator.validateApellidoPaterno(apellidoPaterno); + if (apellidoPaternoValidation.hasError()) { + apellidoPaternoValidation.showErrorDialog(); + return; + } + + String apellidoMaterno = this.view.getApellidoMaternoField().getText(); + ValidationResult apellidoMaternoValidation = this.clienteValidator.validateApellidoMaterno(apellidoMaterno); + if (apellidoMaternoValidation.hasError()) { + apellidoMaternoValidation.showErrorDialog(); + return; + } + + LocalDate fechaNacimiento = this.view.getFechaNacimientoField().getDate(); + ValidationResult fechaContratoValidation = this.clienteValidator.validateFechaNacimiento(fechaNacimiento); + if (fechaContratoValidation.hasError()) { + fechaContratoValidation.showErrorDialog(); + return; + } + + assert this.cliente != null; + this.cliente.setNombre(nombre); + this.cliente.setApellidoPaterno(apellidoPaterno); + this.cliente.setApellidoMaterno(apellidoMaterno); + this.cliente.setFechaNacimiento(fechaNacimiento); + this.cliente.setRut(rut); + this.clienteRespository.update(this.cliente); + + this.getParentController().showCard(PanelName.CLIENTE_SEARCH); + } + + @Override + public BasePanel getView() { + return this.view; + } + +} diff --git a/src/main/java/xyz/danielcortes/controllers/mantenedores/cliente/ClienteViewController.java b/src/main/java/xyz/danielcortes/controllers/mantenedores/cliente/ClienteViewController.java new file mode 100644 index 0000000..01ef666 --- /dev/null +++ b/src/main/java/xyz/danielcortes/controllers/mantenedores/cliente/ClienteViewController.java @@ -0,0 +1,71 @@ +package xyz.danielcortes.controllers.mantenedores.cliente; + +import java.time.format.DateTimeFormatter; +import xyz.danielcortes.controllers.LaunchController; +import xyz.danielcortes.framework.BaseController; +import xyz.danielcortes.framework.BasePanel; +import xyz.danielcortes.framework.PanelName; +import xyz.danielcortes.models.Cliente; +import xyz.danielcortes.views.mantenedores.cliente.ClienteViewPanel; + +public class ClienteViewController extends BaseController { + + private Cliente cliente; + private ClienteViewPanel view; + + public ClienteViewController(ClienteViewPanel view, LaunchController parent) { + super(parent); + this.view = view; + this.setupListeners(); + } + + @Override + public void show() { + this.fillCliente(); + } + + public void setCliente(Cliente cliente) { + this.cliente = cliente; + } + + private void setupListeners() { + this.view.getVolverButton().addActionListener(e -> this.getParentController().showCard(PanelName.CLIENTE_SEARCH)); +// this.view.getCorreosButton().addActionListener(e -> this.gotoCorreosView()); +// this.view.getTelefonosButton().addActionListener(e -> this.gotoTelefonoView()); +// this.view.getDireccionesButton().addActionListener(e -> this.gotoDireccionView()); + } + +// private void gotoDireccionView() { +// DireccionSearchController controller = (DireccionSearchController) this.getParentController().getCard(PanelName.DIRECCION_SEARCH); +// controller.setCliente(cliente); +// this.getParentController().showCard(PanelName.DIRECCION_SEARCH); +// } +// +// private void gotoTelefonoView() { +// TelefonoSearchController controller = (TelefonoSearchController) this.getParentController().getCard(PanelName.TELEFONO_SEARCH); +// controller.setCliente(cliente); +// this.getParentController().showCard(PanelName.TELEFONO_SEARCH); +// } +// +// private void gotoCorreosView() { +// CorreoSearchController controller = (CorreoSearchController) this.getParentController().getCard(PanelName.CORREO_SEARCH); +// controller.setCliente(cliente); +// this.getParentController().showCard(PanelName.CORREO_SEARCH); +// } + + private void fillCliente() { + if (this.cliente == null) + return; + + this.view.getRutField().setText(this.cliente.getRut()); + this.view.getNombreField().setText(this.cliente.getNombre()); + this.view.getApellidoPaternoField().setText(this.cliente.getApellidoPaterno()); + this.view.getApellidoMaternoField().setText(this.cliente.getApellidoMaterno()); + this.view.getFechaNacimientoField().setText(this.cliente.getFechaNacimiento().format(DateTimeFormatter.ofPattern("dd/MM/YYYY"))); + } + + @Override + public BasePanel getView() { + return this.view; + } +} diff --git a/src/main/java/xyz/danielcortes/controllers/mantenedores/trabajador/correo/CorreoSearchController.java b/src/main/java/xyz/danielcortes/controllers/mantenedores/trabajador/correo/CorreoSearchController.java index 8c1f56e..abebecc 100644 --- a/src/main/java/xyz/danielcortes/controllers/mantenedores/trabajador/correo/CorreoSearchController.java +++ b/src/main/java/xyz/danielcortes/controllers/mantenedores/trabajador/correo/CorreoSearchController.java @@ -36,7 +36,7 @@ public class CorreoSearchController extends BaseController { @Override public BasePanel getView() { - return view; + return this.view; } public void setTrabajador(Trabajador trabajador) { @@ -60,7 +60,7 @@ public class CorreoSearchController extends BaseController { private void create() { CorreoCreateController controller = (CorreoCreateController) this.getParentController().getCard(PanelName.CORREO_CREATE); - controller.setTrabajador(trabajador); + controller.setTrabajador(this.trabajador); this.getParentController().showCard(PanelName.CORREO_CREATE); } @@ -68,14 +68,14 @@ public class CorreoSearchController extends BaseController { Correo correo = this.getSelectedCorreo(); if (correo != null) { CorreoUpdateController controller = (CorreoUpdateController) this.getParentController().getCard(PanelName.CORREO_UPDATE); - controller.setTrabajador(trabajador); + controller.setTrabajador(this.trabajador); controller.setCorreo(correo); this.getParentController().showCard(PanelName.CORREO_UPDATE); } } private void delete() { - Correo correo = this.getSelectedCorreo(); + Correo correo = this.getSelecztedCorreo(); if (correo == null) return; @@ -99,14 +99,14 @@ public class CorreoSearchController extends BaseController { if (correo != null) { CorreoViewController controller = (CorreoViewController) this.getParentController().getCard(PanelName.CORREO_VIEW); controller.setCorreo(correo); - controller.setTrabajador(trabajador); + controller.setTrabajador(this.trabajador); this.getParentController().showCard(PanelName.CORREO_VIEW); } } private void search() { String term = this.view.getSearchField().getText(); - List correo = this.correoRepository.search(term, trabajador); + List correo = this.correoRepository.search(term, this.trabajador); this.loadCorreosTable(correo); } @@ -118,7 +118,7 @@ public class CorreoSearchController extends BaseController { private void loadCorreosTable() { List correos = this.trabajador.getCorreos(); - loadCorreosTable(correos); + this.loadCorreosTable(correos); } private void loadCorreosTable(List correos) { diff --git a/src/main/java/xyz/danielcortes/framework/PanelName.java b/src/main/java/xyz/danielcortes/framework/PanelName.java index 530ae10..d45e516 100644 --- a/src/main/java/xyz/danielcortes/framework/PanelName.java +++ b/src/main/java/xyz/danielcortes/framework/PanelName.java @@ -43,6 +43,11 @@ public enum PanelName { DISTRIBUIDOR_CREATE, DISTRIBUIDOR_UPDATE, + CLIENTE_VIEW, + CLIENTE_SEARCH, + CLIENTE_CREATE, + CLIENTE_UPDATE, + USUARIO_VIEW, USUARIO_CREATE, USUARIO_UPDATE, diff --git a/src/main/java/xyz/danielcortes/models/Cliente.java b/src/main/java/xyz/danielcortes/models/Cliente.java new file mode 100644 index 0000000..f6c4f6e --- /dev/null +++ b/src/main/java/xyz/danielcortes/models/Cliente.java @@ -0,0 +1,123 @@ +package xyz.danielcortes.models; + +import java.time.LocalDate; +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.ManyToMany; +import javax.persistence.Table; + +@Entity +@Table(name = "cliente") +public class Cliente { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Integer id; + + @Column(name = "rut") + private String rut; + + @Column(name = "nombre") + private String nombre; + + @Column(name = "apellido_paterno") + private String apellidoPaterno; + + @Column(name = "apellido_materno") + private String apellidoMaterno; + + @Column(name = "fecha_nacimiento") + private LocalDate fechaNacimiento; + + @ManyToMany(mappedBy = "clientes") + private List correos; + + @ManyToMany(mappedBy = "clientes") + private List telefonos; + + @ManyToMany(mappedBy = "clientes") + private List direcciones; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getRut() { + return rut; + } + + public void setRut(String rut) { + this.rut = rut; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public String getApellidoPaterno() { + return apellidoPaterno; + } + + public void setApellidoPaterno(String apellidoPaterno) { + this.apellidoPaterno = apellidoPaterno; + } + + public String getApellidoMaterno() { + return apellidoMaterno; + } + + public void setApellidoMaterno(String apellidoMaterno) { + this.apellidoMaterno = apellidoMaterno; + } + + public LocalDate getFechaNacimiento() { + return fechaNacimiento; + } + + public void setFechaNacimiento(LocalDate fechaNacimiento) { + this.fechaNacimiento = fechaNacimiento; + } + + public List getCorreos() { + if(correos == null) + correos = new ArrayList<>(); + return correos; + } + + public void setCorreos(List correos) { + this.correos = correos; + } + + public List getTelefonos() { + if(telefonos == null) + telefonos = new ArrayList<>(); + return telefonos; + } + + public void setTelefonos(List telefonos) { + this.telefonos = telefonos; + } + + public List getDirecciones() { + if(direcciones == null) + direcciones = new ArrayList<>(); + return direcciones; + } + + public void setDirecciones(List direcciones) { + this.direcciones = direcciones; + } +} diff --git a/src/main/java/xyz/danielcortes/models/Correo.java b/src/main/java/xyz/danielcortes/models/Correo.java index 8f0da35..dad4d25 100644 --- a/src/main/java/xyz/danielcortes/models/Correo.java +++ b/src/main/java/xyz/danielcortes/models/Correo.java @@ -41,6 +41,14 @@ public class Correo { ) private List distribuidores; + @ManyToMany + @JoinTable( + name = "cliente_direccion", + joinColumns = @JoinColumn(name = "direccion_id", referencedColumnName = "id"), + inverseJoinColumns = @JoinColumn(name = "cliente_id", referencedColumnName = "id") + ) + private List clientes; + public Integer getId() { return id; } @@ -69,7 +77,7 @@ public class Correo { } public List getDistribuidores() { - if(distribuidores == null) + if (distribuidores == null) distribuidores = new ArrayList<>(); return distribuidores; } @@ -78,20 +86,13 @@ public class Correo { this.distribuidores = distribuidores; } - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (!(o instanceof Correo)) - return false; - Correo correo1 = (Correo) o; - return Objects.equals(id, correo1.id) && - Objects.equals(correo, correo1.correo) && - Objects.equals(trabajadores, correo1.trabajadores); + public List getClientes() { + if (clientes == null) + clientes = new ArrayList<>(); + return clientes; } - @Override - public int hashCode() { - return Objects.hash(id, correo, trabajadores); + public void setClientes(List clientes) { + this.clientes = clientes; } } diff --git a/src/main/java/xyz/danielcortes/models/Direccion.java b/src/main/java/xyz/danielcortes/models/Direccion.java index 8f7b46c..d9db559 100644 --- a/src/main/java/xyz/danielcortes/models/Direccion.java +++ b/src/main/java/xyz/danielcortes/models/Direccion.java @@ -2,7 +2,6 @@ package xyz.danielcortes.models; import java.util.ArrayList; import java.util.List; -import java.util.Objects; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -44,6 +43,14 @@ public class Direccion { ) private List distribuidores; + @ManyToMany + @JoinTable( + name = "cliente_direccion", + joinColumns = @JoinColumn(name = "direccion_id", referencedColumnName = "id"), + inverseJoinColumns = @JoinColumn(name = "cliente_id", referencedColumnName = "id") + ) + private List clientes; + public Integer getId() { return id; } @@ -80,7 +87,7 @@ public class Direccion { } public List getDistribuidores() { - if(distribuidores == null) + if (distribuidores == null) distribuidores = new ArrayList<>(); return distribuidores; } @@ -89,21 +96,13 @@ public class Direccion { this.distribuidores = distribuidores; } - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (!(o instanceof Direccion)) - return false; - Direccion direccion = (Direccion) o; - return Objects.equals(id, direccion.id) && - Objects.equals(calle, direccion.calle) && - Objects.equals(numero, direccion.numero) && - Objects.equals(trabajadores, direccion.trabajadores); + public List getClientes() { + if (clientes == null) + clientes = new ArrayList<>(); + return clientes; } - @Override - public int hashCode() { - return Objects.hash(id, calle, numero, trabajadores); + public void setClientes(List clientes) { + this.clientes = clientes; } } diff --git a/src/main/java/xyz/danielcortes/models/Telefono.java b/src/main/java/xyz/danielcortes/models/Telefono.java index 7416a8b..ccc58e9 100644 --- a/src/main/java/xyz/danielcortes/models/Telefono.java +++ b/src/main/java/xyz/danielcortes/models/Telefono.java @@ -2,7 +2,6 @@ package xyz.danielcortes.models; import java.util.ArrayList; import java.util.List; -import java.util.Objects; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -16,6 +15,7 @@ import javax.persistence.Table; @Entity @Table(name = "telefono") public class Telefono { + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id", nullable = false) @@ -40,6 +40,14 @@ public class Telefono { ) private List distribuidores; + @ManyToMany + @JoinTable( + name = "cliente_direccion", + joinColumns = @JoinColumn(name = "direccion_id", referencedColumnName = "id"), + inverseJoinColumns = @JoinColumn(name = "cliente_id", referencedColumnName = "id") + ) + private List clientes; + public Integer getId() { return id; } @@ -57,7 +65,7 @@ public class Telefono { } public List getTrabajadores() { - if(trabajadores == null) { + if (trabajadores == null) { trabajadores = new ArrayList<>(); } return trabajadores; @@ -68,7 +76,7 @@ public class Telefono { } public List getDistribuidores() { - if(distribuidores == null) + if (distribuidores == null) distribuidores = new ArrayList<>(); return distribuidores; } @@ -77,20 +85,13 @@ public class Telefono { this.distribuidores = distribuidores; } - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (!(o instanceof Telefono)) - return false; - Telefono telefono = (Telefono) o; - return Objects.equals(id, telefono.id) && - Objects.equals(numero, telefono.numero) && - Objects.equals(trabajadores, telefono.trabajadores); + public List getClientes() { + if(clientes == null) + clientes = new ArrayList<>(); + return clientes; } - @Override - public int hashCode() { - return Objects.hash(id, numero, trabajadores); + public void setClientes(List clientes) { + this.clientes = clientes; } } diff --git a/src/main/java/xyz/danielcortes/repository/ClienteRespository.java b/src/main/java/xyz/danielcortes/repository/ClienteRespository.java new file mode 100644 index 0000000..ccaf875 --- /dev/null +++ b/src/main/java/xyz/danielcortes/repository/ClienteRespository.java @@ -0,0 +1,29 @@ +package xyz.danielcortes.repository; + +import java.util.List; +import javax.persistence.TypedQuery; +import xyz.danielcortes.framework.BaseRepository; +import xyz.danielcortes.models.Cliente; + +public class ClienteRespository extends BaseRepository { + + public List getAll() { + TypedQuery query = em.createQuery("SELECT c FROM Cliente c", Cliente.class); + return query.getResultList(); + } + + public List search(String term) { + TypedQuery query = em.createQuery( + "SELECT c FROM Cliente c WHERE " + + " LOWER(c.rut) LIKE :term OR " + + " LOWER(c.nombre) LIKE :term OR " + + " LOWER(c.apellidoPaterno) LIKE :term OR " + + " LOWER(c.apellidoPaterno) LIKE :term OR " + + " LOWER(c.fechaNacimiento) LIKE :term", + Cliente.class + ); + + return query.getResultList(); + } + +} diff --git a/src/main/java/xyz/danielcortes/validator/ClienteValidator.java b/src/main/java/xyz/danielcortes/validator/ClienteValidator.java new file mode 100644 index 0000000..f187b0d --- /dev/null +++ b/src/main/java/xyz/danielcortes/validator/ClienteValidator.java @@ -0,0 +1,88 @@ +package xyz.danielcortes.validator; + +import java.time.LocalDate; +import xyz.danielcortes.framework.ValidationResult; +import xyz.danielcortes.repository.ClienteRespository; + +public class ClienteValidator { + + private ClienteRespository clienteRespository; + + public ClienteValidator(ClienteRespository clienteRespository) { + this.clienteRespository = clienteRespository; + } + + public ValidationResult validateNombre(String nombre) { + if (nombre == null) { + return new ValidationResult("El nombre es nulo"); + } else if (nombre.isEmpty()) { + return new ValidationResult("El nombre esta vacío"); + } + return ValidationResult.NON_ERROR; + } + + public ValidationResult validateApellidoPaterno(String apellidoPaterno) { + if (apellidoPaterno == null) { + return new ValidationResult("El apellido paterno es nulo"); + } else if (apellidoPaterno.isEmpty()) { + return new ValidationResult("El apellido paterno esta vacío"); + } + return ValidationResult.NON_ERROR; + } + + public ValidationResult validateApellidoMaterno(String apellidoMaterno) { + if (apellidoMaterno == null) { + return new ValidationResult("El apellido materno es nulo"); + } else if (apellidoMaterno.isEmpty()) { + return new ValidationResult("El apellido materno esta vacío"); + } + return ValidationResult.NON_ERROR; + } + + public ValidationResult validateRut(String rut) { + if (rut == null) { + return new ValidationResult("El rut es nulo"); + } else if (rut.isEmpty()) { + return new ValidationResult("El rut esta vacío"); + } else if (rut.length() < 4) { + return new ValidationResult("El rut es muy corto"); + } + if (!this.rutChecksum(rut)) { + return new ValidationResult("El rut es invalido"); + } + + return ValidationResult.NON_ERROR; + } + + public ValidationResult validateFechaNacimiento(LocalDate fecha) { + if (fecha == null) { + return new ValidationResult("La fecha es nula"); + } + return ValidationResult.NON_ERROR; + } + + + private boolean rutChecksum(String rut) { + char lastchar = rut.charAt(rut.length() - 1); + rut = rut.toLowerCase().replaceAll("[^\\dkK]", ""); + int sum = 0; + for (int i = rut.length() - 2, j = 2; i >= 0; i--, j++) { + int digit = rut.charAt(i) - '0'; + if (j == 8) + j = 2; + + sum += digit * j; + } + + int mod11 = 11 - (sum % 11); + + char digitoVerificador = (char) (mod11 + '0'); + if (mod11 == 11) + digitoVerificador = '0'; + if (mod11 == 10) + digitoVerificador = 'k'; + + return lastchar == digitoVerificador; + } + +} diff --git a/src/main/java/xyz/danielcortes/views/LaunchFrame.java b/src/main/java/xyz/danielcortes/views/LaunchFrame.java index 51280ad..3f95fba 100644 --- a/src/main/java/xyz/danielcortes/views/LaunchFrame.java +++ b/src/main/java/xyz/danielcortes/views/LaunchFrame.java @@ -9,6 +9,7 @@ import javax.swing.WindowConstants; import xyz.danielcortes.framework.PanelName; public class LaunchFrame extends JFrame { + private Dimension dimension; public LaunchFrame() { diff --git a/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteCreatePanel.form b/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteCreatePanel.form new file mode 100644 index 0000000..95cb648 --- /dev/null +++ b/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteCreatePanel.form @@ -0,0 +1,138 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteCreatePanel.java b/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteCreatePanel.java new file mode 100644 index 0000000..0715969 --- /dev/null +++ b/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteCreatePanel.java @@ -0,0 +1,151 @@ +package xyz.danielcortes.views.mantenedores.cliente; + +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 ClienteCreatePanel extends BasePanel { + + private JTextField nombreField; + private JTextField apellidoPaternoField; + private JTextField apellidoMaternoField; + private JButton guardarButton; + private JPanel contentPane; + private JButton volverButton; + private JTextField rutField; + private DatePicker fechaNacimientoPicker; + + @Override + public JPanel getContentPane() { + return contentPane; + } + + public JTextField getNombreField() { + return nombreField; + } + + public JTextField getApellidoPaternoField() { + return apellidoPaternoField; + } + + public JTextField getApellidoMaternoField() { + return apellidoMaternoField; + } + + public JButton getGuardarButton() { + return guardarButton; + } + + public JButton getVolverButton() { + return volverButton; + } + + public JTextField getRutField() { + return rutField; + } + + public DatePicker getFechaNacimientoPicker() { + return fechaNacimientoPicker; + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * 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(12, 3, new Insets(20, 20, 20, 20), -1, -1)); + final JLabel label1 = new JLabel(); + label1.setText("Nombre:"); + 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)); + nombreField = new JTextField(); + contentPane.add(nombreField, + 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 JLabel label2 = new JLabel(); + label2.setText("Apellido Paterno:"); + contentPane.add(label2, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + apellidoPaternoField = new JTextField(); + contentPane.add(apellidoPaternoField, + new GridConstraints(5, 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 JLabel label3 = new JLabel(); + label3.setText("Apellido Materno:"); + contentPane.add(label3, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + apellidoMaternoField = new JTextField(); + contentPane.add(apellidoMaternoField, + new GridConstraints(7, 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 spacer1 = new Spacer(); + contentPane.add(spacer1, + new GridConstraints(11, 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(11, 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(11, 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, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(10, 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)); + rutField = new JTextField(); + contentPane.add(rutField, + 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)); + final JLabel label4 = new JLabel(); + label4.setText("Rut:"); + contentPane.add(label4, new GridConstraints(0, 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 Nacimiento:"); + contentPane.add(label5, new GridConstraints(8, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + fechaNacimientoPicker = new DatePicker(); + contentPane.add(fechaNacimientoPicker, + new GridConstraints(9, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + +} diff --git a/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteSearchPanel.form b/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteSearchPanel.form new file mode 100644 index 0000000..fd801df --- /dev/null +++ b/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteSearchPanel.form @@ -0,0 +1,96 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteSearchPanel.java b/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteSearchPanel.java new file mode 100644 index 0000000..ede45d5 --- /dev/null +++ b/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteSearchPanel.java @@ -0,0 +1,154 @@ +package xyz.danielcortes.views.mantenedores.cliente; + +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import java.awt.Dimension; +import java.awt.Insets; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import xyz.danielcortes.framework.BasePanel; +import xyz.danielcortes.framework.BaseTableModel; +import xyz.danielcortes.models.Cliente; + +public class ClienteSearchPanel extends BasePanel { + + private JPanel contentPane; + private JTable clienteTable; + private JTextField searchField; + private JButton buscarButton; + private JButton verButton; + private JButton eliminarButton; + private JButton editarButton; + private JButton crearButton; + private BaseTableModel clienteModel; + + public JPanel getContentPane() { + return contentPane; + } + + public JTable getClienteTable() { + return clienteTable; + } + + public JTextField getSearchField() { + return searchField; + } + + public JButton getBuscarButton() { + return buscarButton; + } + + public JButton getVerButton() { + return verButton; + } + + public JButton getEliminarButton() { + return eliminarButton; + } + + public JButton getEditarButton() { + return editarButton; + } + + public JButton getCrearButton() { + return crearButton; + } + + public BaseTableModel getClienteModel() { + return clienteModel; + } + + private void createUIComponents() { + this.createClienteTable(); + } + + private void createClienteTable() { + // @formatter:off + this.clienteModel= new BaseTableModel<>( + new String[]{"Rut", "Nombre", "Apellido Paterno", "Apellido Materno", "Fecha Nacimiento"}, + (row, rowIndex, colIndex) -> { + switch (colIndex) { + case 0: return row.get(rowIndex).getRut(); + case 1: return row.get(rowIndex).getNombre(); + case 2: return row.get(rowIndex).getApellidoPaterno(); + case 3: return row.get(rowIndex).getApellidoMaterno(); + case 4: return row.get(rowIndex).getFechaNacimiento(); + default: return null; + } + } + ); + // @formatter:on + this.clienteTable = new JTable(this.clienteModel); + this.clienteTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * 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(3, 2, new Insets(20, 20, 20, 20), -1, -1)); + final JScrollPane scrollPane1 = new JScrollPane(); + contentPane.add(scrollPane1, new GridConstraints(1, 0, 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(clienteTable); + searchField = new JTextField(); + contentPane.add(searchField, + new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + buscarButton = new JButton(); + buscarButton.setText("Buscar"); + contentPane.add(buscarButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), + null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(2, 0, 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)); + verButton = new JButton(); + verButton.setText("Ver"); + panel1.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)); + eliminarButton = new JButton(); + eliminarButton.setText("Eliminar"); + panel1.add(eliminarButton, new GridConstraints(0, 3, 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)); + editarButton = new JButton(); + editarButton.setText("Editar"); + panel1.add(editarButton, 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)); + crearButton = new JButton(); + crearButton.setText("Crear"); + panel1.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)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + +} diff --git a/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteUpdatePanel.form b/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteUpdatePanel.form new file mode 100644 index 0000000..1c93522 --- /dev/null +++ b/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteUpdatePanel.form @@ -0,0 +1,138 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteUpdatePanel.java b/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteUpdatePanel.java new file mode 100644 index 0000000..de1b811 --- /dev/null +++ b/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteUpdatePanel.java @@ -0,0 +1,151 @@ +package xyz.danielcortes.views.mantenedores.cliente; + +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 ClienteUpdatePanel extends BasePanel { + + private JTextField nombreField; + private JTextField apellidoPaternoField; + private JTextField apellidoMaternoField; + private JButton actualizarButton; + private JPanel contentPane; + private JButton volverButton; + private JTextField rutField; + private DatePicker fechaNacimientoField; + + public JTextField getNombreField() { + return nombreField; + } + + public JTextField getApellidoPaternoField() { + return apellidoPaternoField; + } + + public JTextField getApellidoMaternoField() { + return apellidoMaternoField; + } + + public JButton getActualizarButton() { + return actualizarButton; + } + + @Override + public JPanel getContentPane() { + return contentPane; + } + + public JButton getVolverButton() { + return volverButton; + } + + public JTextField getRutField() { + return rutField; + } + + public DatePicker getFechaNacimientoField() { + return fechaNacimientoField; + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * 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(12, 3, new Insets(20, 20, 20, 20), -1, -1)); + nombreField = new JTextField(); + contentPane.add(nombreField, + 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 JLabel label1 = new JLabel(); + label1.setText("Apellido Paterno:"); + contentPane.add(label1, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + apellidoPaternoField = new JTextField(); + contentPane.add(apellidoPaternoField, + new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false)); + apellidoMaternoField = new JTextField(); + contentPane.add(apellidoMaternoField, + new GridConstraints(7, 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 JLabel label2 = new JLabel(); + label2.setText("Apellido Materno:"); + 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)); + final Spacer spacer1 = new Spacer(); + contentPane.add(spacer1, + new GridConstraints(11, 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(11, 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(11, 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, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(10, 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, 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)); + actualizarButton = new JButton(); + actualizarButton.setText("Actualizar"); + panel1.add(actualizarButton, 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 label3 = new JLabel(); + label3.setText("Nombre:"); + 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)); + final JLabel label4 = new JLabel(); + label4.setText("Rut:"); + contentPane.add(label4, new GridConstraints(0, 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 Nacimiento:"); + contentPane.add(label5, new GridConstraints(8, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + fechaNacimientoField = new DatePicker(); + contentPane.add(fechaNacimientoField, + new GridConstraints(9, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, + GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false)); + rutField = new JTextField(); + contentPane.add(rutField, + 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)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + +} diff --git a/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteViewPanel.form b/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteViewPanel.form new file mode 100644 index 0000000..c9ea1ee --- /dev/null +++ b/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteViewPanel.form @@ -0,0 +1,169 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteViewPanel.java b/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteViewPanel.java new file mode 100644 index 0000000..0757b35 --- /dev/null +++ b/src/main/java/xyz/danielcortes/views/mantenedores/cliente/ClienteViewPanel.java @@ -0,0 +1,177 @@ +package xyz.danielcortes.views.mantenedores.cliente; + +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 ClienteViewPanel extends BasePanel { + + private JTextField nombreField; + private JTextField apellidoPaternoField; + private JTextField apellidoMaternoField; + private JButton volverButton; + private JPanel contentPane; + private JTextField rutField; + private JButton direccionesButton; + private JButton correosButton; + private JButton telefonosButton; + private JTextField fechaNacimientoField; + + public JTextField getNombreField() { + return nombreField; + } + + public JTextField getApellidoPaternoField() { + return apellidoPaternoField; + } + + public JTextField getApellidoMaternoField() { + return apellidoMaternoField; + } + + public JButton getVolverButton() { + return volverButton; + } + + @Override + public JPanel getContentPane() { + return contentPane; + } + + public JTextField getRutField() { + return rutField; + } + + public JTextField getFechaNacimientoField() { + return fechaNacimientoField; + } + + public JButton getDireccionesButton() { + return direccionesButton; + } + + public JButton getCorreosButton() { + return correosButton; + } + + public JButton getTelefonosButton() { + return telefonosButton; + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * 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(13, 3, new Insets(20, 20, 20, 20), -1, -1)); + final JLabel label1 = new JLabel(); + label1.setText("Nombre:"); + 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)); + nombreField = new JTextField(); + nombreField.setEditable(false); + nombreField.setEnabled(true); + contentPane.add(nombreField, + 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 JLabel label2 = new JLabel(); + label2.setText("Apellido Paterno:"); + contentPane.add(label2, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + apellidoPaternoField = new JTextField(); + apellidoPaternoField.setEditable(false); + apellidoPaternoField.setEnabled(true); + contentPane.add(apellidoPaternoField, + new GridConstraints(5, 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 JLabel label3 = new JLabel(); + label3.setText("Apellido Materno:"); + contentPane.add(label3, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + apellidoMaternoField = new JTextField(); + apellidoMaternoField.setEditable(false); + apellidoMaternoField.setEnabled(true); + contentPane.add(apellidoMaternoField, + new GridConstraints(7, 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 spacer1 = new Spacer(); + contentPane.add(spacer1, + new GridConstraints(12, 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(12, 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(12, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, + null, null, null, 0, false)); + volverButton = new JButton(); + volverButton.setText("Volver"); + contentPane.add(volverButton, new GridConstraints(11, 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 label4 = new JLabel(); + label4.setText("Rut:"); + contentPane.add(label4, new GridConstraints(0, 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 Nacimiento:"); + contentPane.add(label5, new GridConstraints(8, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + rutField = new JTextField(); + rutField.setEditable(false); + contentPane.add(rutField, + 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)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(10, 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)); + direccionesButton = new JButton(); + direccionesButton.setText("Direcciones"); + panel1.add(direccionesButton, 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)); + correosButton = new JButton(); + correosButton.setText("Correos"); + panel1.add(correosButton, 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)); + telefonosButton = new JButton(); + telefonosButton.setText("Telefonos"); + panel1.add(telefonosButton, 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)); + fechaNacimientoField = new JTextField(); + contentPane.add(fechaNacimientoField, + 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)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + +}