Estaba en medio de cosas y movi archivos

Estoy avanzando a la venta, pero se me ocurrio mover unos archivos
porque.... puedo?

Me molestaba tanta cosa en el index XD
aparte mejore el migrate.sh y cree un dump.sh para mas comodidad de
exportar los cambios a la base de datos
This commit is contained in:
Daniel Cortés
2019-07-03 19:23:28 -04:00
parent c9dfd7f3ad
commit 3c3147bc23
29 changed files with 1342 additions and 681 deletions

10
.idea/bashsupport_project.xml generated Normal file
View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="BashSupportProjectSettings">
<option name="autocompleteBuiltinVars" value="true" />
<option name="autocompletePathCommands" value="false" />
<option name="formatterEnabled" value="true" />
<option name="projectInterpreter" value="/bin/sh" />
<option name="supportBash4" value="false" />
</component>
</project>

View File

@@ -1,6 +1,7 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="BashReplaceWithDoubleBrackets" enabled="false" level="INFO" enabled_by_default="false" />
<inspection_tool class="Duplicates" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="false" />

4
.idea/sqldialects.xml generated
View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlDialectMappings">
<file url="file://$PROJECT_DIR$/create.sql" dialect="MariaDB" />
<file url="file://$PROJECT_DIR$/data.sql" dialect="MariaDB" />
<file url="file://$PROJECT_DIR$/db/create.sql" dialect="MariaDB" />
<file url="file://$PROJECT_DIR$/db/data.sql" dialect="MariaDB" />
</component>
</project>

119
data.sql
View File

@@ -1,119 +0,0 @@
start transaction;
set foreign_key_checks = 0;
set autocommit = 0;
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');
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');
--
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');
INSERT INTO `correo`
VALUES (1, 'HOOLA', '2019-06-13 17:25:41'),
(2, 'skrd159@gmail.com', '2019-06-13 17:32:13');
INSERT INTO `distribuidor`
VALUES (2, 1, '14166920-6', '2019-06-13 03:08:17'),
(3, 2, '8425080-5', '2019-06-13 03:08:23'),
(4, 1, '21629388-6', '2019-06-13 03:08:25'),
(5, 1, '13510176-1', '2019-06-13 03:08:27');
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');
INSERT INTO `empresa`
VALUES (1, 'Empresa 1', '2019-06-13 00:39:50'),
(2, 'Empresa 2', '2019-06-13 00:39:52');
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');
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');
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');
INSERT INTO `libro_autor`
VALUES (1, 3),
(2, 3),
(3, 3),
(4, 1),
(5, 1),
(6, 1),
(7, 2),
(8, 2),
(9, 2);
INSERT INTO `libro_categoria`
VALUES (1, 3),
(2, 3),
(3, 3),
(4, 1),
(5, 1),
(6, 1),
(7, 1),
(8, 1),
(9, 1);
INSERT INTO `libro_idioma`
VALUES (1, 2),
(2, 2),
(3, 2),
(4, 2),
(5, 2),
(6, 2),
(7, 2),
(8, 2),
(9, 2);
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');
INSERT INTO `trabajador_correo`
VALUES (4, 1),
(2, 2);
INSERT INTO `usuario`
VALUES (2, 'admin', 0x243168097E0BA82B896F348BABCEB600A8DCA30488C6F238F97FD8737BD00B27,
0x3564ECCCD85CF0583F9C090602E998B7, 2, '2019-06-13 16:04:53');
set autocommit = 1;
set foreign_key_checks = 1;
commit;

View File

@@ -1,50 +1,11 @@
#--------------------------------------------------------------------------------#
#-----------------------------Eliminar todas las tablas--------------------------#
#-----------------------------Comenzar ------------------------------------------#
#--------------------------------------------------------------------------------#
start transaction;
set foreign_key_checks = 0;
set autocommit = 0;
drop table if exists editorial;
drop table if exists estado;
drop table if exists autor;
drop table if exists categoria;
drop table if exists idioma;
drop table if exists libro;
drop table if exists ejemplar;
drop table if exists libro_autor;
drop table if exists libro_categoria;
drop table if exists libro_idioma;
drop table if exists correo;
drop table if exists direccion;
drop table if exists telefono;
drop table if exists empresa;
drop table if exists distribuidor;
drop table if exists cliente;
drop table if exists trabajador;
drop table if exists distribuidor_direccion;
drop table if exists distribuidor_telefono;
drop table if exists distribuidor_correo;
drop table if exists cliente_direccion;
drop table if exists cliente_telefono;
drop table if exists cliente_correo;
drop table if exists trabajador_direccion;
drop table if exists trabajador_telefono;
drop table if exists trabajador_correo;
drop table if exists orden_compra;
drop table if exists factura;
drop table if exists boleta;
drop table if exists compra;
drop table if exists venta;
drop table if exists arriendo;
drop table if exists libro_orden_compra;
drop table if exists ejemplar_compra;
drop table if exists ejemplar_venta;
drop table if exists ejemplar_arriendo;
drop table if exists usuario;
#--------------------------------------------------------------------------------#
#--------------Definicion de las tablas relacionadas a los libros----------------#
#--------------------------------------------------------------------------------#
@@ -295,7 +256,7 @@ create table boleta
create table orden_compra
(
id int unsigned primary key auto_increment,
estado enum ('En Curso', 'Aceptada', 'Cancelada'),
estado enum ('En Curso', 'Recibida', 'Cancelada'),
compra_id int unsigned,
distribuidor_id int unsigned not null,
inserted_at timestamp default CURRENT_TIMESTAMP,
@@ -387,6 +348,10 @@ create table usuario
foreign key (trabajador_id) references trabajador (id) on delete cascade on update cascade
);
#--------------------------------------------------------------------------------#
#-----------------------------Terminar ------------------------------------------#
#--------------------------------------------------------------------------------#
set autocommit = 1;
set foreign_key_checks = 1;

109
db/data.sql Normal file
View File

