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 32 33 34 35 36 37 38 39
|
Statement stmt =con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
//garde en mémoire les lignes Résultant de l'éxecution de la requete
ResultSet rs = stmt.executeQuery("select * from baseefs.totalht");
//boucle sur les champs
while (rs.next()) {
System.out.println("1");
Double montantHTDEB = rs.getDouble(1);
Double montantHTCRED = rs.getDouble(2);
Double diffe = montantHTDEB - montantHTCRED;
// test de l'égalité pour ensuite envoyer dans la table TCAchats.
if (montantHTDEB.equals(montantHTCRED)) {
System.out.println(" c'est bon !");
//affiche("creation et execution de la requête");
requete = "INSERT INTO TCAchats (Nchrono, idMenuConf, Compte, DateEmission, Libelle, Piece, Section, TTVA, MontantHTDeb, MontantTVADeb, MontantTTCDeb, MontantHTCred, MontantTVACred, MontantTTCCred, MPayement)"
+ "SELECT (Nchrono, idMenuConf, Compte, DateEmission, Libelle, Piece, Section, TTVA, MontantHTDeb, MontantTVADeb, MontantTTCDeb, MontantHTCred, MontantTVACred, MontantTTCCred, MPayement) FROM TMPAchats"
+ "VALUES ('" + jTnChrono.getText() + "','" + idmenuconf + "','" + jCombCompt.getSelectedItem() + "','" + sqlDate + "','" + jTlibaera.getText() + "','" + jTPiece.getText() + "','" + jTSect.getText() + "','" + toTva.toString() + "','" + jTMhtDeb.getText() + "','" + jTMTVADeb.getText() + "','" + jTMttcDeb.getText() + "','" + jTMhtCred.getText() + "','" + jTMTVACred.getText() + "','" + jTMttcCred.getText() + "','" + jCoMpaye.getSelectedItem() +"')";
System.out.println("2");
//requete = "INSERT IGNORE INTO baseefs.TMPAchats SELECT (Nchrono, idMenuConf, Compte, DateEmission, Libelle, Piece, Section, TTVA, MontantHTDeb, MontantTVADeb, MontantTTCDeb, MontantHTCred, MontantTVACred, MontantTTCCred, MPayement) FROM baseefs.TCAchats ";
try {
System.out.println("3");
//int maj = stmt.executeUpdate(requete);
ResultSet maj = stmt.executeQuery(requete);
System.out.println("4");
} catch (SQLException e) {
System.out.println("Erreur : Anomalie lors de l'execution de la requête : " + e);
}
} else {
System.out.println(" Les montant ne sont pas égaux, veuillez corriger l'erreur avanr de valider !");
System.out.println(" Les montants en Débit : " + montantHTDEB + " " + ", en crédit :" + montantHTCRED + " " + ", il y a une différence de : " + diffe + "");
}
}
} catch (SQLException ex) {
Logger.getLogger(Comptabilite.class.getName()).log(Level.SEVERE, null, ex);
} |
Partager