示例#1
0
  public static JasperPrint generateRecapAdressesClients(Date dateDebut, Date dateFin) {

    JasperPrint printImprCheques = new JasperPrint();

    Connection conn = null;
    long start = System.currentTimeMillis();
    try {

      Map<String, Object> paramFacture = new HashMap<String, Object>();
      paramFacture.put("debut", dateDebut);
      paramFacture.put("fin", dateFin);

      org.hibernate.Session session = CEFXUtil.getSessionFactory().getCurrentSession();

      SessionFactoryImplementor sfi = (SessionFactoryImplementor) session.getSessionFactory();
      ConnectionProvider cp = sfi.getConnectionProvider();
      conn = cp.getConnection();

      printImprCheques =
          JasperFillManager.fillReport("src/cefx/report/AdresseAnnee.jasper", paramFacture, conn);

    } catch (Exception e) {
      throw new RuntimeException("Impossible de générer le recap", e);
    } finally {
      //                     it's your responsibility to close the connection, don't forget it!
      if (conn != null) {
        try {
          conn.close();
        } catch (Exception e) {
        }
      }
    }

    return printImprCheques;
  }
示例#2
0
  public static JasperPrint generateFacture(Integer numFacture) {

    Connection conn = null;
    JasperPrint printFacture = new JasperPrint();

    long start = System.currentTimeMillis();

    try {

      Map<String, Object> paramFacture = new HashMap<String, Object>();
      paramFacture.put("num_commande", numFacture);

      org.hibernate.Session session = CEFXUtil.getSessionFactory().getCurrentSession();

      SessionFactoryImplementor sfi = (SessionFactoryImplementor) session.getSessionFactory();
      ConnectionProvider cp = sfi.getConnectionProvider();
      conn = cp.getConnection();

      printFacture =
          JasperFillManager.fillReport("src/cefx/report/FactureCE.jasper", paramFacture, conn);
      //    JasperPrint printBDC =
      // JasperFillManager.fillReport("src/cefx/report/BonDeCommande.jasper", paramFacture, conn);

    } catch (Exception e) {
      throw new RuntimeException("Impossible de générer la Facture", e);
      //  COMMANDE ENREGISTREE MAIS NON IMPRIMEE
    } finally {
      //                     it's your responsibility to close the connection, don't forget it!
      if (conn != null) {
        try {
          conn.close();
        } catch (Exception e) {
        }
      }
    }

    return printFacture;
  }