laporan per periode
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Laporan;
import Class.classkoneksi;
import java.awt.Cursor;
import java.sql.Connection;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JRootPane;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.view.JasperViewer;
/**
*
* @author andicki
*/
public class LaporanPerPeriode extends javax.swing.JDialog {
/**
* Creates new form LaporanPerPeriode
*/
private String status ;
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
public LaporanPerPeriode(java.awt.Frame parent, boolean modal) {
super(parent, modal);
setUndecorated(true);
getRootPane().setWindowDecorationStyle(JRootPane.NONE);
initComponents();
this.setLocationRelativeTo(this);
}
private void cetakPasok(){
String Dari = df.format(txtDari.getDate());
String Sampai = df.format(txtSampai.getDate());
{btnCetak.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
Connection cn = classkoneksi.setKoneksi();
try {
cn.createStatement();
Map<String, Object> prs = new HashMap<String, Object>();
prs.put("dari",Dari);
prs.put("sampai",Sampai);
JasperReport JRpt =
JasperCompileManager.compileReport("src/Laporan/pasokPerPeriode.jrxml");
JasperPrint JPrint = JasperFillManager.fillReport(JRpt, prs, cn);
JasperViewer view = new JasperViewer(JPrint, false);
javax.swing.JDialog dialog = new javax.swing.JDialog(new javax.swing.JFrame(),true);//the owner
dialog.setContentPane(view.getContentPane());
dialog.setSize(1280,720);
dialog.setTitle("List Pasok Periode "+Dari+" - "+Sampai);
dialog.setLocationRelativeTo(this);
dialog.setVisible(true);
} catch (Exception rptexcpt) {
System.out.println("Report Can't view because : " + rptexcpt);
}
btnCetak.setCursor(Cursor.getDefaultCursor());
}
}
private void cetakBuku(){
String Dari = df.format(txtDari.getDate());
String Sampai = df.format(txtSampai.getDate());
{btnCetak.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
Connection cn = classkoneksi.setKoneksi();
try {
cn.createStatement();
Map<String, Object> prs = new HashMap<String, Object>();
prs.put("dari",Dari);
prs.put("sampai",Sampai);
JasperReport JRpt =
JasperCompileManager.compileReport("src/Laporan/penjualanPerPeriode.jrxml");
JasperPrint JPrint = JasperFillManager.fillReport(JRpt, prs, cn);
JasperViewer view = new JasperViewer(JPrint, false);
javax.swing.JDialog dialog = new javax.swing.JDialog(new javax.swing.JFrame(),true);//the owner
dialog.setContentPane(view.getContentPane());
dialog.setSize(1280,720);
dialog.setTitle("List Penjualan Periode "+Dari+" - "+Sampai);
dialog.setVisible(true);
dialog.setLocationRelativeTo(this);
} catch (Exception rptexcpt) {
System.out.println("Report Can't view because : " + rptexcpt);
}
btnCetak.setCursor(Cursor.getDefaultCursor());
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
txtDari = new com.toedter.calendar.JDateChooser();
txtSampai = new com.toedter.calendar.JDateChooser();
btnCetak = new javax.swing.JButton();
btnKeluar = new javax.swing.JButton();
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jLabel1.setText("Dari");
jLabel2.setText("Sampai");
btnCetak.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gambar/1484901579_print.png"))); // NOI18N
btnCetak.setText("CETAK");
btnCetak.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCetakActionPerformed(evt);
}
});
btnKeluar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gambar/1484900317_common-logout-signout-exit-glyph.png"))); // NOI18N
btnKeluar.setText("KELUAR");
btnKeluar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnKeluarActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(32, 32, 32)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(30, 30, 30)
.addComponent(txtDari, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(btnCetak)
.addGap(18, 18, 18)
.addComponent(btnKeluar)
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(txtSampai, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addContainerGap(49, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(35, 35, 35)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(txtDari, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(txtSampai, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnCetak)
.addComponent(btnKeluar))
.addContainerGap(24, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>
private void btnCetakActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(getStatus().equals("Pasok")){
cetakPasok();
}else{
cetakBuku();
}
}
private void btnKeluarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.dispose();
}
/**
* @param args the command line arguments
*/
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 ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(LaporanPerPeriode.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(LaporanPerPeriode.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(LaporanPerPeriode.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(LaporanPerPeriode.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
LaporanPerPeriode dialog = new LaporanPerPeriode(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnCetak;
private javax.swing.JButton btnKeluar;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private com.toedter.calendar.JDateChooser txtDari;
private com.toedter.calendar.JDateChooser txtSampai;
// End of variables declaration
/**
* @return the status
*/
public String getStatus() {
return status;
}
/**
* @param status the status to set
*/
public void setStatus(String status) {
this.status = status;
}
}
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Laporan;
import Class.classkoneksi;
import java.awt.Cursor;
import java.sql.Connection;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JRootPane;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.view.JasperViewer;
/**
*
* @author andicki
*/
public class LaporanPerPeriode extends javax.swing.JDialog {
/**
* Creates new form LaporanPerPeriode
*/
private String status ;
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
public LaporanPerPeriode(java.awt.Frame parent, boolean modal) {
super(parent, modal);
setUndecorated(true);
getRootPane().setWindowDecorationStyle(JRootPane.NONE);
initComponents();
this.setLocationRelativeTo(this);
}
private void cetakPasok(){
String Dari = df.format(txtDari.getDate());
String Sampai = df.format(txtSampai.getDate());
{btnCetak.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
Connection cn = classkoneksi.setKoneksi();
try {
cn.createStatement();
Map<String, Object> prs = new HashMap<String, Object>();
prs.put("dari",Dari);
prs.put("sampai",Sampai);
JasperReport JRpt =
JasperCompileManager.compileReport("src/Laporan/pasokPerPeriode.jrxml");
JasperPrint JPrint = JasperFillManager.fillReport(JRpt, prs, cn);
JasperViewer view = new JasperViewer(JPrint, false);
javax.swing.JDialog dialog = new javax.swing.JDialog(new javax.swing.JFrame(),true);//the owner
dialog.setContentPane(view.getContentPane());
dialog.setSize(1280,720);
dialog.setTitle("List Pasok Periode "+Dari+" - "+Sampai);
dialog.setLocationRelativeTo(this);
dialog.setVisible(true);
} catch (Exception rptexcpt) {
System.out.println("Report Can't view because : " + rptexcpt);
}
btnCetak.setCursor(Cursor.getDefaultCursor());
}
}
private void cetakBuku(){
String Dari = df.format(txtDari.getDate());
String Sampai = df.format(txtSampai.getDate());
{btnCetak.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
Connection cn = classkoneksi.setKoneksi();
try {
cn.createStatement();
Map<String, Object> prs = new HashMap<String, Object>();
prs.put("dari",Dari);
prs.put("sampai",Sampai);
JasperReport JRpt =
JasperCompileManager.compileReport("src/Laporan/penjualanPerPeriode.jrxml");
JasperPrint JPrint = JasperFillManager.fillReport(JRpt, prs, cn);
JasperViewer view = new JasperViewer(JPrint, false);
javax.swing.JDialog dialog = new javax.swing.JDialog(new javax.swing.JFrame(),true);//the owner
dialog.setContentPane(view.getContentPane());
dialog.setSize(1280,720);
dialog.setTitle("List Penjualan Periode "+Dari+" - "+Sampai);
dialog.setVisible(true);
dialog.setLocationRelativeTo(this);
} catch (Exception rptexcpt) {
System.out.println("Report Can't view because : " + rptexcpt);
}
btnCetak.setCursor(Cursor.getDefaultCursor());
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
txtDari = new com.toedter.calendar.JDateChooser();
txtSampai = new com.toedter.calendar.JDateChooser();
btnCetak = new javax.swing.JButton();
btnKeluar = new javax.swing.JButton();
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jLabel1.setText("Dari");
jLabel2.setText("Sampai");
btnCetak.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gambar/1484901579_print.png"))); // NOI18N
btnCetak.setText("CETAK");
btnCetak.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCetakActionPerformed(evt);
}
});
btnKeluar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gambar/1484900317_common-logout-signout-exit-glyph.png"))); // NOI18N
btnKeluar.setText("KELUAR");
btnKeluar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnKeluarActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(32, 32, 32)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(30, 30, 30)
.addComponent(txtDari, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(btnCetak)
.addGap(18, 18, 18)
.addComponent(btnKeluar)
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(txtSampai, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addContainerGap(49, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(35, 35, 35)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(txtDari, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(txtSampai, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnCetak)
.addComponent(btnKeluar))
.addContainerGap(24, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>
private void btnCetakActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(getStatus().equals("Pasok")){
cetakPasok();
}else{
cetakBuku();
}
}
private void btnKeluarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.dispose();
}
/**
* @param args the command line arguments
*/
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 ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(LaporanPerPeriode.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(LaporanPerPeriode.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(LaporanPerPeriode.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(LaporanPerPeriode.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
LaporanPerPeriode dialog = new LaporanPerPeriode(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnCetak;
private javax.swing.JButton btnKeluar;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private com.toedter.calendar.JDateChooser txtDari;
private com.toedter.calendar.JDateChooser txtSampai;
// End of variables declaration
/**
* @return the status
*/
public String getStatus() {
return status;
}
/**
* @param status the status to set
*/
public void setStatus(String status) {
this.status = status;
}
}
Comments
Post a Comment