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 27 28 29 30 31
|
base.open();
ResultSet res2 = base.query("SELECT * FROM mois WHERE libelle_mois= '"+mois+"'");
// parse
for (int j = 0 ; j < table.getRowCount() ; j++)
{
String rq="SELECT * FROM `enfant` WHERE `nom_enfant` = '"+table.getValueAt(j, 0).toString().replace("'", "''")+"' AND `prenom_enfant` = '"+table.getValueAt(j, 1).toString().replace("'", "''")+"' AND garderie_total_enfant!=0";
ResultSet enf = base.query(rq);
res2.first();
if(enf.next())
{
try
{
String insert="INSERT INTO `facture` ( id_enfant, id_mois, annee, montant_facture) VALUES('"+enf.getInt("id_enfant")+"', '"+res2.getInt("id_mois")+"', '"+annee+"', '"+table.getValueAt(j, 6).toString().replace(',', '.')+"')";
base.execute(insert);
}
catch (Exception ex){}
}
}
JOptionPane.showMessageDialog(null, "Insertion prise en compte", "Confirmation", JOptionPane.INFORMATION_MESSAGE);
base.close();
}
catch(SQLException sqle){
System.out.println(sqle.getMessage());
System.out.println(sqle.getLocalizedMessage()); System.out.println(sqle.getLocalizedMessage());
}
catch(DataBaseException dbe)
{
JOptionPane.showMessageDialog(null, "Problème de base de donnée !!!", "Erreur", JOptionPane.ERROR_MESSAGE);
} |
Partager