@@ -0,0 +1,109 @@
INSERT INTO `autor`
VALUES (1, 'Howard Philips', 'Lovecraft', NULL, '2019-06-12 20:18:57'),
(2, 'Stephen', 'King', NULL, '2019-06-12 20:18:57'),
(3, 'Brandon', 'Sanderson', NULL, '2019-06-12 20:18:57');
INSERT INTO `categoria`
VALUES (1, 'Terror', '2019-06-12 20:18:57'),
(2, 'Aventura', '2019-06-12 20:18:57'),
(3, 'Fantasia', '2019-06-12 20:18:57');
INSERT INTO `cliente`
VALUES (1, '21786653-7', 'Cliente', '1', '1', '2019-06-17', '2019-06-13 20:01:33'),
(2, '17181388-3', 'Cliente', '2', '2', '2019-06-13', '2019-06-13 20:04:02');
INSERT INTO `compra`
VALUES (1, 1, 2, '2019-07-03 23:03:36');
INSERT INTO `correo`
VALUES (1, 'HOOLA', '2019-06-13 21:25:41'),
(2, 'skrd159@gmail.com', '2019-06-13 21:32:13');
INSERT INTO `distribuidor`
VALUES (2, 1, '14166920-6', '2019-06-13 07:08:17'),
(3, 2, '8425080-5', '2019-06-13 07:08:23'),
(4, 1, '21629388-6', '2019-06-13 07:08:25'),
(5, 1, '13510176-1', '2019-06-13 07:08:27');
INSERT INTO `editorial`
VALUES (1, 'Editorial N1', '2019-06-12 20:18:57'),
(2, 'Editorial N2', '2019-06-12 20:18:57'),
(3, 'Editorial N3', '2019-06-12 20:18:57');
INSERT INTO `ejemplar`
VALUES (1, 1, 3, '123', '2019-07-03 23:03:36');
INSERT INTO `ejemplar_compra`
VALUES (1, 1);
INSERT INTO `empresa`
VALUES (1, 'Empresa 1', '2019-06-13 04:39:50'),
(2, 'Empresa 2', '2019-06-13 04:39:52');
INSERT INTO `estado`
VALUES (1, 'Vendido', '2019-06-12 20:18:57'),
(2, 'Arrendado', '2019-06-12 20:18:57'),
(3, 'Disponible', '2019-06-12 20:18:57');
INSERT INTO `factura`
VALUES (1, '159', 5000, '2019-07-03 00:00:00', '2019-07-03 23:03:36');
INSERT INTO `idioma`
VALUES (1, 'Español', '2019-06-12 20:18:57'),
(2, 'Ingles', '2019-06-12 20:18:57'),
(3, 'Portuges', '2019-06-12 20:18:57'),
(4, 'Aleman', '2019-06-12 20:18:57'),
(5, 'Ruso', '2019-06-12 20:18:57'),
(6, 'Japones', '2019-06-12 20:18:57');
INSERT INTO `libro`
VALUES (1, 1, '0-765-31178-X', 2006, 541, 'Mistborn: The Final Empire', 10000,
'2019-06-12 20:18:57'),
(2, 1, '0-765-31688-9', 2007, 590, 'Mistborn: The Well of Ascension', 10000,
'2019-06-12 20:18:57'),
(3, 1, '978-0-7653-1689-9', 2008, 572, 'Mistborn: The Hero of Ages', 10000,
'2019-06-12 20:18:57'),
(4, 2, '1231231231232', 1931, 100, 'The Shadow over Innsmouth', 10000,
'2019-06-12 20:18:57'),
(5, 2, '1231231231232', 1933, 100, 'The Dreams in the Witch House', 10000,
'2019-06-12 20:18:57'),
(6, 2, '1231231231232', 1936, 100, 'At the Mountains of Madness', 10000,
'2019-06-12 20:18:57'),
(7, 3, '0385086954', 1974, 199, 'Carrie', 10000, '2019-06-12 20:18:57'),
(8, 3, '978-0-670-26077-5', 1979, 428, 'The Dead Zone', 10000, '2019-06-12 20:18:57'),
(9, 3, '0-670-81302-8', 1986, 1138, 'It', 10000, '2019-06-12 20:18:57');
INSERT INTO `libro_autor`
VALUES (1, 3),
(2, 3),
(3, 3),
(4, 1),
(5, 1),
(6, 1),
(7, 2),
(8, 2),
(9, 2);
INSERT INTO `libro_categoria`
VALUES (1, 3),
(2, 3),
(3, 3),
(4, 1),
(5, 1),
(6, 1),
(7, 1),
(8, 1),
(9, 1);
INSERT INTO `libro_idioma`
VALUES (1, 2),
(2, 2),
(3, 2),
(4, 2),
(5, 2),
(6, 2),
(7, 2),
(8, 2),
(9, 2);
INSERT INTO `libro_orden_compra`
VALUES (1, 1);
INSERT INTO `orden_compra`
VALUES (1, 'Recibida', 1, 2, '2019-07-03 23:03:36');
INSERT INTO `trabajador`
VALUES (2, '19763899-0', 'Daniel', 'Cortes', 'Pincheira', '2019-06-13', '2019-06-13 20:04:42'),
(3, '10768789-0', 'Trabajador', 'N', '2', '2019-06-13', '2019-06-13 20:05:17'),
(4, '9717478-4', 'Trabajador', 'N', '3', '2019-06-13', '2019-06-13 20:05:27');
INSERT INTO `trabajador_correo`
VALUES (4, 1),
(2, 2);
INSERT INTO `usuario`
VALUES (2, 'admin', 0x243168097E0BA82B896F348BABCEB600A8DCA30488C6F238F97FD8737BD00B27,
0x3564ECCCD85CF0583F9C090602E998B7, 2, '2019-06-13 20:04:53');

8
dump.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/sh
if [ -z "$1" ]; then
echo "Se debe pasar el nombre de la base de datos"
exit 1
fi
mysqldump -u root -p --compact --hex-blob -t "$1"

View File

