Aniadir controlador
This commit is contained in:
		
							parent
							
								
									5ba64e2335
								
							
						
					
					
						commit
						bb7282ce44
					
				| @ -29,13 +29,13 @@ public class Modelo { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public void insertarTransaccion(String nombre, float dinero, LocalDate fecha) { | 	public void insertarTransaccion(String nombre, float dinero, String fecha) { | ||||||
| 		 String query = "insert into transacciones(nombre, dinero, fecha) values(?, ?, ?);"; | 		 String query = "insert into transacciones(nombre, dinero, fecha) values(?, ?, ?);"; | ||||||
| 		 try { | 		 try { | ||||||
| 			PreparedStatement stmt = this.connection.prepareStatement(query); | 			PreparedStatement stmt = this.connection.prepareStatement(query); | ||||||
| 			stmt.setString(1, nombre); | 			stmt.setString(1, nombre); | ||||||
| 			stmt.setFloat(2, dinero); | 			stmt.setFloat(2, dinero); | ||||||
| 			stmt.setString(3, fecha.toString()); | 			stmt.setString(3, fecha); | ||||||
| 			stmt.execute(); | 			stmt.execute(); | ||||||
| 		} catch (SQLException e) { | 		} catch (SQLException e) { | ||||||
| 			// TODO Auto-generated catch block | 			// TODO Auto-generated catch block | ||||||
| @ -70,7 +70,7 @@ public class Modelo { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public void modificarTransaccion(String nombreViejo, String nombre, float dinero, LocalDate fecha) { | 	public void modificarTransaccion(String nombreViejo, String nombre, float dinero, String fecha) { | ||||||
| 		String query ="update transacciones" +  | 		String query ="update transacciones" +  | ||||||
| 				"set nombre=?, dinero=?, fecha=?"+ | 				"set nombre=?, dinero=?, fecha=?"+ | ||||||
| 				"where nombre=?;"; | 				"where nombre=?;"; | ||||||
| @ -78,7 +78,7 @@ public class Modelo { | |||||||
| 			PreparedStatement stmt = this.connection.prepareStatement(query); | 			PreparedStatement stmt = this.connection.prepareStatement(query); | ||||||
| 			stmt.setString(1, nombre); | 			stmt.setString(1, nombre); | ||||||
| 			stmt.setFloat(2, dinero); | 			stmt.setFloat(2, dinero); | ||||||
| 			stmt.setString(3, fecha.toString()); | 			stmt.setString(3, fecha); | ||||||
| 			stmt.setString(4, nombreViejo); | 			stmt.setString(4, nombreViejo); | ||||||
| 		} catch (SQLException e) { | 		} catch (SQLException e) { | ||||||
| 			// TODO Auto-generated catch block | 			// TODO Auto-generated catch block | ||||||
|  | |||||||
| @ -15,6 +15,8 @@ public class Vista extends JPanel{ | |||||||
| 	JButton mostrarTodo; | 	JButton mostrarTodo; | ||||||
| 	JButton aniadir; | 	JButton aniadir; | ||||||
| 	JButton editar; | 	JButton editar; | ||||||
|  | 	JTextField textoNombreViejo; | ||||||
|  | 	JTextField insertarNombreViejo; | ||||||
| 	 | 	 | ||||||
| 	public Vista() { | 	public Vista() { | ||||||
| 		this.setLayout(new GridBagLayout()); | 		this.setLayout(new GridBagLayout()); | ||||||
| @ -60,5 +62,16 @@ public class Vista extends JPanel{ | |||||||
| 		constrain.gridx = 2; | 		constrain.gridx = 2; | ||||||
| 		constrain.gridy = 2; | 		constrain.gridy = 2; | ||||||
| 		this.add(this.mostrarTodo, constrain); | 		this.add(this.mostrarTodo, constrain); | ||||||
|  | 		 | ||||||
|  | 		this.textoNombreViejo = new JTextField("nombre a cabiar"); | ||||||
|  | 		this.textoNombre.setEditable(false); | ||||||
|  | 		constrain.gridx = 3; | ||||||
|  | 		constrain.gridy = 0; | ||||||
|  | 		this.add(this.textoNombreViejo, constrain); | ||||||
|  | 
 | ||||||
|  | 		this.insertarNombreViejo = new JTextField("nombre a cambiar"); | ||||||
|  | 		constrain.gridx = 3; | ||||||
|  | 		constrain.gridy = 1; | ||||||
|  | 		this.add(this.insertarNombreViejo, constrain); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user