penjualan
/*
* 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 nmTransaksi;
import Class.classkoneksi;
import com.mysql.jdbc.Connection;
import java.awt.Cursor;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JRootPane;
import javax.swing.table.DefaultTableModel;
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;
import net.sf.jasperreports.engine.util.JRLoader;
import sesion.sessionLogin;
/**
*
* @author RPL
*/
public class Penjualan extends javax.swing.JFrame {
private String idPenjualan;
private String diskon;
private boolean update = false;
/**
* Creates new form Penjualan
*/
public Penjualan() {
setUndecorated(true);
getRootPane().setWindowDecorationStyle(JRootPane.NONE);
initComponents();
this.setLocationRelativeTo(this);
}
private void getBuku() {
try{
String SQL = "Select id_buku from tbl_buku order by id_bUku asc";
ResultSet rs = classkoneksi.executeQuery(SQL);
cboBuku.removeAllItems();
cboBuku.addItem("-");
while(rs.next()){
cboBuku.addItem(rs.getString(1));
}
}catch (Exception e) {
}
}
private void getDetBuku(){
try{
String idBuku = cboBuku.getSelectedItem().toString();
String SQL = "select noisbn,judul,penulis,penerbit,tahun,stok,harga_jual "
+"from tbl_buku where id_buku ='"+idBuku+"'";
ResultSet rs = classkoneksi.executeQuery(SQL);
if(rs.next()){
txtIsbn.setText(rs.getString(1));
txtJudul.setText(rs.getString(2));
txtPenulis.setText(rs.getString(3));
txtPenerbit.setText(rs.getString(4));
txtTahun.setText(rs.getString(5));
txtStok.setText(rs.getString(6));
txtHarga.setText(rs.getString(7));
}
}catch (Exception e){
}
}
private void getTotal(){
String jumlah = txtJumlah.getText();
int j = Integer.valueOf(jumlah);
String harga = txtHarga.getText();
int h = Integer.valueOf(harga);
int Hasil = j*h;
txtTotal.setText(String.valueOf(Hasil));
}
private void genIdTransaksi(){
try{
String SQL = "select substring(id_penjualan,5,10) as id from tbl_penjualan order by id_penjualan desc limit 0,1";
ResultSet rs = classkoneksi.executeQuery(SQL);
SimpleDateFormat df = new SimpleDateFormat("yyMM");
Date date = new Date();
String hasil = df.format(date);
if(rs.next()){
String str = "000000";
int id = Integer.valueOf(rs.getString(1))+1;
String str_no = String.valueOf(id);
String idTransaksi = hasil+str.substring(0,6-str_no.length())+Integer.toString(id);
txtIdTransaksi.setText(idTransaksi);
}else{
txtIdTransaksi.setText(hasil+"000001");
}
}catch(Exception e){
JOptionPane.showMessageDialog(rootPane, "ada kesalahan dalam database");
}
}
private void tglTransaksi(){
SimpleDateFormat df = new SimpleDateFormat("EEE, dd MMMM YYYY");
Date date = new Date();
String hasil = df.format(date);
txtTanggal.setText(hasil);
}
private int cekData(){
int i = 0;
if(cboBuku.getSelectedItem().equals("-")){
JOptionPane.showMessageDialog(rootPane, "Silahkan pilih buku.","Peringatan", JOptionPane.WARNING_MESSAGE);
}else if(txtJumlah.getText().isEmpty()){
JOptionPane.showMessageDialog(rootPane, "Jumlah tidak boleh kosong.","Peringatan", JOptionPane.WARNING_MESSAGE);
}else{
i=1;
}
return i;
}
private void simpan(){
int i = cekData();
if(i>0){
String idTransaksi = txtIdTransaksi.getText();
String idBuku = cboBuku.getSelectedItem().toString();
String idKasir = "KSR001";
String jumlah = txtJumlah.getText();
String total = txtTotal.getText();
SimpleDateFormat df = new SimpleDateFormat("YYYY-MM-dd");
Date date = new Date();
String tanggal = df.format(date);
String SQL = "insert into tbl_penjualan value('"+idTransaksi+"','"+idBuku+"','"+idKasir+"','"+jumlah+"','"+total+"','"+tanggal+"')";
int a = classkoneksi.execute(SQL);
if(i>0){
JOptionPane.showMessageDialog(rootPane, "Data berhasil di simpan.","Succses", JOptionPane.INFORMATION_MESSAGE);
}else{
JOptionPane.showMessageDialog(rootPane, "data gagal di simpan","Gagal", JOptionPane.WARNING_MESSAGE);
}
}
}
private void updateData(){
String idTransaksi = txtIdTransaksi.getText();
String idBuku = cboBuku.getSelectedItem().toString();
String idKasir = "17010001";
String jumlah = txtJumlah.getText();
String total = txtTotal.getText();
String SQL = "update tbl_penjualan set id_buku='"+idBuku+"',jumlah='"+jumlah+"',total='"+total+"' where "
+ "id_penjualan = '"+idTransaksi+"'";
int i = classkoneksi.execute(SQL);
if(i>0){
JOptionPane.showMessageDialog(rootPane, "Data berhasil diubah.","Success",JOptionPane.INFORMATION_MESSAGE);
}else{
JOptionPane.showMessageDialog(rootPane, "Data gagal diubah.","Gagal",JOptionPane.WARNING_MESSAGE);
}
}
private void pushData(){
String SQL = "Select * from tbl_penjualan where id_penjualan = '"+this.getIdPenjualan()+"'";
try{
ResultSet rs = classkoneksi.executeQuery(SQL);
if(rs.next()){
txtIdTransaksi.setText(rs.getString(1));
cboBuku.setSelectedItem(rs.getString(2));
txtJumlah.setText(rs.getString(4));
txtTotal.setText(rs.getString(5));
txtTanggal.setText(rs.getString(6));
}
}catch(Exception e){
JOptionPane.showMessageDialog(rootPane, "kesalahan dalam database");
}
}
private void cetak(){
{btnCetak.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
Connection cn = classkoneksi.setKoneksi();
try {
Statement st = cn.createStatement();
Map<String, Object> prs = new HashMap<String, Object>();
prs.put("idPenjualan", txtIdTransaksi.getText());
JasperReport JRpt =
JasperCompileManager.compileReport("src/Laporan/fakturPenjualan.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(700,882);
dialog.setTitle("Laporan Transaksi");
dialog.setVisible(true);
dialog.setLocationRelativeTo(this);
} catch (Exception rptexcpt) {
System.out.println("Report Can't view because : " + rptexcpt);
}
btnCetak.setCursor(Cursor.getDefaultCursor());
}
}
public void bersih(){
txtJudul.setText("");
txtIsbn.setText("");
txtPenulis.setText("");
txtPenerbit.setText("");
txtTahun.setText("");
txtStok.setText("");
txtHarga.setText("");
txtJumlah.setText("");
txtTotal.setText("");
}
/**
* 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();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
txtIdTransaksi = new javax.swing.JTextField();
cboBuku = new javax.swing.JComboBox();
txtJumlah = new javax.swing.JTextField();
txtTotal = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
btnSimpan = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jLabel7 = new javax.swing.JLabel();
txtIsbn = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
txtJudul = new javax.swing.JTextField();
jLabel9 = new javax.swing.JLabel();
txtPenulis = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
txtPenerbit = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
txtTahun = new javax.swing.JTextField();
jLabel12 = new javax.swing.JLabel();
txtStok = new javax.swing.JTextField();
jLabel13 = new javax.swing.JLabel();
txtHarga = new javax.swing.JTextField();
txtTanggal = new javax.swing.JTextField();
btnCetak = new javax.swing.JButton();
txtNama = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Penjualan"));
jLabel1.setText("Id Penjualan");
jLabel2.setText("Id Buku");
jLabel3.setText("Nama Kasir");
jLabel4.setText("Jumlah");
jLabel5.setText("Total");
cboBuku.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
cboBukuItemStateChanged(evt);
}
});
cboBuku.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cboBukuActionPerformed(evt);
}
});
txtJumlah.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtJumlahActionPerformed(evt);
}
});
txtJumlah.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtJumlahKeyReleased(evt);
}
});
txtTotal.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtTotalActionPerformed(evt);
}
});
jLabel6.setText("Tanggal");
btnSimpan.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gambar/1484900179_floppy_disk_save.png"))); // NOI18N
btnSimpan.setText("SIMPAN");
btnSimpan.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSimpanActionPerformed(evt);
}
});
jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gambar/1484900274_ic_cancel_48px.png"))); // NOI18N
jButton2.setText("BATAL");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gambar/1484900317_common-logout-signout-exit-glyph.png"))); // NOI18N
jButton3.setText("KELUAR");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jLabel7.setText("NoISBN");
jLabel8.setText("Judul");
jLabel9.setText("Penulis");
jLabel10.setText("Penerbit");
jLabel11.setText("Tahun");
jLabel12.setText("Stok");
jLabel13.setText("Harga Jual");
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);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(33, 33, 33)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel8)
.addComponent(jLabel9))
.addGap(23, 23, 23)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(txtPenulis, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(27, 27, 27)
.addComponent(jLabel10)
.addGap(18, 18, 18)
.addComponent(txtPenerbit))
.addComponent(txtJudul))
.addGap(118, 118, 118))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addGap(142, 142, 142)
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtStok, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(35, 35, 35)
.addComponent(jLabel13)
.addGap(18, 18, 18)
.addComponent(txtHarga, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 83, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(47, 47, 47)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtIdTransaksi, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
.addComponent(cboBuku, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6)
.addComponent(jLabel7))
.addGap(23, 23, 23)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtIsbn)
.addComponent(txtTanggal))))
.addGap(32, 32, 32))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(jLabel5))
.addGap(47, 47, 47)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtJumlah, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
.addComponent(txtTotal, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
.addComponent(txtNama, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(48, 48, 48)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnCetak)
.addComponent(btnSimpan))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtTahun, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(94, 94, 94))))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(19, 19, 19)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(txtTanggal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(3, 3, 3))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(txtIdTransaksi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(6, 6, 6)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cboBuku, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(txtIsbn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel8)
.addComponent(txtJudul, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(txtPenulis, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10)
.addComponent(txtPenerbit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11)
.addComponent(txtTahun, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel12)
.addComponent(txtStok, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel13)
.addComponent(txtHarga, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(59, 59, 59)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnSimpan)
.addComponent(jButton2)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(13, 13, 13)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtNama, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(txtJumlah, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(txtTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnCetak)
.addComponent(jButton3))
.addContainerGap(73, 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(jPanel1, 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(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>
private void cboBukuActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void cboBukuItemStateChanged(java.awt.event.ItemEvent evt) {
// TODO add your handling code here:
getDetBuku();
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {
// TODO add your handling code here:
sessionLogin sesi = new sessionLogin();
txtNama.setText(sesi.getNamaKasir());
if(this.isUpdate()==true){
getBuku();
pushData();
btnSimpan.setText("Update");
}else{
genIdTransaksi();
getBuku();
tglTransaksi();
btnSimpan.setText("Simpan");
}
}
private void txtTotalActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void txtJumlahKeyReleased(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
if(txtJumlah.getText().isEmpty()){
txtTotal.setText("0");
}else{
getTotal();
}
}
private void txtJumlahActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.dispose();
}
private void btnSimpanActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(this.isUpdate() == true){
updateData();
}else{
simpan();
}
}
private void btnCetakActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
cetak();
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bersih();
}
/**
* @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(Penjualan.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Penjualan.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Penjualan.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Penjualan.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 Penjualan().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnCetak;
private javax.swing.JButton btnSimpan;
private javax.swing.JComboBox cboBuku;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField txtHarga;
private javax.swing.JTextField txtIdTransaksi;
private javax.swing.JTextField txtIsbn;
private javax.swing.JTextField txtJudul;
private javax.swing.JTextField txtJumlah;
private javax.swing.JLabel txtNama;
private javax.swing.JTextField txtPenerbit;
private javax.swing.JTextField txtPenulis;
private javax.swing.JTextField txtStok;
private javax.swing.JTextField txtTahun;
private javax.swing.JTextField txtTanggal;
private javax.swing.JTextField txtTotal;
// End of variables declaration
/**
* @return the idPenjualan
*/
public String getIdPenjualan() {
return idPenjualan;
}
/**
* @param idPenjualan the idPenjualan to set
*/
public void setIdPenjualan(String idPenjualan) {
this.idPenjualan = idPenjualan;
}
/**
* @return the update
*/
public boolean isUpdate() {
return update;
}
/**
* @param update the update to set
*/
public void setUpdate(boolean update) {
this.update = update;
}
/**
* @return the diskon
*/
public String getDiskon() {
return diskon;
}
/**
* @param diskon the diskon to set
*/
public void setDiskon(String diskon) {
this.diskon = diskon;
}
}
* 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 nmTransaksi;
import Class.classkoneksi;
import com.mysql.jdbc.Connection;
import java.awt.Cursor;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JRootPane;
import javax.swing.table.DefaultTableModel;
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;
import net.sf.jasperreports.engine.util.JRLoader;
import sesion.sessionLogin;
/**
*
* @author RPL
*/
public class Penjualan extends javax.swing.JFrame {
private String idPenjualan;
private String diskon;
private boolean update = false;
/**
* Creates new form Penjualan
*/
public Penjualan() {
setUndecorated(true);
getRootPane().setWindowDecorationStyle(JRootPane.NONE);
initComponents();
this.setLocationRelativeTo(this);
}
private void getBuku() {
try{
String SQL = "Select id_buku from tbl_buku order by id_bUku asc";
ResultSet rs = classkoneksi.executeQuery(SQL);
cboBuku.removeAllItems();
cboBuku.addItem("-");
while(rs.next()){
cboBuku.addItem(rs.getString(1));
}
}catch (Exception e) {
}
}
private void getDetBuku(){
try{
String idBuku = cboBuku.getSelectedItem().toString();
String SQL = "select noisbn,judul,penulis,penerbit,tahun,stok,harga_jual "
+"from tbl_buku where id_buku ='"+idBuku+"'";
ResultSet rs = classkoneksi.executeQuery(SQL);
if(rs.next()){
txtIsbn.setText(rs.getString(1));
txtJudul.setText(rs.getString(2));
txtPenulis.setText(rs.getString(3));
txtPenerbit.setText(rs.getString(4));
txtTahun.setText(rs.getString(5));
txtStok.setText(rs.getString(6));
txtHarga.setText(rs.getString(7));
}
}catch (Exception e){
}
}
private void getTotal(){
String jumlah = txtJumlah.getText();
int j = Integer.valueOf(jumlah);
String harga = txtHarga.getText();
int h = Integer.valueOf(harga);
int Hasil = j*h;
txtTotal.setText(String.valueOf(Hasil));
}
private void genIdTransaksi(){
try{
String SQL = "select substring(id_penjualan,5,10) as id from tbl_penjualan order by id_penjualan desc limit 0,1";
ResultSet rs = classkoneksi.executeQuery(SQL);
SimpleDateFormat df = new SimpleDateFormat("yyMM");
Date date = new Date();
String hasil = df.format(date);
if(rs.next()){
String str = "000000";
int id = Integer.valueOf(rs.getString(1))+1;
String str_no = String.valueOf(id);
String idTransaksi = hasil+str.substring(0,6-str_no.length())+Integer.toString(id);
txtIdTransaksi.setText(idTransaksi);
}else{
txtIdTransaksi.setText(hasil+"000001");
}
}catch(Exception e){
JOptionPane.showMessageDialog(rootPane, "ada kesalahan dalam database");
}
}
private void tglTransaksi(){
SimpleDateFormat df = new SimpleDateFormat("EEE, dd MMMM YYYY");
Date date = new Date();
String hasil = df.format(date);
txtTanggal.setText(hasil);
}
private int cekData(){
int i = 0;
if(cboBuku.getSelectedItem().equals("-")){
JOptionPane.showMessageDialog(rootPane, "Silahkan pilih buku.","Peringatan", JOptionPane.WARNING_MESSAGE);
}else if(txtJumlah.getText().isEmpty()){
JOptionPane.showMessageDialog(rootPane, "Jumlah tidak boleh kosong.","Peringatan", JOptionPane.WARNING_MESSAGE);
}else{
i=1;
}
return i;
}
private void simpan(){
int i = cekData();
if(i>0){
String idTransaksi = txtIdTransaksi.getText();
String idBuku = cboBuku.getSelectedItem().toString();
String idKasir = "KSR001";
String jumlah = txtJumlah.getText();
String total = txtTotal.getText();
SimpleDateFormat df = new SimpleDateFormat("YYYY-MM-dd");
Date date = new Date();
String tanggal = df.format(date);
String SQL = "insert into tbl_penjualan value('"+idTransaksi+"','"+idBuku+"','"+idKasir+"','"+jumlah+"','"+total+"','"+tanggal+"')";
int a = classkoneksi.execute(SQL);
if(i>0){
JOptionPane.showMessageDialog(rootPane, "Data berhasil di simpan.","Succses", JOptionPane.INFORMATION_MESSAGE);
}else{
JOptionPane.showMessageDialog(rootPane, "data gagal di simpan","Gagal", JOptionPane.WARNING_MESSAGE);
}
}
}
private void updateData(){
String idTransaksi = txtIdTransaksi.getText();
String idBuku = cboBuku.getSelectedItem().toString();
String idKasir = "17010001";
String jumlah = txtJumlah.getText();
String total = txtTotal.getText();
String SQL = "update tbl_penjualan set id_buku='"+idBuku+"',jumlah='"+jumlah+"',total='"+total+"' where "
+ "id_penjualan = '"+idTransaksi+"'";
int i = classkoneksi.execute(SQL);
if(i>0){
JOptionPane.showMessageDialog(rootPane, "Data berhasil diubah.","Success",JOptionPane.INFORMATION_MESSAGE);
}else{
JOptionPane.showMessageDialog(rootPane, "Data gagal diubah.","Gagal",JOptionPane.WARNING_MESSAGE);
}
}
private void pushData(){
String SQL = "Select * from tbl_penjualan where id_penjualan = '"+this.getIdPenjualan()+"'";
try{
ResultSet rs = classkoneksi.executeQuery(SQL);
if(rs.next()){
txtIdTransaksi.setText(rs.getString(1));
cboBuku.setSelectedItem(rs.getString(2));
txtJumlah.setText(rs.getString(4));
txtTotal.setText(rs.getString(5));
txtTanggal.setText(rs.getString(6));
}
}catch(Exception e){
JOptionPane.showMessageDialog(rootPane, "kesalahan dalam database");
}
}
private void cetak(){
{btnCetak.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
Connection cn = classkoneksi.setKoneksi();
try {
Statement st = cn.createStatement();
Map<String, Object> prs = new HashMap<String, Object>();
prs.put("idPenjualan", txtIdTransaksi.getText());
JasperReport JRpt =
JasperCompileManager.compileReport("src/Laporan/fakturPenjualan.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(700,882);
dialog.setTitle("Laporan Transaksi");
dialog.setVisible(true);
dialog.setLocationRelativeTo(this);
} catch (Exception rptexcpt) {
System.out.println("Report Can't view because : " + rptexcpt);
}
btnCetak.setCursor(Cursor.getDefaultCursor());
}
}
public void bersih(){
txtJudul.setText("");
txtIsbn.setText("");
txtPenulis.setText("");
txtPenerbit.setText("");
txtTahun.setText("");
txtStok.setText("");
txtHarga.setText("");
txtJumlah.setText("");
txtTotal.setText("");
}
/**
* 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();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
txtIdTransaksi = new javax.swing.JTextField();
cboBuku = new javax.swing.JComboBox();
txtJumlah = new javax.swing.JTextField();
txtTotal = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
btnSimpan = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jLabel7 = new javax.swing.JLabel();
txtIsbn = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
txtJudul = new javax.swing.JTextField();
jLabel9 = new javax.swing.JLabel();
txtPenulis = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
txtPenerbit = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
txtTahun = new javax.swing.JTextField();
jLabel12 = new javax.swing.JLabel();
txtStok = new javax.swing.JTextField();
jLabel13 = new javax.swing.JLabel();
txtHarga = new javax.swing.JTextField();
txtTanggal = new javax.swing.JTextField();
btnCetak = new javax.swing.JButton();
txtNama = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Penjualan"));
jLabel1.setText("Id Penjualan");
jLabel2.setText("Id Buku");
jLabel3.setText("Nama Kasir");
jLabel4.setText("Jumlah");
jLabel5.setText("Total");
cboBuku.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
cboBukuItemStateChanged(evt);
}
});
cboBuku.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cboBukuActionPerformed(evt);
}
});
txtJumlah.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtJumlahActionPerformed(evt);
}
});
txtJumlah.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtJumlahKeyReleased(evt);
}
});
txtTotal.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtTotalActionPerformed(evt);
}
});
jLabel6.setText("Tanggal");
btnSimpan.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gambar/1484900179_floppy_disk_save.png"))); // NOI18N
btnSimpan.setText("SIMPAN");
btnSimpan.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSimpanActionPerformed(evt);
}
});
jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gambar/1484900274_ic_cancel_48px.png"))); // NOI18N
jButton2.setText("BATAL");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gambar/1484900317_common-logout-signout-exit-glyph.png"))); // NOI18N
jButton3.setText("KELUAR");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jLabel7.setText("NoISBN");
jLabel8.setText("Judul");
jLabel9.setText("Penulis");
jLabel10.setText("Penerbit");
jLabel11.setText("Tahun");
jLabel12.setText("Stok");
jLabel13.setText("Harga Jual");
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);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(33, 33, 33)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel8)
.addComponent(jLabel9))
.addGap(23, 23, 23)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(txtPenulis, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(27, 27, 27)
.addComponent(jLabel10)
.addGap(18, 18, 18)
.addComponent(txtPenerbit))
.addComponent(txtJudul))
.addGap(118, 118, 118))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addGap(142, 142, 142)
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtStok, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(35, 35, 35)
.addComponent(jLabel13)
.addGap(18, 18, 18)
.addComponent(txtHarga, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 83, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(47, 47, 47)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtIdTransaksi, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
.addComponent(cboBuku, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6)
.addComponent(jLabel7))
.addGap(23, 23, 23)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtIsbn)
.addComponent(txtTanggal))))
.addGap(32, 32, 32))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(jLabel5))
.addGap(47, 47, 47)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtJumlah, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
.addComponent(txtTotal, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
.addComponent(txtNama, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(48, 48, 48)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnCetak)
.addComponent(btnSimpan))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtTahun, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(94, 94, 94))))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(19, 19, 19)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(txtTanggal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(3, 3, 3))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(txtIdTransaksi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(6, 6, 6)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cboBuku, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(txtIsbn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel8)
.addComponent(txtJudul, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(txtPenulis, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10)
.addComponent(txtPenerbit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11)
.addComponent(txtTahun, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel12)
.addComponent(txtStok, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel13)
.addComponent(txtHarga, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(59, 59, 59)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnSimpan)
.addComponent(jButton2)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(13, 13, 13)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtNama, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(txtJumlah, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(txtTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnCetak)
.addComponent(jButton3))
.addContainerGap(73, 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(jPanel1, 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(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>
private void cboBukuActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void cboBukuItemStateChanged(java.awt.event.ItemEvent evt) {
// TODO add your handling code here:
getDetBuku();
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {
// TODO add your handling code here:
sessionLogin sesi = new sessionLogin();
txtNama.setText(sesi.getNamaKasir());
if(this.isUpdate()==true){
getBuku();
pushData();
btnSimpan.setText("Update");
}else{
genIdTransaksi();
getBuku();
tglTransaksi();
btnSimpan.setText("Simpan");
}
}
private void txtTotalActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void txtJumlahKeyReleased(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
if(txtJumlah.getText().isEmpty()){
txtTotal.setText("0");
}else{
getTotal();
}
}
private void txtJumlahActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.dispose();
}
private void btnSimpanActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(this.isUpdate() == true){
updateData();
}else{
simpan();
}
}
private void btnCetakActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
cetak();
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bersih();
}
/**
* @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(Penjualan.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Penjualan.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Penjualan.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Penjualan.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 Penjualan().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnCetak;
private javax.swing.JButton btnSimpan;
private javax.swing.JComboBox cboBuku;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField txtHarga;
private javax.swing.JTextField txtIdTransaksi;
private javax.swing.JTextField txtIsbn;
private javax.swing.JTextField txtJudul;
private javax.swing.JTextField txtJumlah;
private javax.swing.JLabel txtNama;
private javax.swing.JTextField txtPenerbit;
private javax.swing.JTextField txtPenulis;
private javax.swing.JTextField txtStok;
private javax.swing.JTextField txtTahun;
private javax.swing.JTextField txtTanggal;
private javax.swing.JTextField txtTotal;
// End of variables declaration
/**
* @return the idPenjualan
*/
public String getIdPenjualan() {
return idPenjualan;
}
/**
* @param idPenjualan the idPenjualan to set
*/
public void setIdPenjualan(String idPenjualan) {
this.idPenjualan = idPenjualan;
}
/**
* @return the update
*/
public boolean isUpdate() {
return update;
}
/**
* @param update the update to set
*/
public void setUpdate(boolean update) {
this.update = update;
}
/**
* @return the diskon
*/
public String getDiskon() {
return diskon;
}
/**
* @param diskon the diskon to set
*/
public void setDiskon(String diskon) {
this.diskon = diskon;
}
}
Comments
Post a Comment