5
5
import java .awt .event .*;
6
6
import javax .swing .*;
7
7
import java .sql .*;
8
+ import java .text .SimpleDateFormat ;
9
+ import java .util .Date ;
8
10
9
11
10
12
public class SaveProject extends JFrame implements ActionListener {
11
13
RoundedButton volver , crear ;
12
14
JTextField cajon_nombre , cajon_precio ;
13
15
JComboBox cajon_tipo ;
14
- String NIF ,ID_USER ;
16
+ String NIF ,ID_USER ,DATE ;
17
+ SimpleDateFormat dateFormat ;
18
+ JFormattedTextField dateField ;
15
19
SaveProject (String NIF ,String ID_USER ) {
16
20
this .NIF = NIF ;
17
21
this .ID_USER = ID_USER ;
@@ -94,15 +98,11 @@ public class SaveProject extends JFrame implements ActionListener {
94
98
panel .add (panelBotones , gbc );
95
99
96
100
crear = new RoundedButton (" Continuar " );
97
- crear .setBackground (new Color (222 , 239 , 255 ));
98
- crear .setForeground (Color .BLACK );
99
101
crear .setFont (new Font ("Roboto" , Font .PLAIN , 16 ));
100
102
crear .addActionListener (this );
101
103
panelBotones .add (crear , BorderLayout .WEST );
102
104
103
105
volver = new RoundedButton (" Volver " );
104
- volver .setBackground (new Color (222 , 239 , 255 ));
105
- volver .setForeground (Color .BLACK );
106
106
volver .setFont (new Font ("Roboto" , Font .PLAIN , 16 ));
107
107
volver .addActionListener (this );
108
108
panelBotones .add (volver , BorderLayout .EAST );
@@ -116,24 +116,21 @@ public class SaveProject extends JFrame implements ActionListener {
116
116
117
117
118
118
public void actionPerformed (ActionEvent ae ) {
119
+ dateFormat = new SimpleDateFormat ("dd-MM-yyyy" );
120
+ DATE = dateFormat .format (new Date ());
119
121
if (ae .getSource () == crear ) {
120
122
String name = cajon_nombre .getText ().toLowerCase ().trim ();
121
123
int name_length = name .length ();
122
124
String tipo =(String ) cajon_tipo .getSelectedItem ();
123
125
tipo = tipo .toLowerCase ().trim ();
124
126
int iva_length = tipo .length ();
125
127
String price = cajon_precio .getText ().toLowerCase ().trim ();
126
- int price_length = price .length ();
127
128
128
129
boolean action =true ;
129
130
if (name_length > 20 ) {
130
131
JOptionPane .showMessageDialog (null , "Nombre demasiado largo" );
131
132
action =false ;
132
133
}
133
- if (price_length > 5 ) {
134
- JOptionPane .showMessageDialog (null , "Unidad de precio demasiado grande" );
135
- action =false ;
136
- }
137
134
138
135
int nombre_existente = 0 ;
139
136
try {
@@ -157,7 +154,7 @@ public void actionPerformed(ActionEvent ae) {
157
154
if (action && nombre_existente == 0 ) {
158
155
try {
159
156
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 + "' )" ;
161
158
162
159
c .s .executeUpdate (query );
163
160
0 commit comments