@@ -1,17 +1,28 @@
#!/bin/sh
# Ask for password
printf "Pass: "
stty_orig=`stty -g` # save original terminal setting
stty -echo # turn-off echoing.
read PASS # read the password
stty $stty_orig # restore terminal setting.
if [ -z "$1" ]; then
echo "Se debe pasar el nombre de la base de datos"
exit 1
fi
printf "Enter password: "
stty_orig=$(stty -g) # save original terminal setting
stty -echo # turn-off echoing.
read -r PASS # read the password
stty "${stty_orig}" # restore terminal setting.
echo ""
set -e
echo "Ejecutando create.sql"
mysql -u root -p$PASS biblioteca < create.sql
printf "Eliminando: %s \n" "$1"
mysql -u root -p"${PASS}" -e "DROP DATABASE $1"
echo "Ejecutando data.sql"
mysql -u root -p$PASS biblioteca < data.sql
printf "Creando: %s \n" "$1"
mysql -u root -p"${PASS}" -e "CREATE DATABASE $1"
printf "Ejecutando: create.sql \n"
mysql -u root -p"${PASS}" "${1}" < db/create.sql
printf "Ejecutando: data.sql \n"
mysql -u root -p"${PASS}" "${1}" < db/data.sql

504
mysql
View File

@@ -1,504 +0,0 @@
#--------------------------------------------------------------------------------#
#-----------------------------Eliminar todas las tablas--------------------------#
#--------------------------------------------------------------------------------#
start transaction;
set foreign_key_checks = 0;
set autocommit = 0;
drop table if exists editorial;
drop table if exists estado;
drop table if exists autor;
drop table if exists categoria;
drop table if exists idioma;
drop table if exists libro;
drop table if exists ejemplar;
drop table if exists libro_autor;
drop table if exists libro_categoria;
drop table if exists libro_idioma;
drop table if exists correo;
drop table if exists direccion;
drop table if exists telefono;
drop table if exists empresa;
drop table if exists distribuidor;
drop table if exists cliente;
drop table if exists trabajador;
drop table if exists distribuidor_direccion;
drop table if exists distribuidor_telefono;
drop table if exists distribuidor_correo;
drop table if exists cliente_direccion;
drop table if exists cliente_telefono;
drop table if exists cliente_correo;
drop table if exists trabajador_direccion;
drop table if exists trabajador_telefono;
drop table if exists trabajador_correo;
drop table if exists orden_compra;
drop table if exists factura;
drop table if exists boleta;
drop table if exists compra;
drop table if exists venta;
drop table if exists arriendo;
drop table if exists ejemplar_compra;
drop table if exists ejemplar_venta;
drop table if exists ejemplar_arriendo;
drop table if exists usuario;
#--------------------------------------------------------------------------------#
#--------------Definicion de las tablas relacionadas a los libros----------------#
#--------------------------------------------------------------------------------#
create table editorial
(
id int unsigned primary key auto_increment,
nombre varchar(255) not null,
inserted_at timestamp default CURRENT_TIMESTAMP
);
create table estado
(
id int unsigned primary key auto_increment,
nombre varchar(255) not null,
inserted_at timestamp default CURRENT_TIMESTAMP
);
create table autor
(
id int unsigned primary key auto_increment,
nombre varchar(255) not null,
apellido_paterno varchar(255) null,
apellido_materno varchar(255) null,
inserted_at timestamp default CURRENT_TIMESTAMP
);
create table categoria
(
id int unsigned primary key auto_increment,
nombre varchar(255) not null,
inserted_at timestamp default CURRENT_TIMESTAMP
);
create table idioma
(
id int unsigned primary key auto_increment,
nombre varchar(255) not null,
inserted_at timestamp default CURRENT_TIMESTAMP
);
create table libro
(
id int unsigned primary key auto_increment,
editorial_id int unsigned not null,
isbn varchar(255) not null,
ano_publicacion int default null,
numero_paginas int not null,
titulo varchar(255) default null,
precio_referencia int not null,
inserted_at timestamp default CURRENT_TIMESTAMP,
foreign key (editorial_id) references editorial (id) on delete restrict on update cascade
);
create table ejemplar
(
id int unsigned primary key auto_increment,
libro_id int unsigned not null,
estado_id int unsigned default 1,
serie varchar(255) not null,
inserted_at timestamp default CURRENT_TIMESTAMP,
unique key serie_libro (serie, libro_id),
foreign key (libro_id) references libro (id) on delete cascade on update cascade,
foreign key (estado_id) references estado (id) on delete restrict on update cascade
);
create table libro_autor
(
libro_id int unsigned not null,
autor_id int unsigned not null,
foreign key (libro_id) references libro (id) on delete restrict on update cascade,
foreign key (autor_id) references autor (id) on delete restrict on update cascade
);
create table libro_categoria
(
libro_id int unsigned not null,
categoria_id int unsigned not null,
foreign key (libro_id) references libro (id) on delete restrict on update cascade,
foreign key (categoria_id) references categoria (id) on delete restrict on update cascade
);
create table libro_idioma
(
libro_id int unsigned not null,
idioma_id int unsigned not null,
foreign key (libro_id) references libro (id) on delete restrict on update cascade,
foreign key (idioma_id) references idioma (id) on delete restrict on update cascade
);
#--------------------------------------------------------------------------------#
#------------Definicion de las tablas relacionadas a las personas----------------#
#--------------------------------------------------------------------------------#
create table direccion
(
id int unsigned primary key auto_increment,
calle varchar(255) not null,
numero varchar(255) not null,
inserted_at timestamp default CURRENT_TIMESTAMP
);
create table telefono
(
id int unsigned primary key auto_increment,
numero varchar(255) not null,
inserted_at timestamp default CURRENT_TIMESTAMP
);
create table correo
(
id int unsigned primary key auto_increment,
correo varchar(255) not null,
inserted_at timestamp default CURRENT_TIMESTAMP
);
create table empresa
(
id int unsigned primary key auto_increment,
nombre varchar(255) not null,
inserted_at timestamp default CURRENT_TIMESTAMP
);
create table distribuidor
(
id int unsigned primary key auto_increment,
empresa_id int unsigned not null,
rut varchar(255) not null,
inserted_at timestamp default CURRENT_TIMESTAMP,
foreign key (empresa_id) references empresa (id) on delete restrict on update cascade
);
create table cliente
(
id int unsigned primary key auto_increment,
rut varchar(255) not null,
nombre varchar(255) not null,
apellido_paterno varchar(255) not null,
apellido_materno varchar(255) not null,
fecha_nacimiento date not null,
inserted_at timestamp default CURRENT_TIMESTAMP
);
create table trabajador
(
id int unsigned primary key auto_increment,
rut varchar(255) not null,
nombre varchar(255) not null,
apellido_paterno varchar(255) not null,
apellido_materno varchar(255) not null,
fecha_contrato date not null,
inserted_at timestamp default CURRENT_TIMESTAMP
);
create table distribuidor_direccion
(
distribuidor_id int unsigned,
direccion_id int unsigned,
foreign key (distribuidor_id) references cliente (id) on delete restrict on update cascade,
foreign key (direccion_id) references direccion (id) on delete cascade on update cascade
);
create table distribuidor_telefono
(
distribuidor_id int unsigned,
telefono_id int unsigned,
foreign key (distribuidor_id) references cliente (id) on delete restrict on update cascade,
foreign key (telefono_id) references telefono (id) on delete cascade on update cascade
);
create table distribuidor_correo
(
distribuidor_id int unsigned,
correo_id int unsigned,
foreign key (distribuidor_id) references cliente (id) on delete restrict on update cascade,
foreign key (correo_id) references correo (id) on delete cascade on update cascade
);
create table cliente_direccion
(
cliente_id int unsigned,
direccion_id int unsigned,
foreign key (cliente_id) references cliente (id) on delete restrict on update cascade,
foreign key (direccion_id) references direccion (id) on delete cascade on update cascade
);
create table cliente_telefono
(
cliente_id int unsigned,
telefono_id int unsigned,
foreign key (cliente_id) references cliente (id) on delete restrict on update cascade,
foreign key (telefono_id) references telefono (id) on delete cascade on update cascade
);
create table cliente_correo
(
cliente_id int unsigned,
correo_id int unsigned,
foreign key (cliente_id) references cliente (id) on delete restrict on update cascade,
foreign key (correo_id) references correo (id) on delete cascade on update cascade
);
create table trabajador_direccion
(
trabajador_id int unsigned,
direccion_id int unsigned,
foreign key (trabajador_id) references trabajador (id) on delete restrict on update cascade,
foreign key (direccion_id) references direccion (id) on delete cascade on update cascade
);
create table trabajador_telefono
(
trabajador_id int unsigned,
telefono_id int unsigned,
foreign key (trabajador_id) references trabajador (id) on delete restrict on update cascade,
foreign key (telefono_id) references telefono (id) on delete cascade on update cascade
);
create table trabajador_correo
(
trabajador_id int unsigned,
correo_id int unsigned,
foreign key (trabajador_id) references trabajador (id) on delete restrict on update cascade,
foreign key (correo_id) references correo (id) on delete cascade on update cascade
);
#--------------------------------------------------------------------------------#
#-------Definicion de las tablas relacionadas a la venta/compra/arriendo---------#
#--------------------------------------------------------------------------------#
create table factura
(
id int unsigned primary key auto_increment,
folio varchar(255) not null,
precio_neto int not null,
precio_iva int not null,
fecha_compra datetime not null,
inserted_at timestamp default CURRENT_TIMESTAMP
);
create table boleta
(
id int unsigned primary key auto_increment,
folio varchar(255) not null,
precio_neto int not null,
precio_iva int not null,
fecha_venta datetime not null,
inserted_at timestamp default CURRENT_TIMESTAMP
);
create table orden_compra
(
id int unsigned primary key auto_increment,
estado enum ('En Curso', 'Aceptada', 'Cancelada'),
compra_id int unsigned,
distribuidor_id int unsigned not null,
inserted_at timestamp default CURRENT_TIMESTAMP,
foreign key (distribuidor_id) references distribuidor (id) on delete restrict on update cascade,
foreign key (compra_id) references compra (id) on delete restrict on update cascade
);
create table compra
(
id int unsigned primary key auto_increment,
factura_id int unsigned not null,
distribuidor_id int unsigned not null,
inserted_at timestamp default CURRENT_TIMESTAMP,
foreign key (factura_id) references factura (id) on delete restrict on update cascade,
foreign key (distribuidor_id) references cliente (id) on delete restrict on update cascade
);
create table venta
(
id int unsigned primary key auto_increment,
cliente_id int unsigned not null,
trabajador_id int unsigned not null,
boleta_id int unsigned not null,
inserted_at timestamp default CURRENT_TIMESTAMP,
foreign key (cliente_id) references cliente (id) on delete restrict on update cascade,
foreign key (trabajador_id) references trabajador (id) on delete restrict on update cascade,
foreign key (boleta_id) references boleta (id) on delete restrict on update cascade
);
create table arriendo
(
id int unsigned primary key auto_increment,
trabajador_id int unsigned not null,
cliente_id int unsigned not null,
costo_arriendo int not null,
fecha_arriendo date not null,
fecha_devolucion_estimada date not null,
fecha_devolucion_real date,
multa int,
inserted_at timestamp default CURRENT_TIMESTAMP,
foreign key (trabajador_id) references trabajador (id) on delete restrict on update cascade,
foreign key (cliente_id) references cliente (id) on delete restrict on update cascade
);
create table ejemplar_compra
(
ejemplar_id int unsigned,
compra_id int unsigned,
foreign key (ejemplar_id) references ejemplar (id) on delete restrict on update cascade,
foreign key (compra_id) references compra (id) on delete restrict on update cascade
);
create table ejemplar_venta
(
ejemplar_id int unsigned,
venta_id int unsigned,
foreign key (ejemplar_id) references ejemplar (id) on delete restrict on update cascade,
foreign key (venta_id) references venta (id) on delete restrict on update cascade
);
create table ejemplar_arriendo
(
ejemplar_id int unsigned,
arriendo_id int unsigned,
foreign key (ejemplar_id) references ejemplar (id) on delete restrict on update cascade,
foreign key (arriendo_id) references arriendo (id) on delete restrict on update cascade
);
#--------------------------------------------------------------------------------#
#---------------------Definicion de las tablas de usuario------------------------#
#--------------------------------------------------------------------------------#
create table usuario
(
id int unsigned primary key auto_increment,
nombre varchar(255) not null,
password binary(32) not null,
salt binary(16) not null,
trabajador_id int unsigned not null,
inserted_at timestamp default current_timestamp,
foreign key (trabajador_id) references trabajador (id) on delete cascade on update cascade
);
set autocommit = 1;
set foreign_key_checks = 1;
commit;start transaction;
set foreign_key_checks = 0;
set autocommit = 0;
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');
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');
--
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');
INSERT INTO `correo`
VALUES (1, 'HOOLA', '2019-06-13 17:25:41'),
(2, 'skrd159@gmail.com', '2019-06-13 17:32:13');
INSERT INTO `distribuidor`
VALUES (2, 1, '14166920-6', '2019-06-13 03:08:17'),
(3, 2, '8425080-5', '2019-06-13 03:08:23'),
(4, 1, '21629388-6', '2019-06-13 03:08:25'),
(5, 1, '13510176-1', '2019-06-13 03:08:27');
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');
INSERT INTO `empresa`
VALUES (1, 'Empresa 1', '2019-06-13 00:39:50'),
(2, 'Empresa 2', '2019-06-13 00:39:52');
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');
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');
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');
INSERT INTO `libro_autor`
VALUES (1, 3),
(2, 3),
(3, 3),
(4, 1),
(5, 1),
(6, 1),
(7, 2),
(8, 2),
(9, 2);
INSERT INTO `libro_categoria`
VALUES (1, 3),
(2, 3),
(3, 3),
(4, 1),
(5, 1),
(6, 1),
(7, 1),
(8, 1),
(9, 1);
INSERT INTO `libro_idioma`
VALUES (1, 2),
(2, 2),
(3, 2),
(4, 2),
(5, 2),
(6, 2),
(7, 2),
(8, 2),
(9, 2);
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');
INSERT INTO `trabajador_correo`
VALUES (4, 1),
(2, 2);
INSERT INTO `usuario`
VALUES (2, 'admin', 0x243168097E0BA82B896F348BABCEB600A8DCA30488C6F238F97FD8737BD00B27,
0x3564ECCCD85CF0583F9C090602E998B7, 2, '2019-06-13 16:04:53');
set autocommit = 1;
set foreign_key_checks = 1;
commit;

