Skip to content

Commit 0e527d7

Browse files
committed
añadidio fecha a proyectos
1 parent c7b9356 commit 0e527d7

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/electricity_bills_system/SaveProject.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55
import java.awt.event.*;
66
import javax.swing.*;
77
import java.sql.*;
8+
import java.text.SimpleDateFormat;
9+
import java.util.Date;
810

911

1012
public class SaveProject extends JFrame implements ActionListener {
1113
RoundedButton volver, crear;
1214
JTextField cajon_nombre, cajon_precio;
1315
JComboBox cajon_tipo;
14-
String NIF,ID_USER;
16+
String NIF,ID_USER,DATE;
17+
SimpleDateFormat dateFormat;
18+
JFormattedTextField dateField;
1519
SaveProject(String NIF,String ID_USER) {
1620
this.NIF = NIF;
1721
this.ID_USER = ID_USER;
@@ -94,15 +98,11 @@ public class SaveProject extends JFrame implements ActionListener {
9498
panel.add(panelBotones, gbc);
9599

96100
crear = new RoundedButton(" Continuar ");
97-
crear.setBackground(new Color(222, 239, 255));
98-
crear.setForeground(Color.BLACK);
99101
crear.setFont(new Font("Roboto", Font.PLAIN, 16));
100102
crear.addActionListener(this);
101103
panelBotones.add(crear, BorderLayout.WEST);
102104

103105
volver = new RoundedButton(" Volver ");
104-
volver.setBackground(new Color(222, 239, 255));
105-
volver.setForeground(Color.BLACK);
106106
volver.setFont(new Font("Roboto", Font.PLAIN, 16));
107107
volver.addActionListener(this);
108108
panelBotones.add(volver, BorderLayout.EAST);
@@ -116,24 +116,21 @@ public class SaveProject extends JFrame implements ActionListener {
116116

117117

118118
public void actionPerformed(ActionEvent ae) {
119+
dateFormat = new SimpleDateFormat("dd-MM-yyyy");
120+
DATE = dateFormat.format(new Date());
119121
if (ae.getSource() == crear) {
120122
String name = cajon_nombre.getText().toLowerCase().trim();
121123
int name_length = name.length();
122124
String tipo =(String) cajon_tipo.getSelectedItem();
123125
tipo = tipo.toLowerCase().trim();
124126
int iva_length = tipo.length();
125127
String price = cajon_precio.getText().toLowerCase().trim();
126-
int price_length = price.length();
127128

128129
boolean action=true;
129130
if (name_length > 20) {
130131
JOptionPane.showMessageDialog(null, "Nombre demasiado largo");
131132
action=false;
132133
}
133-
if (price_length > 5) {
134-
JOptionPane.showMessageDialog(null, "Unidad de precio demasiado grande");
135-
action=false;
136-
}
137134

138135
int nombre_existente = 0;
139136
try {
@@ -157,7 +154,7 @@ public void actionPerformed(ActionEvent ae) {
157154
if (action && nombre_existente == 0) {
158155
try {
159156
Connect c = new Connect();
160-
String query = "insert into save_project values('"+name+"', '"+tipo+"','"+price+"','"+NIF+"','')";
157+
String query = "insert into save_project values('"+name+"', '"+tipo+"','"+price+"','"+NIF+"','','"+DATE+"')";
161158

162159
c.s.executeUpdate(query);
163160

0 commit comments

Comments
 (0)