bonjour tout le monde,
je rencontre ce type d'erreur java.io.FileNotFoundException:E:\Works\Java\gPerfe_Netbeans\Projet2nullFacture.jrxml. j'ai compris qu'il ne trouve pas le fichier Facture.jrxml, j'ai tout tenté en revérifiant bien le chemin. Tout est apparemment correcte mais toujours rien. même le classe JasperMySQL_Parametres.java qui se positionne sur le fichier aussi marche à merveille. je vous envois le code.
la classe JasperMySQL_Parametres.java :
package controle.etat;
import controle.connection.ControleConnexion; import controle.utilitaires.Systeme; import java.io.File; import java.sql.Connection; import java.util.HashMap; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import net.sf.jasperreports.engine.*; import net.sf.jasperreports.engine.design.JasperDesign; import net.sf.jasperreports.engine.export.oasis.JROdsExporter; import net.sf.jasperreports.engine.export.oasis.JROdtExporter; import net.sf.jasperreports.engine.export.ooxml.JRDocxExporter; import net.sf.jasperreports.engine.xml.JRXmlLoader; import net.sf.jasperreports.view.JasperViewer;
public class JasperMySQL_Parametres {
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | private static Connection laConnexion = ControleConnexion.getLaConnectionStatique(); private static JasperDesign design = null; private static JasperReport report = null; private static JasperPrint print = null; private static String code_facture = ""; private static String code_client = ""; private static String recherche_article = ""; public static String getCode_facture() { return code_facture; } public static String getCode_Client() { return code_client; } public static String getRecherche_article() { return recherche_article; } public static void setCode_facture (String code_facture) { JasperMySQL_Parametres .code_facture = code_facture; } public static void setCode_client (String code_client) { JasperMySQL_Parametres .code_client = code_client; } public static void setRecherche_article (String recherche_article) { JasperMySQL_Parametres .recherche_article = recherche_article; } public static void chargeEtcompile(String rapport) { try { design = JRXmlLoader.load(Systeme.getRepertoireCourant() + Systeme.getSeparateur() + "jasper" + Systeme.getSeparateur() + rapport); report = JasperCompileManager.compileReport(design); HashMap<String,Object> mesParametres = new HashMap<String,Object>(); mesParametres.put("code", new String("%")); mesParametres.put("recherche_article", new String('%' + getRecherche_article() + '%')); mesParametres.put("code_facture", new String(getCode_facture())); print = JasperFillManager.fillReport (report, mesParametres, laConnexion); } catch (JRException e) { JOptionPane.showMessageDialog(null, "La compilation du rapport a échoué : \n" + e.getMessage() + "\nVeuillez contacter " + "votre administrateur", "Erreur", JOptionPane.ERROR_MESSAGE); } } public static void apercu(String rapport) { chargeEtcompile(rapport); try { JasperViewer.viewReport(print, false); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Erreur lors de l'aperçu : \n" + e.getMessage() + "\nVeuillez contacter " + "votre administrateur", "Erreur", JOptionPane.ERROR_MESSAGE); } } public static void imprimer(String rapport) { chargeEtcompile(rapport); try { JasperPrintManager.printReport(print, true); } catch (Exception e) { JOptionPane.showMessageDialog(null, "L'impression a échoué : \n" + e.getMessage() + "\nVeuillez contacter " + "votre administrateur", "Erreur", JOptionPane.ERROR_MESSAGE); } } public static void exporterPDF(String rapport) { JFileChooser save = new JFileChooser(); save.setSelectedFile(new File("Fichier.pdf")); int retour = save.showSaveDialog(save); if (retour == JFileChooser.APPROVE_OPTION) { try { chargeEtcompile(rapport); JasperExportManager .exportReportToPdfFile(print, save.getSelectedFile() .getAbsolutePath()); } catch (Exception e) { JOptionPane.showMessageDialog(null, "L'export au format PDF a échoué :" + " \n" + e.getMessage() + "\nVeuillez contacter " + "votre administrateur", "Erreur", JOptionPane.ERROR_MESSAGE); } } } public static void exportHTML(String rapport) { chargeEtcompile(rapport); JFileChooser save = new JFileChooser(); save.setSelectedFile(new File("Fichier.html")); int retour = save.showSaveDialog(save); if (retour == JFileChooser.APPROVE_OPTION) { try { JasperExportManager .exportReportToHtmlFile (print, save.getSelectedFile() .getAbsolutePath()); } catch (Exception e) { JOptionPane.showMessageDialog(null, "L'export au format HTML a échoué :" + " \n" + e.getMessage() + "\nVeuillez contacter " + "votre administrateur", "Erreur", JOptionPane.ERROR_MESSAGE); } } } public static void exportDOCX(String rapport) { chargeEtcompile(rapport); JFileChooser save = new JFileChooser(); save.setSelectedFile(new File("Fichier.docx")); int retour = save.showSaveDialog(save); if (retour == JFileChooser.APPROVE_OPTION) { try { JRDocxExporter exporter = new JRDocxExporter(); exporter.setParameter(JRExporterParameter .JASPER_PRINT, print); exporter.setParameter(JRExporterParameter .OUTPUT_FILE_NAME, save .getSelectedFile().getAbsolutePath()); exporter.exportReport(); } catch (Exception e) { JOptionPane.showMessageDialog(null, "L'export a rencontré une erreur : " + "\n" + e.getMessage() + "\nVeuillez contacter " + "votre administrateur", "Erreur", JOptionPane.ERROR_MESSAGE); } } } public static void exportODS(String rapport) { chargeEtcompile(rapport); JFileChooser save = new JFileChooser(); save.setSelectedFile(new File("Fichier.ods")); int retour = save.showSaveDialog(save); if (retour == JFileChooser.APPROVE_OPTION) { try { JROdsExporter exporter = new JROdsExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, print); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, save.getSelectedFile().getAbsolutePath()); exporter.exportReport(); } catch (Exception e) { JOptionPane.showMessageDialog(null, "L'export a rencontré une erreur : \n" + e.getMessage() + "\nVeuillez contacter votre administrateur", "Erreur", JOptionPane.ERROR_MESSAGE); } } } public static void exportODT(String rapport) { chargeEtcompile(rapport); JFileChooser save = new JFileChooser(); save.setSelectedFile(new File("Fichier.odt")); int retour = save.showSaveDialog(save); if (retour == JFileChooser.APPROVE_OPTION) { try { JROdtExporter exporter = new JROdtExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, print); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, save.getSelectedFile().getAbsolutePath()); exporter.exportReport(); } catch (Exception e) { JOptionPane.showMessageDialog(null, "L'export a rencontré une erreur : \n" + e.getMessage() + "\nVeuillez contacter votre administrateur", "Erreur", JOptionPane.ERROR_MESSAGE); } } } |
}
la classe Facture.jrxml
<?xml version="1.0" encoding="UTF-8"?> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="commande" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="bb752dcf-a7a3-4467-a7e2-16517c553b2e"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <parameter name="code_facture" class="java.lang.String"/> <queryString> <![CDATA[select * from lignes_factures;]]> </queryString> <field name="code_facture" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="code_article" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="quantite" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="prix_unitaire" class="java.lang.Double"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="total" class="java.lang.Double"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <background> <band splitType="Stretch"/> </background> <title> <band height="208" splitType="Stretch"> <rectangle> <reportElement x="153" y="0" width="250" height="92" uuid="a78e615d-9f22-4cf3-bf3c-0532ef48b2fb"/> </rectangle> <staticText> <reportElement x="19" y="23" width="515" height="42" uuid="d38bb54f-a327-4c2c-8a45-adddbf6b6ed7"/> <textElement textAlignment="Center"> <font size="24" isBold="true"/> </textElement> <text><![CDATA[S.A.R.L XELFI]]></text> </staticText> <staticText> <reportElement x="3" y="138" width="132" height="25" uuid="8d4a717a-114b-461b-8487-b1be51b60d14"/> <box> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="12" isBold="true"/> </textElement> <text><![CDATA[Commande n°]]></text> </staticText> <staticText> <reportElement x="135" y="138" width="223" height="25" uuid="40ecc1c1-7564-4289-920e-ac947c9414d1"/> <box> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.0"/> <rightPen lineWidth="0.25"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="12" isBold="true"/> </textElement> <text><![CDATA[Client]]></text> </staticText> <staticText> <reportElement x="358" y="138" width="132" height="25" uuid="fbf6efab-2756-42c1-b872-bb1432351478"/> <box> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.0"/> <rightPen lineWidth="0.25"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="12" isBold="true"/> </textElement> <text><![CDATA[Date]]></text> </staticText> <textField> <reportElement x="3" y="163" width="132" height="30" uuid="299582a9-ea11-4f44-837c-ae468b67a5d3"/> <box> <topPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="12"/> </textElement> <textFieldExpression><![CDATA[
La classe FenFacture.java
package dialogue;
import controle.modele.ModeleLigneFacture; import entite.*; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Random; import javax.swing.JOptionPane;
public class FenFacture extends javax.swing.JFrame { private static String code_article = ""; private static String code_client = ""; private static String code_facture = randomfactureNumber(); private ModeleLigneFacture leModelLigneFacture = new ModeleLigneFacture(code_facture); private ModeReglement mode = new ModeReglement(); private double total_ttc;
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | public FenFacture() { initComponents(); remplirCmBModeReglement(); } private static String randomfactureNumber() { String num = ""; Random rand = new Random(); num += "FAC" + rand.nextInt(999999); return num; } private void remplirCmBModeReglement() { for (ModeReglement unMode : mode.getLesEnreg()) { jCmB_ModeReglement.addItem(unMode.getType()); } } public static void setCode_article(String code_article) { FenFacture.code_article = code_article; } public static void setCode_client(String code_client) { FenFacture.code_client = code_client; } public static void setjTxT_NomClient(String nom) { FenFacture.jTxT_NomClient.setText(nom); } public static void setjTxT_CodeArticle(String code) { FenFacture.jTxT_CodeArticle.setText(code); } public static void setjTxT_CodeCategorie(String categorie) { FenFacture.jTxT_CodeCategorie.setText(categorie); } public static void setjTxT_Designation(String designation) { FenFacture.jTxT_Designation.setText(designation); } public static void setjCmB_Quantite(int max) { JCmB_Quantite.removeAllItems(); for (int i = 1; i <= max; i++) { JCmB_Quantite.addItem(i); } } public static void setjTxT_Montant(String montant) { FenFacture.jTxT_Montant.setText(montant); } private String afficheDateJour() { Date date = new Date(); SimpleDateFormat today = new SimpleDateFormat("dd/MM/yyyy"); String dateJour = today.format(date); return dateJour; } // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); jTable = new javax.swing.JTable(leModelLigneFacture ); jLab_Fichier = new javax.swing.JLabel(); jLab_SupprimerLigne = new javax.swing.JLabel(); jLab_SupprimerTout = new javax.swing.JLabel(); jLab_Retour = new javax.swing.JLabel(); jLab_ModeReglement = new javax.swing.JLabel(); jLab_Fond = new javax.swing.JLabel(); jLab_BandeauFacture = new javax.swing.JLabel(); jLab_NomClient = new javax.swing.JLabel(); jTxT_NomClient = new javax.swing.JTextField(); jLab_NumDocument = new javax.swing.JLabel(); jLab_DateJour = new javax.swing.JLabel(); jLab_BandeauHaut = new javax.swing.JLabel(); jBTN_Articles = new javax.swing.JButton(); jLab_CodeArticle = new javax.swing.JLabel(); jTxT_CodeArticle = new javax.swing.JTextField(); jLab_Quantite = new javax.swing.JLabel(); JCmB_Quantite = new javax.swing.JComboBox(); jCB_NumDocument = new javax.swing.JComboBox(); jLab_Designation = new javax.swing.JLabel(); jLab_Montant = new javax.swing.JLabel(); jLab_CodeCategorie = new javax.swing.JLabel(); jTxT_Designation = new javax.swing.JTextField(); jTxT_Montant = new javax.swing.JTextField(); jTxT_CodeCategorie = new javax.swing.JTextField(); jBTN_Ajouter = new javax.swing.JButton(); jBTN_Modifier = new javax.swing.JButton(); jLab_TotalTTC = new javax.swing.JLabel(); jLab_EtiTotalTTC = new javax.swing.JLabel(); jBTN_Valider = new javax.swing.JButton(); jCmB_ModeReglement = new javax.swing.JComboBox(); jTxT_DateJour = new javax.swing.JTextField(); setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); jScrollPane1.setPreferredSize(new java.awt.Dimension(452, 412)); jScrollPane1.setViewportView(jTable); getContentPane().add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 275, 742, 210)); jLab_Fichier.setForeground(new java.awt.Color(255, 255, 255)); jLab_Fichier.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/gestion/ods.png"))); // NOI18N jLab_Fichier.setText("Fichier des factures"); jLab_Fichier.setToolTipText(""); jLab_Fichier.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLab_FichierMouseClicked(evt); } }); getContentPane().add(jLab_Fichier, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 10, -1, -1)); jLab_SupprimerLigne.setForeground(new java.awt.Color(255, 255, 255)); jLab_SupprimerLigne.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/gestion/supprimer2.png"))); // NOI18N jLab_SupprimerLigne.setText("Supprimer une ligne"); jLab_SupprimerLigne.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLab_SupprimerLigneMouseClicked(evt); } }); getContentPane().add(jLab_SupprimerLigne, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 100, -1, -1)); jLab_SupprimerTout.setForeground(new java.awt.Color(255, 255, 255)); jLab_SupprimerTout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/gestion/supprimer.png"))); // NOI18N jLab_SupprimerTout.setText("Supprimer toutes les lignes"); jLab_SupprimerTout.setToolTipText(""); jLab_SupprimerTout.setName(""); // NOI18N jLab_SupprimerTout.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLab_SupprimerToutMouseClicked(evt); } }); getContentPane().add(jLab_SupprimerTout, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 160, -1, -1)); jLab_Retour.setForeground(new java.awt.Color(255, 255, 255)); jLab_Retour.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/gestion/retour.png"))); // NOI18N jLab_Retour.setText("Menu principal"); jLab_Retour.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLab_RetourMouseClicked(evt); } }); getContentPane().add(jLab_Retour, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 480, -1, -1)); jLab_ModeReglement.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/gestion/carte.png"))); // NOI18N jLab_ModeReglement.setText("Mode de règlement"); getContentPane().add(jLab_ModeReglement, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 500, 140, -1)); jLab_Fond.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/fond/fondGeneral.jpg"))); // NOI18N getContentPane().add(jLab_Fond, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, -100, 240, 710)); jLab_BandeauFacture.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/gestion/barre.png"))); // NOI18N getContentPane().add(jLab_BandeauFacture, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 120, 730, 40)); jLab_NomClient.setText("Nom du client"); getContentPane().add(jLab_NomClient, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 60, -1, -1)); jTxT_NomClient.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N jTxT_NomClient.setText("[ Cliquez ici pour sélectionner un client ]"); jTxT_NomClient.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jTxT_NomClientMouseClicked(evt); } }); getContentPane().add(jTxT_NomClient, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 80, 270, -1)); jLab_NumDocument.setText("Numéro du document"); jLab_NumDocument.setToolTipText(""); getContentPane().add(jLab_NumDocument, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 60, -1, -1)); jLab_DateJour.setText("Date du jour"); getContentPane().add(jLab_DateJour, new org.netbeans.lib.awtextra.AbsoluteConstraints(790, 60, -1, -1)); jLab_BandeauHaut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/gestion/barre.png"))); // NOI18N getContentPane().add(jLab_BandeauHaut, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 10, 730, 40)); jBTN_Articles.setText("Parcourir les articles"); jBTN_Articles.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBTN_ArticlesActionPerformed(evt); } }); getContentPane().add(jBTN_Articles, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 170, -1, -1)); jLab_CodeArticle.setText("Code"); jLab_CodeArticle.setToolTipText(""); getContentPane().add(jLab_CodeArticle, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 200, -1, -1)); getContentPane().add(jTxT_CodeArticle, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 200, 80, -1)); jLab_Quantite.setText("Quantité"); getContentPane().add(jLab_Quantite, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 230, -1, -1)); JCmB_Quantite.setOpaque(false); getContentPane().add(JCmB_Quantite, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 230, -1, -1)); jCB_NumDocument.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCB_NumDocumentActionPerformed(evt); } }); getContentPane().add(jCB_NumDocument, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 80, -1, -1)); jLab_Designation.setText("Désignation"); jLab_Designation.setToolTipText(""); getContentPane().add(jLab_Designation, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 200, -1, -1)); jLab_Montant.setText("Montant"); getContentPane().add(jLab_Montant, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 230, -1, -1)); jLab_CodeCategorie.setText("Code catégorie"); getContentPane().add(jLab_CodeCategorie, new org.netbeans.lib.awtextra.AbsoluteConstraints(810, 200, -1, -1)); getContentPane().add(jTxT_Designation, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 200, 290, -1)); getContentPane().add(jTxT_Montant, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 230, 90, -1)); getContentPane().add(jTxT_CodeCategorie, new org.netbeans.lib.awtextra.AbsoluteConstraints(900, 200, 70, -1)); jBTN_Ajouter.setText("Ajouter"); jBTN_Ajouter.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBTN_AjouterActionPerformed(evt); } }); getContentPane().add(jBTN_Ajouter, new org.netbeans.lib.awtextra.AbsoluteConstraints(810, 240, -1, -1)); jBTN_Modifier.setText("Modifier"); getContentPane().add(jBTN_Modifier, new org.netbeans.lib.awtextra.AbsoluteConstraints(890, 240, -1, -1)); jLab_TotalTTC.setText("Total : "); getContentPane().add(jLab_TotalTTC, new org.netbeans.lib.awtextra.AbsoluteConstraints(650, 510, 120, -1)); jLab_EtiTotalTTC.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/gestion/etiquette.png"))); // NOI18N jLab_EtiTotalTTC.setToolTipText(""); getContentPane().add(jLab_EtiTotalTTC, new org.netbeans.lib.awtextra.AbsoluteConstraints(620, 500, -1, -1)); jBTN_Valider.setText("Valider la facture"); jBTN_Valider.setToolTipText(""); jBTN_Valider.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBTN_ValiderActionPerformed(evt); } }); getContentPane().add(jBTN_Valider, new org.netbeans.lib.awtextra.AbsoluteConstraints(823, 500, 160, -1)); getContentPane().add(jCmB_ModeReglement, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 500, 80, -1)); jTxT_DateJour.setEditable(false); jTxT_DateJour.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N jTxT_DateJour.setHorizontalAlignment(javax.swing.JTextField.LEFT); jTxT_DateJour.setText(afficheDateJour()); jTxT_DateJour.setFocusable(false); getContentPane().add(jTxT_DateJour, new org.netbeans.lib.awtextra.AbsoluteConstraints(790, 80, 90, -1)); setSize(new java.awt.Dimension(1017, 591)); setLocationRelativeTo(null); }// </editor-fold> private void jLab_RetourMouseClicked(java.awt.event.MouseEvent evt) { if (JOptionPane.showConfirmDialog(null, "Abandon de la saisie ? ", "Confirmation", JOptionPane.YES_NO_OPTION) == 0) { LignesFacture lesLignes = new LignesFacture(); lesLignes.supprimerToutCRUD(code_facture, "code_facture"); leModelLigneFacture.supprimerTous(); jTxT_NomClient.setText ("[ Cliquez ici pour sélectionner un client ]"); jLab_TotalTTC.setText(""); code_facture= randomfactureNumber(); dispose(); } } private void jTxT_NomClientMouseClicked(java.awt.event.MouseEvent evt) { FenChoixClient choix = new FenChoixClient(this, rootPaneCheckingEnabled); choix.setModal(true); choix.setLocationRelativeTo(choix.getParent()); choix.setVisible(true); } private void jBTN_ArticlesActionPerformed(java.awt.event.ActionEvent evt) { FenChoixArticle choix = new FenChoixArticle(this, rootPaneCheckingEnabled); choix.setModal(true); choix.setLocationRelativeTo(choix.getParent()); choix.setVisible(true); } private void jBTN_AjouterActionPerformed(java.awt.event.ActionEvent evt) { if (jTxT_CodeArticle.getText().isEmpty() || (code_client.equals(""))) { JOptionPane.showMessageDialog(null, "Vérifiez vos choix !"); } else { int quantite = Integer.parseInt(JCmB_Quantite.getSelectedItem().toString()); if (quantite > 0) { double pu = Double.valueOf(jTxT_Montant.getText()); LignesFacture uneLigne = new LignesFacture( code_facture, new Article(jTxT_CodeArticle.getText(), jTxT_CodeCategorie.getText(), jTxT_Designation.getText(), quantite, pu, new Date()), quantite, pu, quantite * pu); boolean is_created = uneLigne.creerCRUD(code_facture, jTxT_CodeArticle.getText(), quantite, pu, quantite * pu); if (is_created) { leModelLigneFacture.creerMOD(uneLigne); } jLab_TotalTTC.setText(calculeTotal()); jTxT_CodeArticle.setText(""); jTxT_Designation.setText(""); jTxT_Montant.setText(""); JCmB_Quantite.removeAllItems(); } } } private void jBTN_ValiderActionPerformed(java.awt.event.ActionEvent evt) { if (jTable.getRowCount() == 0) { JOptionPane.showMessageDialog(null, "Une facture doit avoir au moins " + "un article pour être validée.", "Information", JOptionPane.INFORMATION_MESSAGE); } else { if (code_client.equals("")) { JOptionPane.showMessageDialog(null, "Vous devez sélectionner" + " un client pour continuer.", "Erreur", JOptionPane.WARNING_MESSAGE); } else { int code_mode_reglement = mode.getLesEnreg().get(jCmB_ModeReglement.getSelectedIndex()).getCode(); String nom_reglement = mode.getLesEnreg().get(jCmB_ModeReglement.getSelectedIndex()).getType(); Facture facture = new Facture(code_facture, new Client(code_client), total_ttc, new ModeReglement(code_mode_reglement, nom_reglement), new Date()); facture.creerCRUD(code_facture, code_client, total_ttc, code_mode_reglement); jTxT_NomClient.setText("[ Cliquez ici pour sélectionner un client ]"); leModelLigneFacture.supprimerTous(); code_facture = randomfactureNumber(); jLab_TotalTTC.setText(""); } } } private void jLab_SupprimerLigneMouseClicked(java.awt.event.MouseEvent evt) { if (jTable.getSelectedRow() == -1) { JOptionPane.showMessageDialog(null, "Vous devez sélectionner " + "une ligne pour la supprimer.", "Suppression", JOptionPane.INFORMATION_MESSAGE); } else { if (JOptionPane.showConfirmDialog(null, "Souhaitez-vous vraiment supprimer" + " cette ligne de la facture ?", "Confirmation", JOptionPane.YES_NO_OPTION) == 0) { int numLigne = jTable.getSelectedRow(); String codeArticle = jTable.getValueAt(numLigne, 0).toString(); LignesFacture uneLigne = new LignesFacture(); uneLigne.supprimerLigneCRUD(code_facture, codeArticle); leModelLigneFacture.supprimerMOD(numLigne); } } } private void jLab_SupprimerToutMouseClicked(java.awt.event.MouseEvent evt) { if (JOptionPane.showConfirmDialog(null, "Souhaitez-vous " + "vraiment supprimer " + "tous les articles présents" + " dans cette facture ?", "Confirmation", JOptionPane.YES_NO_OPTION) == 0) { LignesFacture lesLignes = new LignesFacture(); lesLignes.supprimerToutCRUD(code_facture, "code_facture"); leModelLigneFacture.supprimerTous(); code_facture = randomfactureNumber(); } } private void jLab_FichierMouseClicked(java.awt.event.MouseEvent evt) { FenTableFacture laFenetre = new FenTableFacture(); laFenetre.setVisible(true); } private void jCB_NumDocumentActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private String calculeTotal() { String total = ""; try { DecimalFormat format = new DecimalFormat("#,##0.00"); total_ttc = 0.0; for (int i = 0; i < jTable.getRowCount(); i++) { total_ttc += Double.valueOf(jTable.getValueAt(i, 5).toString()); } total = "Total : " + format.format(total_ttc) + " CFA"; } catch (NumberFormatException e) { JOptionPane.showMessageDialog(null, "Erreur de format de nombre"); } return total; } public static void main(String args[]) { /* * Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* * If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Minus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(FenFacture.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* * Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new FenFacture().setVisible(true); } }); } // Variables declaration - do not modify private static javax.swing.JComboBox JCmB_Quantite; private javax.swing.JButton jBTN_Ajouter; private javax.swing.JButton jBTN_Articles; private javax.swing.JButton jBTN_Modifier; private javax.swing.JButton jBTN_Valider; private javax.swing.JComboBox jCB_NumDocument; private javax.swing.JComboBox jCmB_ModeReglement; private javax.swing.JLabel jLab_BandeauFacture; private javax.swing.JLabel jLab_BandeauHaut; private javax.swing.JLabel jLab_CodeArticle; private javax.swing.JLabel jLab_CodeCategorie; private javax.swing.JLabel jLab_DateJour; private javax.swing.JLabel jLab_Designation; private javax.swing.JLabel jLab_EtiTotalTTC; private javax.swing.JLabel jLab_Fichier; private javax.swing.JLabel jLab_Fond; private javax.swing.JLabel jLab_ModeReglement; private javax.swing.JLabel jLab_Montant; private javax.swing.JLabel jLab_NomClient; private javax.swing.JLabel jLab_NumDocument; private javax.swing.JLabel jLab_Quantite; private javax.swing.JLabel jLab_Retour; private javax.swing.JLabel jLab_SupprimerLigne; private javax.swing.JLabel jLab_SupprimerTout; private javax.swing.JLabel jLab_TotalTTC; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTable jTable; private static javax.swing.JTextField jTxT_CodeArticle; private static javax.swing.JTextField jTxT_CodeCategorie; private javax.swing.JTextField jTxT_DateJour; private static javax.swing.JTextField jTxT_Designation; private static javax.swing.JTextField jTxT_Montant; private static javax.swing.JTextField jTxT_NomClient; // End of variables declaration |
}
La classe Systeme dont se sert JasperMySQL_Parametres.java :
package controle.utilitaires;
public class Systeme { static private String nomOS = System.getProperty("os.name"); static private String versionOS = System.getProperty("os.version"); static private String separateur = System.getProperty("file.seperator"); static private String nomUtilisateur = System.getProperty("user.name"); static private String repertoireCourant = System.getProperty("user.dir");
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | public static String getSeparateur(){ return separateur; } public static String getRepertoireCourant(){ return repertoireCourant; } public static String getNomOS(){ return nomOS; } public static String getVersionOS(){ return versionOS; } public static String getNomUtilisateur(){ return nomUtilisateur; } |
}
PS: Tout les fichiers jar et autres ont été importés.
Merci d'avance