Programing Java Data Base - Aplikasi Kasir Motor
Aplikasi Kasir Motor
Assalamu'alikun wr. wb. Pada kali saya akan membuat aplikasi Swing GUI menggunakan data base MySQL dan Netbeans IDE 8.1. Aplikasi ini dibuat agar memudahkan kasir dan pembeli dalam melakukan transaksi pembelian sepeda motor dari menentukan Harga motor dengan sistem cash maupun dengan sistem pembayaran kredit.
- TextField
- ComboBox
- Label
- Button
- Table
- Pertama kita buat data base pada MYSQL seperti dibawah ini.
- Kemudian saya tambahkan ComboBox Ketika sudah memasuan data base ke Netbeans seperti dibawah ini.
- Ini adalah hasil Output Ketika talah dijalankan.
Source Code yang saya gunakan:
#Source code comboBox "type motor"
private void typeActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add
your handling code here:
if(type.getSelectedItem().equals("Aerox")){
typeMotorField.setText("Aerox");
hargaMotorField.setText(""+32000000);
}
if(type.getSelectedItem().equals("N-Max")){
typeMotorField.setText("N-Max");
hargaMotorField.setText(""+30000000);
}
if(type.getSelectedItem().equals("Mio Soul Gt")){
typeMotorField.setText("Mio Soul Gt");
hargaMotorField.setText(""+18000000);
}
if(type.getSelectedItem().equals("Mio m3")){
typeMotorField.setText("Mio M3");
hargaMotorField.setText(""+15000000);
}
if(type.getSelectedItem().equals("Fino")){
typeMotorField.setText("Fino");
hargaMotorField.setText(""+17000000);
}
if(type.getSelectedItem().equals("Xeon")){
typeMotorField.setText("Xeon");
hargaMotorField.setText(""+17500000);
}
}
#Souce code ComboBox "sistem pembayaran"
private void
sistemActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add
your handling code here:
if(sistem.getSelectedItem().equals("Cash")){
sistemPembayaranField.setText("Cash");
}
if(sistem.getSelectedItem().equals("Kredit")){
sistemPembayaranField.setText("Kredit");
}
}
#Source code button "Hitung"
private void
hitungActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add
your handling code here:
tanggalPembelianField.setText(" "+tgl.getSelectedItem()+
"-"+bln.getSelectedItem()+ "-"+thn.getSelectedItem());
int a=
Integer.parseInt(hargaMotorField.getText());
int b=
Integer.parseInt(uangMukaField.getText());
int c=
Integer.parseInt((String)lamaCicilanField.getText());
int d=a-b;
int hasil=d/c;
sisaBayarField.setText(""+d);
hargaCicilanField.setText(""+hasil);
}
#Source code ComboBox Lama cicilan"LamaCicilan"
private void
lamaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add
your handling code here:
if(lama.getSelectedItem().equals("12")){
lamaCicilanField.setText(""+12);
}
if(lama.getSelectedItem().equals("24")){
lamaCicilanField.setText(""+24);
}
if(lama.getSelectedItem().equals("36")){
lamaCicilanField.setText(""+36);
}
}
#Ini adalah Variable yang saya gunakan:
// Variables
declaration - do not modify
private
javax.swing.JComboBox<String> bln;
private
javax.swing.JButton deleteButton;
private
javax.persistence.EntityManager entityManager;
private
javax.swing.JTextField hargaCicilanField;
private
javax.swing.JLabel hargaCicilanLabel;
private
javax.swing.JTextField hargaMotorField;
private
javax.swing.JLabel hargaMotorLabel;
private
javax.swing.JButton hitung;
private
javax.swing.JComboBox<String> lama;
private javax.swing.JTextField
lamaCicilanField;
private
javax.swing.JLabel lamaCicilanLabel;
private
java.util.List<semester2.Uasdata> list;
private
javax.swing.JScrollPane masterScrollPane;
private
javax.swing.JTable masterTable;
private
javax.swing.JTextField namaPembeliField;
private
javax.swing.JLabel namaPembeliLabel;
private
javax.swing.JButton newButton;
private
javax.persistence.Query query;
private
javax.swing.JButton refreshButton;
private
javax.swing.JButton saveButton;
private
javax.swing.JTextField sisaBayarField;
private
javax.swing.JLabel sisaBayarLabel;
private
javax.swing.JComboBox<String> sistem;
private
javax.swing.JTextField sistemPembayaranField;
private
javax.swing.JLabel sistemPembayaranLabel;
private
javax.swing.JTextField tanggalPembelianField;
private
javax.swing.JLabel tanggalPembelianLabel;
private
javax.swing.JComboBox<String> tgl;
private
javax.swing.JComboBox<String> thn;
private
javax.swing.JComboBox<String> type;
private
javax.swing.JTextField typeMotorField;
private
javax.swing.JLabel typeMotorLabel;
private
javax.swing.JTextField uangMukaField;
private
javax.swing.JLabel uangMukaLabel;
private
org.jdesktop.beansbinding.BindingGroup bindingGroup;
Komentar
Posting Komentar