When I run my application in java, everything works perfect for me without anything altering it, but that little detail comes out. What is the reason? Because it is derived from a table field in the database.
The table is called Invoice.
Save button (JAVA code):
Connection con=null;
try{
con=getConnection();
ps=con.prepareStatement("INSERT INTO factura (idFactura, Precioneto, precioIVA, costoIVA, fechaCompra, HoraCompra, Distribuidor, MetodoPago) VALUES (?,?,?,?,?,?,?,?)");
ps.setString(1, txtid.getText());
if(txtid.getText().equals("")){
JOptionPane.showMessageDialog(null, "Rellenar campo ID");
}
ps.setString(2, txtPrecioNeto.getText());
if(txtPrecioNeto.getText().equals("")){
JOptionPane.showMessageDialog(null, "Rellenar campo Precio Neto");
}
ps.setString(3, txtPrecioIVA.getText());
if(txtPrecioIVA.getText().equals("")){
JOptionPane.showMessageDialog(null, "Rellenar campo Precio IVA");
}
ps.setString(4, txtCostoIVA.getText());
if(txtCostoIVA.getText().equals("")){
JOptionPane.showMessageDialog(null, "Rellenar campo Costo IVA");
}
ps.setString(5, txtFechaCompra.getText());
if(txtFechaCompra.getText().equals("")){
JOptionPane.showMessageDialog(null, "Rellenar campo Fecha de Compra");
}
ps.setString(6, txtHoraCompra.getText());
if(txtHoraCompra.getText().equals("")){
JOptionPane.showMessageDialog(null, "Rellenar campo Hora de Compra");
}
ps.setString(7, txtDistribuidor.getText());
if(txtDistribuidor.getText().equals("")){
JOptionPane.showMessageDialog(null, "Rellenar campo Distribuidor");
}
ps.setString(8, txtPago.getText());
if(txtPago.getText().equals("")){
JOptionPane.showMessageDialog(null, "Rellenar campo Pago");
}
int res=ps.executeUpdate();
if(res>0){
JOptionPane.showMessageDialog(null, "Se ejecuto correctamente");
limpiarCajas();
}else{
JOptionPane.showMessageDialog(null, "Error al ejecutar la conexion");
limpiarCajas();
}
}catch(Exception e){
System.err.println(e);
}