Correcciones varias... se me fue la onda
Le puse una columna de inserted_at a todas las tablas de la base de datos excepto las de join El resto son bugs.. no se, muchas cosas
This commit is contained in:
118
script.sql
118
script.sql
@@ -2,39 +2,40 @@
|
||||
#-----------------------------Eliminar todas las tablas--------------------------#
|
||||
#--------------------------------------------------------------------------------#
|
||||
set foreign_key_checks = 0;
|
||||
drop table if exists usuario;
|
||||
drop table if exists libro_arriendo;
|
||||
drop table if exists libro_venta;
|
||||
drop table if exists libro_compra;
|
||||
drop table if exists arriendo;
|
||||
drop table if exists venta;
|
||||
drop table if exists compra;
|
||||
drop table if exists boleta;
|
||||
drop table if exists factura;
|
||||
drop table if exists trabajador_telefono;
|
||||
drop table if exists trabajador_direccion;
|
||||
drop table if exists cliente_telefono;
|
||||
drop table if exists cliente_direccion;
|
||||
drop table if exists distribuidor_telefono;
|
||||
drop table if exists distribuidor_direccion;
|
||||
drop table if exists trabajador;
|
||||
drop table if exists cliente;
|
||||
drop table if exists distribuidor;
|
||||
drop table if exists empresa;
|
||||
drop table if exists telefono;
|
||||
drop table if exists direccion;
|
||||
drop table if exists libro_idioma;
|
||||
drop table if exists libro_categoria;
|
||||
drop table if exists libro_autor;
|
||||
|
||||
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 editorial;
|
||||
drop table if exists idioma;
|
||||
drop table if exists categoria;
|
||||
drop table if exists autor;
|
||||
drop table if exists estado;
|
||||
set foreign_key_checks = 1;
|
||||
drop table if exists libro_autor;
|
||||
drop table if exists libro_categoria;
|
||||
drop table if exists libro_idioma;
|
||||
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 cliente_direccion;
|
||||
drop table if exists cliente_telefono;
|
||||
drop table if exists trabajador_direccion;
|
||||
drop table if exists trabajador_telefono;
|
||||
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_compra;
|
||||
drop table if exists libro_venta;
|
||||
drop table if exists libro_arriendo;
|
||||
drop table if exists usuario;
|
||||
|
||||
set foreign_key_checks = 1;
|
||||
|
||||
#--------------------------------------------------------------------------------#
|
||||
#--------------Definicion de las tablas relacionadas a los libros----------------#
|
||||
@@ -42,13 +43,15 @@ set foreign_key_checks = 1;
|
||||
create table editorial
|
||||
(
|
||||
id int unsigned primary key auto_increment,
|
||||
nombre varchar(255) not null
|
||||
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
|
||||
nombre varchar(255) not null,
|
||||
inserted_at timestamp default CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
create table autor
|
||||
@@ -56,19 +59,22 @@ create table autor
|
||||
id int unsigned primary key auto_increment,
|
||||
nombre varchar(255) not null,
|
||||
apellido_paterno varchar(255) not null,
|
||||
apellido_materno varchar(255) not null
|
||||
apellido_materno varchar(255) not null,
|
||||
inserted_at timestamp default CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
create table categoria
|
||||
(
|
||||
id int unsigned primary key auto_increment,
|
||||
nombre varchar(255) not null
|
||||
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
|
||||
nombre varchar(255) not null,
|
||||
inserted_at timestamp default CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
create table libro
|
||||
@@ -80,7 +86,8 @@ create table libro
|
||||
precio_referencia int not null,
|
||||
ano_publicacion int default null,
|
||||
editorial_id int unsigned not null,
|
||||
foreign key (editorial_id) references editorial (id) on delete restrict on update cascade
|
||||
foreign key (editorial_id) references editorial (id) on delete restrict on update cascade,
|
||||
inserted_at timestamp default CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
create table ejemplar
|
||||
@@ -91,7 +98,8 @@ create table ejemplar
|
||||
estado_id int unsigned default 1,
|
||||
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
|
||||
foreign key (estado_id) references estado (id) on delete restrict on update cascade,
|
||||
inserted_at timestamp default CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
create table libro_autor
|
||||
@@ -126,19 +134,22 @@ create table direccion
|
||||
(
|
||||
id int unsigned primary key auto_increment,
|
||||
calle varchar(255) not null,
|
||||
numero 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
|
||||
numero 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
|
||||
nombre varchar(255) not null,
|
||||
inserted_at timestamp default CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
create table distribuidor
|
||||
@@ -146,7 +157,8 @@ create table distribuidor
|
||||
id int unsigned primary key auto_increment,
|
||||
rut varchar(255) not null,
|
||||
empresa_id int unsigned not null,
|
||||
foreign key (empresa_id) references empresa (id) on delete restrict on update cascade
|
||||
foreign key (empresa_id) references empresa (id) on delete restrict on update cascade,
|
||||
inserted_at timestamp default CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
create table cliente
|
||||
@@ -156,7 +168,8 @@ create table cliente
|
||||
nombre varchar(255) not null,
|
||||
apellido_paterno varchar(255) not null,
|
||||
apellido_materno varchar(255) not null,
|
||||
fecha_nacimiento date not null
|
||||
fecha_nacimiento date not null,
|
||||
inserted_at timestamp default CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
create table trabajador
|
||||
@@ -166,7 +179,8 @@ create table trabajador
|
||||
nombre varchar(255) not null,
|
||||
apellido_paterno varchar(255) not null,
|
||||
apellido_materno varchar(255) not null,
|
||||
fecha_contrato date not null
|
||||
fecha_contrato date not null,
|
||||
inserted_at timestamp default CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
create table distribuidor_direccion
|
||||
@@ -228,7 +242,8 @@ create table factura
|
||||
precio_neto int not null,
|
||||
precio_iva int not null,
|
||||
costo_iva int not null,
|
||||
fecha_compra datetime not null
|
||||
fecha_compra datetime not null,
|
||||
inserted_at timestamp default CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
create table boleta
|
||||
@@ -238,7 +253,8 @@ create table boleta
|
||||
precio_neto int not null,
|
||||
precio_iva int not null,
|
||||
costo_iva int not null,
|
||||
fecha_venta datetime not null
|
||||
fecha_venta datetime not null,
|
||||
inserted_at timestamp default CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
create table compra
|
||||
@@ -247,7 +263,8 @@ create table compra
|
||||
factura_id int unsigned not null,
|
||||
distribuidor_id int unsigned not null,
|
||||
foreign key (factura_id) references factura (id) on delete restrict on update cascade,
|
||||
foreign key (distribuidor_id) references distribuidor (id) on delete restrict on update cascade
|
||||
foreign key (distribuidor_id) references distribuidor (id) on delete restrict on update cascade,
|
||||
inserted_at timestamp default CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
create table venta
|
||||
@@ -258,7 +275,8 @@ create table venta
|
||||
boleta_id int unsigned not null,
|
||||
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
|
||||
foreign key (boleta_id) references boleta (id) on delete restrict on update cascade,
|
||||
inserted_at timestamp default CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
create table arriendo
|
||||
@@ -271,7 +289,8 @@ create table arriendo
|
||||
fecha_devolucion_estimada date not null,
|
||||
fecha_devolucion_real date,
|
||||
trabajador_id int unsigned not null,
|
||||
cliente_id int unsigned not null
|
||||
cliente_id int unsigned not null,
|
||||
inserted_at timestamp default CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
create table libro_compra
|
||||
@@ -308,7 +327,8 @@ create table usuario
|
||||
nombre varchar(255) not null,
|
||||
password varbinary(2000) not null,
|
||||
trabajador_id int unsigned not null,
|
||||
foreign key (trabajador_id) references trabajador (id) on delete cascade on update cascade
|
||||
foreign key (trabajador_id) references trabajador (id) on delete cascade on update cascade,
|
||||
inserted_at timestamp default current_timestamp
|
||||
);
|
||||
|
||||
#--------------------------------------------------------------------------------#
|
||||
|
||||
@@ -7,7 +7,6 @@ import javax.swing.UnsupportedLookAndFeelException;
|
||||
import xyz.danielcortes.controllers.LaunchController;
|
||||
import xyz.danielcortes.login.LoginController;
|
||||
import xyz.danielcortes.login.LoginPanel;
|
||||
import xyz.danielcortes.models.Usuario;
|
||||
|
||||
public class App {
|
||||
|
||||
@@ -15,7 +14,7 @@ public class App {
|
||||
setupLookAndFeel();
|
||||
LoginController loginController = new LoginController(new LoginPanel());
|
||||
loginController.setLoggedListener(e -> {
|
||||
LaunchController launchController = new LaunchController(new Usuario());
|
||||
LaunchController launchController = new LaunchController(e.getUser());
|
||||
launchController.run();
|
||||
});
|
||||
}
|
||||
@@ -31,7 +30,7 @@ public class App {
|
||||
String metal = "javax.swing.plaf.metal.MetalLookAndFeel";
|
||||
String gtk = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
|
||||
|
||||
UIManager.setLookAndFeel(gtk);
|
||||
UIManager.setLookAndFeel(nimbus);
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class TrabajadorUpdateController extends BaseController {
|
||||
return;
|
||||
}
|
||||
|
||||
String apellidoMaterno = this.view.getApellidoPaternoField().getText();
|
||||
String apellidoMaterno = this.view.getApellidoMaternoField().getText();
|
||||
ValidationResult apellidoMaternoValidation = this.trabajadorValidator.validateApellidoMaterno(apellidoMaterno);
|
||||
if(apellidoMaternoValidation.hasError()){
|
||||
apellidoMaternoValidation.showErrorDialog();
|
||||
|
||||
@@ -39,6 +39,7 @@ public class TrabajadorViewController extends BaseController {
|
||||
this.view.getApellidoPaternoField().setText(this.trabajador.getApellidoPaterno());
|
||||
this.view.getApellidoMaternoField().setText(this.trabajador.getApellidoMaterno());
|
||||
this.view.getFechaContratoPicker().setDate(this.trabajador.getFechaContrato());
|
||||
this.view.getUsernameField().setText(this.trabajador.getUsuario().getNombre());
|
||||
}
|
||||
|
||||
public BasePanel getView() {
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.WindowConstants;
|
||||
import xyz.danielcortes.framework.Hash;
|
||||
import xyz.danielcortes.framework.LoggedEvent;
|
||||
@@ -44,6 +45,13 @@ public class LoginController {
|
||||
if (Arrays.equals(pass, user.getPassword())) {
|
||||
this.frame.dispose();
|
||||
loggedListener.loginTry(new LoggedEvent(this, user));
|
||||
}else{
|
||||
JOptionPane.showMessageDialog(
|
||||
null,
|
||||
"El usuario o contraseña son incorrectos",
|
||||
"Error",
|
||||
JOptionPane.ERROR_MESSAGE
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@@ -31,6 +32,9 @@ public class Trabajador {
|
||||
@Column(name = "fecha_contrato")
|
||||
private LocalDate fechaContrato;
|
||||
|
||||
@OneToOne(mappedBy = "trabajador")
|
||||
private Usuario usuario;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -79,6 +83,14 @@ public class Trabajador {
|
||||
this.fechaContrato = fechaContrato;
|
||||
}
|
||||
|
||||
public Usuario getUsuario() {
|
||||
return usuario;
|
||||
}
|
||||
|
||||
public void setUsuario(Usuario usuario) {
|
||||
this.usuario = usuario;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
|
||||
@@ -112,7 +112,9 @@
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<properties>
|
||||
<editable value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="c3b00" class="com.github.lgooddatepicker.components.DatePicker" binding="fechaContratoPicker">
|
||||
<constraints>
|
||||
@@ -134,7 +136,9 @@
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<properties>
|
||||
<editable value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
|
||||
Reference in New Issue
Block a user