1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
private formattedfields.FormattedCurrencyField txtPrice;
txtPrice = new formattedfields.FormattedCurrencyField();
txtPrice.setMaxValue(1000000.0);
txtPrice.setMinValue(0.0);
txtPrice.setBounds(32, 106, 119, 20);
contentPane.add(txtPrice);
public int insertInfo() throws Exception{
double montant = Double.parseDouble(txtPrice.getText());
String query = "INSERT INTO info (Price)"
+ "VALUES (?)";
try(PreparedStatement stat = cnx.prepareStatement(query)){
stat.setDouble(1, montant);
stat.executeUpdate();
stat.close();
}catch(Exception ex){
JOptionPane.showMessageDialog(null, ex);
}
return rslt.getInt(1);
} |
Partager