View File

@@ -87,6 +87,8 @@ import xyz.danielcortes.controllers.trabajador.telefono.TrabajadorTelefonoViewCo
import xyz.danielcortes.controllers.trabajador.usuario.UsuarioCreateController;
import xyz.danielcortes.controllers.trabajador.usuario.UsuarioUpdateController;
import xyz.danielcortes.controllers.trabajador.usuario.UsuarioViewController;
import xyz.danielcortes.controllers.vender.VenderSearchController;
import xyz.danielcortes.controllers.vender.VenderVenderController;
import xyz.danielcortes.framework.BaseController;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.models.Usuario;
@@ -148,6 +150,8 @@ import xyz.danielcortes.views.trabajador.TrabajadorViewPanel;
import xyz.danielcortes.views.usuario.UsuarioCreatePanel;
import xyz.danielcortes.views.usuario.UsuarioUpdatePanel;
import xyz.danielcortes.views.usuario.UsuarioViewPanel;
import xyz.danielcortes.views.vender.VenderSearchPanel;
import xyz.danielcortes.views.vender.VenderVenderPanel;
/**
* Controlador principal de la aplicacion
@@ -305,6 +309,9 @@ public class LaunchController {
this.controllers.put(PanelName.ORDEN_COMPRA_ACEPTAR, new OrdenCompraAceptarController(new OrdenCompraAceptarPanel(), this));
this.controllers.put(PanelName.ORDEN_COMPRA_ASIGNAR, new OrdenCompraAsignarController(new OrdenCompraAsignarPanel(), this));
this.controllers.put(PanelName.VENDER_SEARCH, new VenderSearchController(new VenderSearchPanel(), this));
this.controllers.put(PanelName.VENDER_VENDER, new VenderVenderController(new VenderVenderPanel(), this));
for (Entry<PanelName, BaseController> entry : this.controllers.entrySet()) {
this.frame.addCard(entry.getValue().getView().getContentPane(), entry.getKey());
}

View File

@@ -122,7 +122,7 @@ public class OrdenCompraAceptarController extends BaseController {
compra.setFactura(factura);
this.compraRepository.save(compra);
this.ordenCompra.setEstado("Aceptada");
this.ordenCompra.setEstado("Recibida");
this.ordenCompra.setCompra(compra);
this.ordenCompraRepository.update(this.ordenCompra);

View File

@@ -69,10 +69,10 @@ public class OrdenCompraSearchController extends BaseController {
JOptionPane.ERROR_MESSAGE
);
return;
} else if (ordenCompra.getEstado().equals("Aceptada")) {
} else if (ordenCompra.getEstado().equals("Recibida")) {
JOptionPane.showMessageDialog(
null,
"La orden ya fue aceptada",
"La orden ya fue Recibida",
"Error",
JOptionPane.ERROR_MESSAGE
);

View File

@@ -0,0 +1,57 @@
package xyz.danielcortes.controllers.vender;
import java.util.List;
import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.framework.BaseController;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.framework.PanelName;
import xyz.danielcortes.models.Venta;
import xyz.danielcortes.repository.VenderRepository;
import xyz.danielcortes.views.vender.VenderSearchPanel;
public class VenderSearchController extends BaseController {
private VenderSearchPanel view;
private VenderRepository repository;
public VenderSearchController(VenderSearchPanel view, LaunchController parent) {
super(parent);
this.view = view;
this.repository = new VenderRepository();
this.setupListeners();
}
private void setupListeners() {
this.view.getBuscarButton().addActionListener(e -> this.search());
this.view.getBuscarField().addActionListener(e -> this.search());
this.view.getVenderButton().addActionListener(e -> this.vender());
this.view.getVerButton().addActionListener(e -> this.ver());
}
private void search() {
}
private void vender() {
this.parentController.showCard(PanelName.VENDER_VENDER);
}
private void ver() {
}
@Override
public void show() {
this.loadTable();
this.view.getVentasTable().clearSelection();
this.view.getBuscarField().setText("");
}
private void loadTable() {
List<Venta> ventas = this.repository.getAll();
this.view.getVentaTableModel().setRows(ventas);
}
@Override
public BasePanel getView() {
return this.view;
}
}

View File

@@ -0,0 +1,61 @@
package xyz.danielcortes.controllers.vender;
import java.util.List;
import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.framework.BaseController;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.models.Cliente;
import xyz.danielcortes.models.Ejemplar;
import xyz.danielcortes.repository.ClienteRepository;
import xyz.danielcortes.repository.EjemplarRepository;
import xyz.danielcortes.repository.VenderRepository;
import xyz.danielcortes.views.vender.VenderVenderPanel;
public class VenderVenderController extends BaseController {
private VenderVenderPanel view;
private VenderRepository venderRepository;
private ClienteRepository clienteRepository;
private EjemplarRepository ejemplarRepository;
public VenderVenderController(VenderVenderPanel view, LaunchController parentController) {
super(parentController);
this.view = view;
this.venderRepository = new VenderRepository();
this.clienteRepository = new ClienteRepository();
this.ejemplarRepository = new EjemplarRepository();
this.setupListeners();
}
private void setupListeners() {
this.view.getAgregarButton().addActionListener(e -> this.agregar());
}
private void agregar() {
}
@Override
public void show() {
this.fillCliente();
this.fillEjemplares();
this.view.getEjemplaresTableModel().removeRows();
}
private void fillCliente() {
List<Cliente> cliente = this.clienteRepository.getAll();
this.view.getClienteComboModel().removeAllElements();
this.view.getClienteComboModel().addAll(cliente);
}
private void fillEjemplares() {
List<Ejemplar> ejemplares = this.ejemplarRepository.getAll();
this.view.getEjemplaresComboModel().removeAllElements();
this.view.getEjemplaresComboModel().addAll(ejemplares);
}
@Override
public BasePanel getView() {
return this.view;
}
}

View File

@@ -0,0 +1,23 @@
package xyz.danielcortes.controllers.vender;
import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.framework.BaseController;
import xyz.danielcortes.framework.BasePanel;
public class VenderVerController extends BaseController {
public VenderVerController(LaunchController parentController) {
super(parentController);
}
@Override
public void show() {
}
@Override
public BasePanel getView() {
return null;
}
}

View File

@@ -0,0 +1,11 @@
package xyz.danielcortes.repository;
import xyz.danielcortes.framework.BaseRepository;
import xyz.danielcortes.models.Cliente;
public class ClienteRepository extends BaseRepository<Cliente> {
public ClienteRepository() {
super(Cliente.class);
}
}

View File

@@ -12,7 +12,11 @@ public class OrdenCompraRepository extends BaseRepository<OrdenCompra> {
}
public List<OrdenCompra> search(String term) {
Query query = this.em.createQuery("SELECT o FROM OrdenCompra o WHERE LOWER(o.estado) LIKE :term");
Query query = this.em.createQuery("SELECT o FROM OrdenCompra o WHERE"
+ " LOWER(o.estado) LIKE :term OR"
+ " LOWER(o.distribuidor.rut) LIKE :term OR "
+ " CONCAT(o.libros.size, '') LIKE :term OR "
+ " LOWER(o.insertedAt) LIKE :term");
query.setParameter("term", "%" + term.toLowerCase() + "%");
return query.getResultList();
}

View File

@@ -0,0 +1,13 @@
package xyz.danielcortes.repository;
import xyz.danielcortes.framework.BaseRepository;
import xyz.danielcortes.models.Venta;
public class VenderRepository extends BaseRepository<Venta> {
public VenderRepository() {
super(Venta.class);
}
}

View File

@@ -19,7 +19,7 @@ public class OrdenCompraValidator {
// se ve mas cul
switch (estado) {
case "En Curso":
case "Aceptada":
case "Recibida":
case "Cancelada":
return ValidationResult.NON_ERROR;
default:

View File

@@ -153,4 +153,5 @@ public class IdiomaSearchPanel extends BasePanel {
public JComponent $$$getRootComponent$$$() {
return contentPane;
}
}

View File

@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.vender.VenderSearchPanel">
<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">
<margin top="20" left="20" bottom="20" right="20"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<scrollpane id="ec841">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="3" 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="71e3b" class="javax.swing.JTable" binding="ventasTable" custom-create="true">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
<grid id="9441d" 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="0" 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="a29f8" class="javax.swing.JButton" binding="buscarButton" 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="Buscar"/>
</properties>
</component>
<component id="97bf7" class="javax.swing.JTextField" binding="buscarField">
<constraints>
<grid row="0" 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/>
</component>
</children>
</grid>
<grid id="9ab80" 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="2" 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="92d7b" class="javax.swing.JButton" binding="verButton" 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="Ver"/>
</properties>
</component>
<component id="49f8e" class="javax.swing.JButton" binding="venderButton">
<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="Vender"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</form>

View File

@@ -0,0 +1,136 @@
package xyz.danielcortes.views.vender;
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.Venta;
public class VenderSearchPanel extends BasePanel {
private JPanel contentPane;
private JTable ventasTable;
private JButton buscarButton;
private JTextField buscarField;
private JButton verButton;
private JButton venderButton;
private BaseTableModel<Venta> ventaTableModel;
{
// 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 getVentasTable() {
return this.ventasTable;
}
public JButton getBuscarButton() {
return this.buscarButton;
}
public JTextField getBuscarField() {
return this.buscarField;
}
public JButton getVerButton() {
return this.verButton;
}
public JButton getVenderButton() {
return this.venderButton;
}
public BaseTableModel<Venta> getVentaTableModel() {
return this.ventaTableModel;
}
/**
* 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, 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_CAN_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(400, -1), null, 0, false));
scrollPane1.setViewportView(ventasTable);
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel1, new GridConstraints(0, 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));
buscarButton = new JButton();
buscarButton.setText("Buscar");
panel1.add(buscarButton, 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));
buscarField = new JTextField();
panel1.add(buscarField,
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));
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
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));
verButton = new JButton();
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));
venderButton = new JButton();
venderButton.setText("Vender");
panel2.add(venderButton, 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));
}
private void createUIComponents() {
// @formatter:off
this.ventaTableModel = new BaseTableModel<>(
new String[]{"Fecha Emision", "Nº Boleta", "Nº Ejemplares", "Vendedor", "Cliente"},
(row, rowIndex, colIndex) -> {
switch (colIndex) {
case 0: return row.get(rowIndex).getBoleta().getFechaEmision();
case 1: return row.get(rowIndex).getBoleta().getFolio();
case 2: return row.get(rowIndex).getEjemplares().size();
case 3: return row.get(rowIndex).getTrabajador().getRut();
case 4: return row.get(rowIndex).getCliente().getRut();
default: return null;
}
}
);
// @formatter:on
this.ventasTable = new JTable(this.ventaTableModel);
this.ventasTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return contentPane;
}
}

View File

@@ -0,0 +1,193 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.vender.VenderVenderPanel">
<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="490" height="536"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="11a46" 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="de140" class="javax.swing.JButton" binding="venderButton" 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="Vender"/>
</properties>
</component>
<component id="6c400" class="javax.swing.JButton" binding="cancelarButton" 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="Cancelar"/>
</properties>
</component>
</children>
</grid>
<vspacer id="83ea6">
<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>
<hspacer id="832a4">
<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="7d130">
<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="10dc0" 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="Cliente:"/>
</properties>
</component>
<scrollpane id="40e17">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="46eda" class="javax.swing.JTable" binding="ejemplaresTable" custom-create="true">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
<grid id="58392" layout-manager="GridLayoutManager" row-count="2" 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="2" 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="92e07" 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="Ejemplares:"/>
</properties>
</component>
<component id="808b9" class="javax.swing.JComboBox" binding="ejemplaresCombo" custom-create="true">
<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"/>
</constraints>
<properties/>
</component>
<component id="9343d" class="javax.swing.JButton" binding="agregarButton" 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">
<preferred-size width="30" height="-1"/>
</grid>
</constraints>
<properties>
<text value="+"/>
</properties>
</component>
</children>
</grid>
<component id="350ea" class="javax.swing.JComboBox" binding="clienteCombo" custom-create="true">
<constraints>
<grid row="1" 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="184ff" 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="Precio Total:"/>
</properties>
</component>
<component id="441d9" class="javax.swing.JTextField" binding="precioTotalField">
<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="400" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="c72e8" 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="195f" 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="89a07" 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="400" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="1d61e" 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="400" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="89829" 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="Folio:"/>
</properties>
</component>
<component id="f03bc" class="javax.swing.JTextField" binding="folioField">
<constraints>
<grid row="5" 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>
<editable value="false"/>
</properties>
</component>
</children>
</grid>
</form>

View File

@@ -0,0 +1,239 @@
package xyz.danielcortes.views.vender;
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.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
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 javax.swing.ListSelectionModel;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.framework.BaseTableModel;
import xyz.danielcortes.models.Cliente;
import xyz.danielcortes.models.Ejemplar;
public class VenderVenderPanel extends BasePanel {
private JPanel contentPane;
private JButton venderButton;
private JButton cancelarButton;
private JTable ejemplaresTable;
private BaseTableModel<Ejemplar> ejemplaresTableModel;
private JComboBox<Cliente> clienteCombo;
private DefaultComboBoxModel<Cliente> clienteComboModel;
private JComboBox<Ejemplar> ejemplaresCombo;
private DefaultComboBoxModel<Ejemplar> ejemplaresComboModel;
private JButton agregarButton;
private JTextField precioTotalField;
private JTextField precioNetoField;
private JTextField ivaField;
private JTextField folioField;
{
// 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 JButton getVenderButton() {
return this.venderButton;
}
public JButton getCancelarButton() {
return this.cancelarButton;
}
public JTable getEjemplaresTable() {
return this.ejemplaresTable;
}
public JComboBox getClienteCombo() {
return this.clienteCombo;
}
public JComboBox getEjemplaresCombo() {
return this.ejemplaresCombo;
}
public JButton getAgregarButton() {
return this.agregarButton;
}
public JTextField getPrecioTotalField() {
return this.precioTotalField;
}
public JTextField getPrecioNetoField() {
return this.precioNetoField;
}
public JTextField getIvaField() {
return this.ivaField;
}
public JTextField getFolioField() {
return this.folioField;
}
public BaseTableModel<Ejemplar> getEjemplaresTableModel() {
return this.ejemplaresTableModel;
}
public DefaultComboBoxModel<Cliente> getClienteComboModel() {
return this.clienteComboModel;
}
public DefaultComboBoxModel<Ejemplar> getEjemplaresComboModel() {
return this.ejemplaresComboModel;
}
/**
* 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(14, 3, new Insets(20, 20, 20, 20), -1, -1));
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));
venderButton = new JButton();
venderButton.setText("Vender");
panel1.add(venderButton, 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));
cancelarButton = new JButton();
cancelarButton.setText("Cancelar");
panel1.add(cancelarButton, 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 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));
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 label1 = new JLabel();
label1.setText("Cliente:");
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 JScrollPane scrollPane1 = new JScrollPane();
contentPane.add(scrollPane1, new GridConstraints(3, 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, null, null, 0, false));
scrollPane1.setViewportView(ejemplaresTable);
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel2, new GridConstraints(2, 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));
final JLabel label2 = new JLabel();
label2.setText("Ejemplares:");
panel2.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
panel2.add(ejemplaresCombo,
new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
agregarButton = new JButton();
agregarButton.setText("+");
panel2.add(agregarButton, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(30, -1),
null, 0, false));
contentPane.add(clienteCombo,
new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false));
final JLabel label3 = new JLabel();
label3.setText("Precio Total:");
contentPane.add(label3, new GridConstraints(10, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
precioTotalField = new JTextField();
precioTotalField.setEditable(false);
contentPane.add(precioTotalField,
new GridConstraints(11, 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 label4 = new JLabel();
label4.setText("IVA:");
contentPane.add(label4, 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 label5 = new JLabel();
label5.setText("Precio Neto:");
contentPane.add(label5, 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();
precioNetoField.setEditable(false);
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(400, -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(400, -1), null, 0, false));
final JLabel label6 = new JLabel();
label6.setText("Folio:");
contentPane.add(label6, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
folioField = new JTextField();
folioField.setEditable(false);
contentPane.add(folioField,
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));
}
private void createUIComponents() {
this.clienteComboModel = new DefaultComboBoxModel<>();
this.clienteCombo = new JComboBox<>(this.clienteComboModel);
this.ejemplaresComboModel = new DefaultComboBoxModel<>();
this.ejemplaresCombo = new JComboBox<>(this.ejemplaresComboModel);
// @formatter:off
this.ejemplaresTableModel = new BaseTableModel<>(
new String[]{"ISBN", "Serie", "Titulo"},
(row, rowIndex, colIndex) -> {
switch (colIndex) {
case 0: return row.get(rowIndex).getLibro().getIsbn();
case 1: return row.get(rowIndex).getSerie();
case 2: return row.get(rowIndex).getLibro().getTitulo();
default: return null;
}
}
);
// @formatter:on
this.ejemplaresTable = new JTable(this.ejemplaresTableModel);
this.ejemplaresTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return contentPane;
}
}

View File

@@ -0,0 +1,157 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="xyz.danielcortes.views.vender.VenderVerPanel">
<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="490" height="536"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="11a46" 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="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="6c400" class="javax.swing.JButton" binding="volverButton">
<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>
<vspacer id="83ea6">
<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>
<hspacer id="832a4">
<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="7d130">
<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="10dc0" 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="Cliente:"/>
</properties>
</component>
<scrollpane id="40e17">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="46eda" class="javax.swing.JTable" binding="ejemplaresTable" custom-create="true">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
<component id="184ff" 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="Precio Total:"/>
</properties>
</component>
<component id="441d9" class="javax.swing.JTextField" binding="precioTotalField">
<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="400" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="c72e8" 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="195f" 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="89a07" 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="400" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="1d61e" 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="400" height="-1"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
</properties>
</component>
<component id="89829" 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="Folio:"/>
</properties>
</component>
<component id="f03bc" class="javax.swing.JTextField" binding="folioField">
<constraints>
<grid row="5" 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>
<editable value="false"/>
</properties>
</component>
<component id="92e07" 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="Ejemplares:"/>
</properties>
</component>
<component id="61ff7" class="javax.swing.JTextField" binding="clienteField">
<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="400" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
</children>
</grid>
</form>

View File

@@ -0,0 +1,192 @@
package xyz.danielcortes.views.vender;
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 javax.swing.ListSelectionModel;
import xyz.danielcortes.framework.BasePanel;
import xyz.danielcortes.framework.BaseTableModel;
import xyz.danielcortes.models.Ejemplar;
public class VenderVerPanel extends BasePanel {
private JPanel contentPane;
private JButton venderButton;
private JButton volverButton;
private JTable ejemplaresTable;
private BaseTableModel<Ejemplar> ejemplaresTableModel;
private JButton agregarButton;
private JTextField precioTotalField;
private JTextField precioNetoField;
private JTextField ivaField;
private JTextField folioField;
private JTextField clienteField;
{
// 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 JButton getVenderButton() {
return this.venderButton;
}
public JButton getVolverButton() {
return this.volverButton;
}
public JTable getEjemplaresTable() {
return this.ejemplaresTable;
}
public JButton getAgregarButton() {
return this.agregarButton;
}
public JTextField getPrecioTotalField() {
return this.precioTotalField;
}
public JTextField getPrecioNetoField() {
return this.precioNetoField;
}
public JTextField getIvaField() {
return this.ivaField;
}
public JTextField getFolioField() {
return this.folioField;
}
public JTextField getClienteField() {
return this.clienteField;
}
/**
* 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(14, 3, new Insets(20, 20, 20, 20), -1, -1));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(1, 1, 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));
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 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));
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 label1 = new JLabel();
label1.setText("Cliente:");
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 JScrollPane scrollPane1 = new JScrollPane();
contentPane.add(scrollPane1, new GridConstraints(3, 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, null, null, 0, false));
scrollPane1.setViewportView(ejemplaresTable);
final JLabel label2 = new JLabel();
label2.setText("Precio Total:");
contentPane.add(label2, new GridConstraints(10, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
precioTotalField = new JTextField();
precioTotalField.setEditable(false);
contentPane.add(precioTotalField,
new GridConstraints(11, 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("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("Precio Neto:");
contentPane.add(label4, 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();
precioNetoField.setEditable(false);
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(400, -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(400, -1), null, 0, false));
final JLabel label5 = new JLabel();
label5.setText("Folio:");
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));
folioField = new JTextField();
folioField.setEditable(false);
contentPane.add(folioField,
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 label6 = new JLabel();
label6.setText("Ejemplares:");
contentPane.add(label6, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
clienteField = new JTextField();
contentPane.add(clienteField,
new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(400, -1), null, 0, false));
}
private void createUIComponents() {
// @formatter:off
this.ejemplaresTableModel = new BaseTableModel<>(
new String[]{"ISBN", "Serie", "Titulo"},
(row, rowIndex, colIndex) -> {
switch (colIndex) {
case 0: return row.get(rowIndex).getLibro().getIsbn();
case 1: return row.get(rowIndex).getSerie();
case 2: return row.get(rowIndex).getLibro().getTitulo();
default: return null;
}
}
);
// @formatter:on
this.ejemplaresTable = new JTable(this.ejemplaresTableModel);
this.ejemplaresTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return contentPane;
}
}