Contoh Laporan Ujian Akhir Semester
LAPORAN UAS
Pemrograman Database
APLIKASI
PEMBAYARAN PAJAK
DiSusun Oleh:
Dewi Fatikha Sari: (13.5.00158)
Puji
Hastuti: (13.5.00142)
Andhika Candra S: (13.5.00162)
Program Studi: Teknik
Informatika_S1
SEKOLAH TINGGI MANAJEMEN INFORMATIKA DAN
KOMPUTER
SINAR NUSANTARA
2015
Pengertian
Basis Data
Basis data adalah kumpulan data yang
diorganisir dalam tabel-tabel yang berelasi.
Kali ini dalam rangka membuat projek tugas
akhir, kelompok kami membuat program yang bertemakan perpajakan. Di dalam
program ini, user bisa mengakses data
berupa memasukkan data diri, mengisi form pembayaran pajak, dan melihat laporan perpajakan tiap user yang
menggunakannya.
Di dalam laporan tugas akhir matakuliah
pemrograman database ini, akan dijelaskan lebih lanjut mengenai program berupa
hasil screenshot program serta sedikit penjelasan tentang coding dari program
yang telah dibuat.
Pada program yang dibuat kali ini kami
membuat database bernama pajak sebagai penyimpanan datanya. Di dalam database
tersebut terdapat 2 tabel, yaitu tabel pelanggan dan tabel pembayaran.
Database
pajak
Tabel Pelanggan
Tabel pelanggan ini
berisikan data pelanggan yang menggunakan aplikasi ini untuk membayar pajak.
Sebelum melakukan transaksi, user harus mengisi data diri terlebih dahulu
sebelum melanjutkan ke sesi selanjutnya. Tabel pelanggan
berisikan beberapa kolom yaitu id, nama, dan alamat. Pada kolom id diisi id
dari user yang akan membayar pajak melalui aplikasi ini, pada kolom nama
diisikan nama user, dan pada kolom alamat diisi alamat user seperti yang ada
pada gambar di atas.
Tabel
Pembayaran
Tabel pembayaran ini
merupakan database untuk menyimpan data transaksi yang telah dilakukan oleh
user. Tabel pembayaran
berisi lima kolom, diantaranya adalah kolom id, nama, nota, komponen, dan
nominal. Seperti sebelumnya, kolom id berisi id user, kolom nama berisi nama
user, kolom nota berisi nomor nota yang digunakan untuk bertransaksi, kolom
komponen berisi jenis pembayaran yang dilakukan, dan kolom nominal berisi angka
rupiah yang harus dibayarkan oleh user berdasarkan dari data pelanggan di atas.
Tampilan Aplikasi
login.java
/*
* 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.
*/
import
java.awt.Dimension;
import
java.awt.Toolkit;
import
java.sql.Connection;
import
java.sql.DriverManager;
import
java.sql.ResultSet;
import
java.sql.Statement;
import
javax.swing.JOptionPane;
/**
*
* @author COMPAQ
*/
public
class Login extends javax.swing.JFrame {
private
Connection con;
private
Statement stat;
private
ResultSet res;
public
String sql="";
/**
* Creates new form Login
*/
public Login() {
initComponents();
setTitle("LOGIN");
//membuat layout tampil di tengah
pada saat di tampilkan
Dimension screenSize =
Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = getSize();
setLocation(
(screenSize.width - frameSize.width)
/ 2,
(screenSize.height -
frameSize.height) / 2);
}
/**
* 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")
//
private void initComponents() {
login = new javax.swing.JButton();
exit = new javax.swing.JButton();
username = new
javax.swing.JTextField();
password = new
javax.swing.JPasswordField();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
daftar = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
login.setText("LOGIN");
login.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
loginActionPerformed(evt);
}
});
exit.setText("EXIT");
exit.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
exitActionPerformed(evt);
}
});
password.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
passwordActionPerformed(evt);
}
});
jLabel1.setText("USERNAME");
jLabel2.setText("PASSWORD");
jLabel3.setFont(new
java.awt.Font("Stencil Std", 0, 24)); // NOI18N
jLabel3.setText("ANDA HARUS
LOGIN DULU");
daftar.setText("DAFTAR");
daftar.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent
evt) {
daftarActionPerformed(evt);
}
});
jLabel4.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/gambar/Lunas
Pajak.png"))); // NOI18N
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(50, 50, 50)
.addComponent(jLabel3))
.addGroup(layout.createSequentialGroup()
.addGap(96, 96, 96)
.addComponent(login)
.addGap(18, 18, 18)
.addComponent(daftar)
.addGap(18, 18, 18)
.addComponent(exit))
.addGroup(layout.createSequentialGroup()
.addGap(78, 78, 78)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
9, Short.MAX_VALUE)
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(username,
javax.swing.GroupLayout.PREFERRED_SIZE, 120,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(password, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 120,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(51,
Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(40, 40, 40)
.addComponent(jLabel3)
.addGap(35, 35, 35)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addGap(96, 96, 96)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jLabel4))
.addGap(39, 39, 39)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(login)
.addComponent(daftar)
.addComponent(exit))
.addContainerGap(83,
Short.MAX_VALUE))
);
pack();
}//
|
private void
exitActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
private void
passwordActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void
loginActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
Class.forName("com.mysql.jdbc.Driver");
con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/pajak",
"root", "");
sql = "SELECT * from login
WHERE username='" + username.getText() + "'" + "AND password='" + password.getText() +
"'";
stat = con.createStatement();
res = stat.executeQuery(sql);
int baris = 0;
while (res.next()) {
baris = res.getRow();
}
if (baris == 1) {
new menu().show(); // form tujuan jika login berhasil
dispose();
} else {
JOptionPane.showMessageDialog(null, "Username atau Password anda
Salah", null, JOptionPane.ERROR_MESSAGE);
}
} catch (Exception e) {
}
}
private void
daftarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new daftar().show();
dispose();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//
/* 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(Login.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch
(javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//
/* Create and display the form */
java.awt.EventQueue.invokeLater(new
Runnable() {
public void run() {
new Login().setVisible(true);
}
});
}
// Variables declaration - do not
modify
private javax.swing.JButton daftar;
private javax.swing.JButton exit;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JButton login;
private javax.swing.JPasswordField
password;
private javax.swing.JTextField username;
// End of variables declaration
}
Ini adalah tampilan
awal aplikasi pembayaran pajak. Pada menu program ini berisi form login yang
mengharuskan user untuk login terlebih dahulu sebelum menggunakan aplikasi
pembayaran pajak ini. Jika user belum memiliki akun yang digunakan untuk login,
maka user harus mendaftar dulu dan masuk ke form pendaftaran.
daftar.java
Di bawah ini merupakan scriptdari daftar.java yang berisi
form pendaftaran bagi user yang belum memiliki akun untuk masuk ke aplikasi ini.
/*
* 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.
*/
import
java.awt.Dimension;
import
java.awt.Toolkit;
import
java.sql.Connection;
import
java.sql.DriverManager;
import
java.sql.ResultSet;
import
java.sql.Statement;
import
javax.swing.JOptionPane;
/**
*
* @author COMPAQ
*/
public
class daftar extends javax.swing.JFrame {
private Connection con;
private Statement stat;
private ResultSet res;
public String sql="";
/**
* Creates new form daftar
*/
public daftar() {
initComponents();
setTitle("PENDAFTARAN");
//membuat layout tampil di tengah pada
saat di tampilkan
Dimension screenSize =
Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = getSize();
setLocation(
(screenSize.width - frameSize.width)
/ 2,
(screenSize.height - frameSize.height)
/ 2);
}
/**
* 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")
//
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
username = new
javax.swing.JTextField();
email = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
daftar = new javax.swing.JButton();
batal = new javax.swing.JButton();
password = new
javax.swing.JPasswordField();
jLabel5 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setFont(new
java.awt.Font("Stencil Std", 0, 24)); // NOI18N
jLabel1.setText("SILAHKAN ISI
FORM DIBAWAH INI");
jLabel2.setText("Username");
jLabel3.setText("E-mail");
jLabel4.setText("Password");
daftar.setText("DAFTARKAN");
daftar.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
daftarActionPerformed(evt);
}
});
batal.setText("BATAL");
batal.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
batalActionPerformed(evt);
}
});
jLabel5.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/gambar/images.png")));
// NOI18N
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(37, 37, 37)
.addComponent(jLabel1)
.addGap(0, 30,
Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(99, 99, 99)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addGroup(layout.createSequentialGroup()
.addComponent(daftar)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
37, Short.MAX_VALUE)
.addComponent(batal))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jLabel4))
.addGap(33,
33, 33)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(username, javax.swing.GroupLayout.DEFAULT_SIZE, 112,
Short.MAX_VALUE)
.addComponent(email)
.addComponent(password))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel5)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(53, 53, 53)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(username,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(25, 25, 25)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(email, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(21, 21, 21)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jLabel5))
.addGap(33, 33, 33)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(batal)
.addComponent(daftar))
.addGap(0, 87,
Short.MAX_VALUE))
);
pack();
}//
|
private void daftarActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:
try {
Class.forName("com.mysql.jdbc.Driver");
con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/pajak",
"root", null);
sql = "insert into login
values ('" + username.getText() + "','" + email.getText() +
"','" + password.getText() + "')";
stat = con.createStatement();
stat.executeUpdate(sql);
JOptionPane.showMessageDialog(null, "SELAMAT \t " +
username.getText() + "\n" + "Silahkah Login :)");
new Login().show();
dispose();
}catch (Exception e) {
System.err.println("SQLException:"+e.getMessage());
JOptionPane.showMessageDialog(null, "TERDAPAT KESALAHAN, HARAP
ULANGI!!!", null, JOptionPane.ERROR_MESSAGE);
}
}
private void
batalActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new Login().show();
dispose();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//
/* 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(daftar.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(daftar.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(daftar.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch
(javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(daftar.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//
/* Create and display the form */
java.awt.EventQueue.invokeLater(new
Runnable() {
public void run() {
new
daftar().setVisible(true);
}
});
}
// Variables declaration - do not
modify
private javax.swing.JButton batal;
private javax.swing.JButton daftar;
private javax.swing.JTextField email;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPasswordField
password;
private javax.swing.JTextField username;
// End of variables declaration
}
menu.java
Selanjutnya setelah
melakukan login, user akan masuk ke tampilan utama program ini yang berisi
menu-menu yang ditawarkan oleh aplikasi. Di dalamnya ada menu
“menu”, dan “laporan”. Dalam menu “menu” terdapat beberapa submenu, yaitu
submenu pendaftaran data diri dan sub menu pembayaran atau transaksi. Dalam
menu “laporan” terdapat submenu laporan pelanggan dan laporan pembayaran.
import
java.sql.Connection;
import
java.sql.Statement;
/*
* 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.
*/
/**
*
* @author COMPAQ
*/
public
class menu extends javax.swing.JFrame {
/**
* Creates new form menu
*/
public menu() {
initComponents();
}
/**
* 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")
//
private void initComponents() {
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jMenuBar1 = new
javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
pendaftaran = new
javax.swing.JMenuItem();
transaksi = new
javax.swing.JMenuItem();
exit = new javax.swing.JMenuItem();
keluar = new javax.swing.JMenu();
jMenuItem1 = new
javax.swing.JMenuItem();
jMenuItem2 = new
javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("MENU KU");
addWindowListener(new
java.awt.event.WindowAdapter() {
public void
windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});
getContentPane().setLayout(new
org.netbeans.lib.awtextra.AbsoluteLayout());
jButton1.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/critical_icon.gif")));
// NOI18N
jButton1.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(168, 11, -1, -1));
jButton2.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/information_icon.gif")));
// NOI18N
getContentPane().add(jButton2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(93, 11, -1, -1));
jButton3.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/icon48.png"))); //
NOI18N
getContentPane().add(jButton3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(10, 11, -1, -1));
jLabel1.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/gambar/pajak-i.jpg")));
// NOI18N
getContentPane().add(jLabel1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));
jMenu1.setText("Menu");
pendaftaran.setText("Form
Pendaftaran");
pendaftaran.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
pendaftaranActionPerformed(evt);
}
});
jMenu1.add(pendaftaran);
transaksi.setText("Form
Transaksi");
transaksi.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
transaksiActionPerformed(evt);
}
});
jMenu1.add(transaksi);
exit.setText("Exit");
exit.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
exitActionPerformed(evt);
}
});
jMenu1.add(exit);
jMenuBar1.add(jMenu1);
keluar.setText("Laporan");
keluar.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
keluarActionPerformed(evt);
}
});
jMenuItem1.setText("Laporan
Pelanggan");
jMenuItem1.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
keluar.add(jMenuItem1);
jMenuItem2.setText("Lporan
Pembayaran");
jMenuItem2.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
keluar.add(jMenuItem2);
jMenuBar1.add(keluar);
setJMenuBar(jMenuBar1);
pack();
}//
|
private void
exitActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
private void
pendaftaranActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new jform1(this,
rootPaneCheckingEnabled).show();
}
private void
transaksiActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new OPO(this,
rootPaneCheckingEnabled).show();
}
private void
formWindowOpened(java.awt.event.WindowEvent evt) {
// TODO add your handling code here:
setExtendedState(menu.MAXIMIZED_BOTH);
}
private void
keluarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
private void
jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
koneksi conn1=new koneksi();
java.io.File namaFile = new
java.io.File("src/report1.jasper");
try {
net.sf.jasperreports.engine.JasperReport jasper;
jasper=(net.sf.jasperreports.engine.JasperReport)
net.sf.jasperreports.engine.util.JRLoader.loadObject(namaFile.getPath());
net.sf.jasperreports.engine.JasperPrint jp;
jp=net.sf.jasperreports.engine.JasperFillManager.fillReport(jasper,null,conn1.getCon());
net.sf.jasperreports.view.JasperViewer.viewReport(jp,false);
} catch (Exception ex) {
javax.swing.JOptionPane.showMessageDialog(rootPane, ex.getMessage());
}
}
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:
koneksi conn1=new koneksi();
java.io.File namaFile = new
java.io.File("src/pembayaran.jasper");
try {
net.sf.jasperreports.engine.JasperReport jasper;
jasper=(net.sf.jasperreports.engine.JasperReport)
net.sf.jasperreports.engine.util.JRLoader.loadObject(namaFile.getPath());
net.sf.jasperreports.engine.JasperPrint
jp;
jp=net.sf.jasperreports.engine.JasperFillManager.fillReport(jasper,null,conn1.getCon());
net.sf.jasperreports.view.JasperViewer.viewReport(jp,false);
} catch (Exception ex) {
javax.swing.JOptionPane.showMessageDialog(rootPane,
ex.getMessage());
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//
/* 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(menu.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(menu.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(menu.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch
(javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(menu.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//
/* Create and display the form */
java.awt.EventQueue.invokeLater(new
Runnable() {
public void run() {
new menu().setVisible(true);
}
});
}
// Variables declaration - do not
modify
private javax.swing.JMenuItem exit;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenu keluar;
private javax.swing.JMenuItem
pendaftaran;
private javax.swing.JMenuItem transaksi;
// End of variables declaration
}
Gambar diambil dari direktorat jendral pajak |
jform1.java
Dalam form ini untuk
mendaftarkan diri user harus mengisi id, nama, dan alamat,kemudian pilih
simpan. Untuk mengganti data diri,user cukup memasukkan id-nya dan mengganti
nama dan alamatnya sesuai dengan keinginannya. Untuk menghapus juga, tinggal
memasukkan data diri dan pilih hapus, dan begitupun seterusnya.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Andika PC
*/
import
java.awt.Dialog;
import
java.sql.*;
import javax.swing.JOptionPane;
import
javax.swing.table.DefaultTableModel;
import
java.awt.PrintJob;
import
java.awt.Graphics;
import
java.awt.Font;
/**
*
* @author COMPAQ
*/
public
class jform1 extends java.awt.Dialog {
Statement
stmt ;
Connection
con ;
String
url = "jdbc:mysql://localhost:3306/pajak";
/**
* Creates new form jform1
*/
public jform1(java.awt.Frame parent,
boolean modal){
super(parent, modal);
initComponents();
}
/**
* 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")
//
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
id = new javax.swing.JTextField();
nama = new javax.swing.JTextField();
alamat = new
javax.swing.JTextField();
simpan = new javax.swing.JButton();
ganti = new javax.swing.JButton();
hapus = new javax.swing.JButton();
cari = new javax.swing.JButton();
batal = new javax.swing.JButton();
jScrollPane1 = new
javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
cetak = new javax.swing.JButton();
jumlah = new
javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
setTitle("PENDAFTARAN PEMBAYARAN
PAJAK");
addWindowListener(new
java.awt.event.WindowAdapter() {
public void
windowActivated(java.awt.event.WindowEvent evt) {
formWindowActivated(evt);
}
public void
windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});
jLabel1.setText("Masukan Nomor
ID");
jLabel2.setText("Masukkan
Nama");
jLabel3.setText("Masukkan
Alamat");
simpan.setText("SIMPAN");
simpan.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
simpanActionPerformed(evt);
}
});
ganti.setText("GANTI");
ganti.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
gantiActionPerformed(evt);
}
});
hapus.setText("HAPUS");
hapus.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
hapusActionPerformed(evt);
}
});
cari.setText("Cari");
cari.addActionListener(new java.awt.event.ActionListener()
{
public void
actionPerformed(java.awt.event.ActionEvent evt) {
cariActionPerformed(evt);
}
});
batal.setText("BATAL");
batal.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
batalActionPerformed(evt);
}
});
jTable1.setModel(new
javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1",
"Title 2", "Title 3", "Title 4"
}
));
jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
jScrollPane1.setViewportView(jTable1);
cetak.setText("CETAK");
cetak.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
cetakActionPerformed(evt);
}
});
jLabel4.setText("Jumlah
Data");
jLabel5.setFont(new
java.awt.Font("Perpetua Titling MT", 1, 24)); // NOI18N
jLabel5.setText("FORM
PENDAFTARAN");
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(25, 25,
25)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3))
.addGap(39, 39, 39)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(alamat, javax.swing.GroupLayout.PREFERRED_SIZE, 217,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(nama)
.addGroup(layout.createSequentialGroup()
.addComponent(id, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cari))))
.addGroup(layout.createSequentialGroup()
.addComponent(simpan)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(ganti)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(hapus)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(batal)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cetak))))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
424, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jumlah,
javax.swing.GroupLayout.PREFERRED_SIZE, 35,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(26,
Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGap(0, 0,
Short.MAX_VALUE)
.addComponent(jLabel5)
.addGap(73, 73, 73))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel5)
.addGap(21, 21, 21)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(id,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1)
.addComponent(cari))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(nama,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3)
.addComponent(alamat,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(simpan)
.addComponent(ganti)
.addComponent(hapus)
.addComponent(batal)
.addComponent(cetak))
.addGap(2, 2, 2)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jumlah,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 249,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
pack();
}//
|
public
void cetak_data(){
DefaultTableModel tabelnyo = new
DefaultTableModel();
tabelnyo.addColumn("NOMOR
ID");
tabelnyo.addColumn("NAMA
");
tabelnyo.addColumn("ALAMAT");
try {
con = DriverManager.getConnection(url,"root","");
stmt = con.createStatement();
String sql2 = "select * from
pelanggan order by id ";
stmt.executeQuery(sql2);
ResultSet rs =
stmt.executeQuery(sql2);
while (rs.next()){
tabelnyo.addRow(new Object[]{
rs.getString(1),
rs.getString(2),
rs.getString(3),
});
int
x=rs.getRow();
jumlah.setText(""+x);
}
jTable1.setModel(tabelnyo);
id.setText("");nama.setText("");alamat.setText("");
} catch (SQLException
ex){System.out.println(ex.getMessage()); }
};
private void
simpanActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String ID = id.getText();
String Nama = nama.getText();
String Alamat = alamat.getText();
//
JOptionPane.showMessageDialog(null,nim+","+nama+","+alamat);
try {
con = DriverManager.getConnection(url,"root",null);
stmt = con.createStatement();
String sql = "insert into
pelanggan
values('"+ID+"','"+Nama+"','"+Alamat+"')";
stmt.executeUpdate(sql);
cetak_data();
JOptionPane.showMessageDialog(null,
"DATA BERHASIL DISIMPAN" ,
"PESAN",JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException ex){
System.err.println("SQLException:"+ex.getMessage());
JOptionPane.showMessageDialog(null, "TERJADI KESALAHAN!! HARAP
ULANGI" , "KESALAHAN",JOptionPane.ERROR_MESSAGE);
}
}
private void
formWindowActivated(java.awt.event.WindowEvent evt) {
// TODO add your handling code here:
cetak_data();
}
private void
batalActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
cetak_data();
}
private void
cariActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
// JOptionPane.showMessageDialog(null,nim+","+nama+","+alamat);
try {
con =
DriverManager.getConnection(url,"root",null);
stmt = con.createStatement();
String sql = "select * from
pelanggan where id='"+id.getText()+"'";
stmt.executeQuery(sql);
String ada="tidak";
ResultSet result =
stmt.executeQuery(sql);
while (result.next()){
nama.setText(result.getString("nama"));
alamat.setText(result.getString("alamat"));
ada="ya";
}
if(ada=="tidak"){
JOptionPane.showMessageDialog(null,
"DATA TIDAK DITEMUKAN" ,
"PESAN",JOptionPane.INFORMATION_MESSAGE);
}
} catch (SQLException ex){
System.err.println("SQLException:"+ex.getMessage());
JOptionPane.showMessageDialog(null, "TERJADI KESALAHAN!! HARAP
ULANGI" , "KESALAHAN",JOptionPane.ERROR_MESSAGE);
}
}
private void
hapusActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
con =
DriverManager.getConnection(url,"root",null);
//System.out.println("Database ditemukan");
stmt = con.createStatement();
String sql = "delete from
pelanggan where id="+id.getText();
stmt.executeUpdate(sql);
cetak_data();
JOptionPane.showMessageDialog(null,"DATA BERHASIL DIHAPUS",
"PESAN", JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException ex){
System.err.println("SQLException:"+ex.getMessage());
JOptionPane.showMessageDialog(null, "TERJADI KESALAHAN!! HARAP
ULANGI" , "KESALAHAN",JOptionPane.ERROR_MESSAGE);
}
}
private void
gantiActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
con =
DriverManager.getConnection(url,"root",null);
stmt = con.createStatement();
String sql = "update
pelanggan set nama='"+nama.getText()+"',
alamat='"+alamat.getText()+"' where
id='"+id.getText()+"'";
stmt.executeUpdate(sql);
cetak_data();
JOptionPane.showMessageDialog(null,
"DATA TELAH GIANTI" ,
"PESAN",JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException ex){
System.err.println("SQLException:"+ex.getMessage());
JOptionPane.showMessageDialog(null, "TERJADI KESALAHAN!! HARAP
ULANGI" , "KESALAHAN",JOptionPane.ERROR_MESSAGE);
}
}
private void
cetakActionPerformed(java.awt.event.ActionEvent evt) {
// TODO
add your handling code here:
}
private void
formWindowClosing(java.awt.event.WindowEvent evt) {
// TODO add your handling code here:
setVisible(false);
dispose();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/*
* Set the Nimbus look and feel
*/
//
/*
* 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(jform1.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(jform1.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(jform1.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch
(javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(jform1.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//
/*
* Create and display the form
*/
java.awt.EventQueue.invokeLater(new
Runnable() {
public void run() {
jform1 dialog = new jform1(new
java.awt.Frame(), true);
dialog.addWindowListener(new
java.awt.event.WindowAdapter() {
public void
windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not
modify
private javax.swing.JTextField alamat;
private javax.swing.JButton batal;
private javax.swing.JButton cari;
private javax.swing.JButton cetak;
private javax.swing.JButton ganti;
private javax.swing.JButton hapus;
private javax.swing.JTextField id;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JScrollPane
jScrollPane1;
private javax.swing.JTable jTable1;
private javax.swing.JTextField jumlah;
private javax.swing.JTextField nama;
private javax.swing.JButton simpan;
// End of variables declaration
}
OPO.java
/*
* 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.
*/
/**
*
* @author Win7
*/
import
java.awt.Font;
import
java.awt.Graphics;
import
java.awt.PrintJob;
import
java.sql.*;
import javax.swing.JOptionPane;
import
javax.swing.table.DefaultTableModel;
public
class OPO extends java.awt.Dialog {
Statement
stmt ;
Connection
con ;
String
url = "jdbc:mysql://localhost:3306/pajak";
int
total=0;
/**
* Creates new form OPO
*/
public OPO(java.awt.Frame parent, boolean
modal) {
super(parent, modal);
initComponents();
}
/**
* 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.
*/
//
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
id2 = new javax.swing.JTextField();
cari = new javax.swing.JButton();
nama = new javax.swing.JTextField();
nota = new javax.swing.JTextField();
nominal = new
javax.swing.JTextField();
proses = new javax.swing.JButton();
selesai = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jumlah = new javax.swing.JTextField();
jComboBox1 = new
javax.swing.JComboBox();
jScrollPane2 = new
javax.swing.JScrollPane();
jTable2 = new javax.swing.JTable();
cetak = new javax.swing.JButton();
setTitle("PEMBAYARAN PAJAK
BULANAN");
addWindowListener(new
java.awt.event.WindowAdapter() {
public void
windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
}
});
jLabel1.setFont(new
java.awt.Font("Perpetua Titling MT", 1, 24)); // NOI18N
jLabel1.setText("PEMBAYARAN");
cari.setText("cari");
cari.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
cariActionPerformed(evt);
}
});
proses.setText("proses");
proses.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
prosesActionPerformed(evt);
}
});
selesai.setText("selesai");
selesai.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
selesaiActionPerformed(evt);
}
});
jLabel2.setText("Nomor
ID");
jLabel3.setText("Nama");
jLabel4.setText("No.Nota");
jLabel5.setText("Membayar");
jLabel6.setText("Nominal");
jLabel7.setText("Jumlah
Bayar");
jumlah.setText("0");
jComboBox1.setModel(new
javax.swing.DefaultComboBoxModel(new String[] { "Rekening Listrik",
"PDAM", "Telepon", "Pajak Bangunan" }));
jComboBox1.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox1ActionPerformed(evt);
}
});
jTable2.setModel(new
javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1",
"Title 2", "Title 3", "Title 4"
}
));
jScrollPane2.setViewportView(jTable2);
cetak.setText("CETAK");
cetak.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
cetakActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(225, 225, 225)
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jLabel2)
.addGap(32, 32, 32)
.addComponent(id2,
javax.swing.GroupLayout.PREFERRED_SIZE, 96,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(81, 81, 81)
.addComponent(cari))
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jLabel3)
.addGap(50, 50, 50)
.addComponent(nama,
javax.swing.GroupLayout.PREFERRED_SIZE, 226, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jLabel4)
.addGap(37, 37, 37)
.addComponent(nota,
javax.swing.GroupLayout.PREFERRED_SIZE, 226,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jLabel5)
.addGap(27, 27, 27)
.addComponent(jComboBox1,
javax.swing.GroupLayout.PREFERRED_SIZE, 223,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jLabel6)
.addGap(40, 40, 40)
.addComponent(nominal,
javax.swing.GroupLayout.PREFERRED_SIZE, 223,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(87, 87, 87)
.addComponent(proses)
.addGap(18, 18, 18)
.addComponent(selesai)
.addGap(18, 18, 18)
.addComponent(cetak))
.addGroup(layout.createSequentialGroup()
.addGap(34, 34, 34)
.addComponent(jScrollPane2,
javax.swing.GroupLayout.PREFERRED_SIZE, 576,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(354, 354, 354)
.addComponent(jLabel7)
.addGap(90, 90, 90)
.addComponent(jumlah,
javax.swing.GroupLayout.PREFERRED_SIZE, 102,
javax.swing.GroupLayout.PREFERRED_SIZE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(jLabel2))
.addGroup(layout.createSequentialGroup()
.addGap(1, 1, 1)
.addComponent(id2,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(cari))
.addGap(4, 4, 4)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(3, 3, 3)
.addComponent(jLabel3))
.addComponent(nama,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(3, 3, 3)
.addComponent(jLabel4))
.addComponent(nota,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(3, 3, 3)
.addComponent(jLabel5))
.addComponent(jComboBox1,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(4, 4, 4)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(3, 3, 3)
.addComponent(jLabel6))
.addComponent(nominal,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(proses)
.addComponent(selesai)
.addComponent(cetak))
.addGap(11, 11, 11)
.addComponent(jScrollPane2,
javax.swing.GroupLayout.PREFERRED_SIZE, 111,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(7, 7, 7)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(3, 3, 3)
.addComponent(jLabel7))
.addComponent(jumlah,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))
);
pack();
}//
|
/**
* Closes the dialog
*/
private void
closeDialog(java.awt.event.WindowEvent evt) {
setVisible(false);
dispose();
}
public void cetak_data(){
DefaultTableModel tabelnyo = new
DefaultTableModel();
tabelnyo.addColumn("NOMOR
ID");
tabelnyo.addColumn("NAMA
");
tabelnyo.addColumn("NO.
NOTA");
tabelnyo.addColumn("MEMBAYAR");
tabelnyo.addColumn("NOMINAL");
try {
con =
DriverManager.getConnection(url,"root","");
System.out.println("Database
Ditemukan");
stmt = con.createStatement();
String sql2 = "select * from
pembayaran where nota='"+nota.getText()+"'";
stmt.executeQuery(sql2);
ResultSet rs =
stmt.executeQuery(sql2);
while (rs.next()){
tabelnyo.addRow(new Object[]{
rs.getString(1),
rs.getString(2),
rs.getString(3),
rs.getString(4),
rs.getString(5),
});
}
jTable2.setModel(tabelnyo);
} catch (SQLException
ex){System.out.println(ex.getMessage()); }
}
private void
cariActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
con =
DriverManager.getConnection(url,"root",null);
stmt = con.createStatement();
String sql = "select * from
pelanggan where id='"+id2.getText()+"'";
stmt.executeQuery(sql);
String ada="tidak";
ResultSet result =
stmt.executeQuery(sql);
while (result.next()){
nama.setText(result.getString("nama"));
// tambah nomer
String sql1 = "insert into
pembayaran(id)values('"+id2.getText()+"')";
stmt.executeUpdate(sql1);
// cari nomer terakhir
String sql2 = "select *
from pembayaran order by nota";
ResultSet rs_bayar =
stmt.executeQuery(sql2);
while (rs_bayar.next()){
nota.setText(""+rs_bayar.getString("nota"));
}// end cari nomer
// tampilkan komponen bayar
try {
String sql_kom = "select *
from komponen";
ResultSet
res=stmt.executeQuery(sql_kom);
while (res.next()) {
jComboBox1.addItem(res.getString(2));
}
} catch (Exception e) {
}
ada="ya";
}
if(ada=="tidak"){
JOptionPane.showMessageDialog(null, "Data Tidak Ditemukan" ,
"KESALAHAN",JOptionPane.ERROR_MESSAGE);
}
} catch (SQLException ex){
System.err.println("SQLException:"+ex.getMessage());
}
}
private void
prosesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
// simpan ke detail bayar
try {
con =
DriverManager.getConnection(url,"root","");
stmt = con.createStatement();
String sql1 = "insert into
pembayaran(id,nama,nota,komponen,nominal)values('"+id2.getText()+"','"+nama.getText()+"','"+nota.getText()+"','"+jComboBox1.getSelectedItem()+"','"+nominal.getText()+"')";
stmt.executeUpdate(sql1);
// total=total+valueof(jumlah.getText());
nominal.setText("");
cetak_data();
JOptionPane.showMessageDialog(null, "PEMBAYARAN
"+jComboBox1.getSelectedItem()+" BERHASIL",
"PESAN",JOptionPane.INFORMATION_MESSAGE);
// komponen bayar
// tampilkan komponen bayar
try {
String sql_kom = "select
* from komponen";
ResultSet
res=stmt.executeQuery(sql_kom);
jComboBox1.removeAllItems();
while (res.next()) {
jComboBox1.addItem(res.getString(2));
}
} catch (Exception e) {
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "TERJADI KESALAHAN!! HARAP
ULANGI" , "KESALAHAN",JOptionPane.ERROR_MESSAGE);
}
}
private void
selesaiActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String z = jumlah.getText();
try {
con =
DriverManager.getConnection(url,"root","");
stmt = con.createStatement();
String sql_kom = "select
sum(nominal) as j from pembayaran where
nota='"+nota.getText()+"'";
ResultSet res=stmt.executeQuery(sql_kom);
while (res.next()) {
jumlah.setText(""+res.getString("j"));
}
} catch (Exception e) {
}
JOptionPane.showMessageDialog(null,
"TOTAL BAYAR Rp " + z , "PESAN",JOptionPane.INFORMATION_MESSAGE);
}
private void
jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void
cetakActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new
Runnable() {
public void run() {
OPO dialog = new OPO(new
java.awt.Frame(), true);
dialog.addWindowListener(new
java.awt.event.WindowAdapter() {
public void
windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not
modify
private javax.swing.JButton cari;
private javax.swing.JButton cetak;
private javax.swing.JTextField id2;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JLabel jLabel1;
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.JScrollPane
jScrollPane2;
private javax.swing.JTable jTable2;
private javax.swing.JTextField jumlah;
private javax.swing.JTextField nama;
private javax.swing.JTextField nominal;
private javax.swing.JTextField nota;
private javax.swing.JButton proses;
private javax.swing.JButton selesai;
// End of variables declaration
}
report1.jasper
Dalam laporan ini,
akan menampilkan data user yang telah mendaftar.
pembayaran.jasper
Laporan ini berisi
tentang data transaksi yang dilakukan oleh user. Berisi nomor id, nama, nomer
nota, komponen yang dibayar, serta jumlah nominal yang dibayarkan.
Sumber:http://fatikacun.blogspot.co.id/2016/01/contoh-laporan-ujian-akhir-semester.html
Sumber:http://fatikacun.blogspot.co.id/2016/01/contoh-laporan-ujian-akhir-semester.html
No comments:
Post a Comment