public Nota() {
initComponents();
kosong();
aktif();
autonumber();
}
2. Method Aktif
protected void aktif(){
txtqty.requestFocus();
jtgl.setEditor(new JSpinner.DateEditor(jtgl,"yyyy/MM/dd"));
Object[] Baris ={"KD Barang","Nama","Harga Beli","Harga Jual","QTY","Total"};
tabmode = new DefaultTableModel(null, Baris);
tbltransaksi.setModel(tabmode);
3. Method Kosong
protected void kosong(){
txtid.setText("");
txtnm.setText("");
txtalmt.setText("");
txtkdbrg.setText("");
txtnmbrg.setText("");
txthb.setText("");
txthj.setText("");
txtqty.setText("");
txttotal.setText("");
}
4. Method Auto Number
if(AN<10)
{Nol = "000";}
else if(AN<100)
{Nol = "00";}
else if(AN<1000)
{Nol = "0";}
else if(AN<10000)
{Nol = "";}
5. Method itemTerpilih
public void itemTerpilih(){
popuppelanggan Pp = new popuppelanggan();
Pp.plgn = this;
txtid.setText(id);
txtnm.setText(nama);
txtalmt.setText(almt);
}
public popuppelanggan() {
initComponents();
datatable();
}
2. Datatable dan Cari
protected void datatable(){
Object[] Baris ={"ID Pelanggan","Nama","Jenis Kelamin","No. Telepon","Alamat"};
tabmode = new DefaultTableModel(null, Baris);
String cariitem=txtcari.getText();
try {
String sql = "SELECT * FROM pelanggan where id like '%"+cariitem+"%' or nmplgn
like '%"+cariitem+"%' order by id asc";
Statement stat = conn.createStatement();
ResultSet hasil = stat.executeQuery(sql);
while (hasil.next()){
tabmode.addRow(new Object[]{
hasil.getString(1),
hasil.getString(2),
hasil.getString(3),
hasil.getString(4),
hasil.getString(5)
});
}
tblplgn.setModel(tabmode);
} catch (Exception e){
JOptionPane.showMessageDialog(null, "data gagal dipanggil"+e);
}
}
4. Tombol Cari
private void bcariActionPerformed(java.awt.event.ActionEvent evt) {
datatable();
}