0% found this document useful (0 votes)
91 views8 pages

Membuat Form Nota - Pop Up Pelanggan

1. The document discusses setting up a form for sales notes in Java, including importing necessary libraries, creating methods for initializing fields, searching for customers, and generating automatic numbering for notes. 2. It also covers creating a pop-up window to search and select customer data, with methods to load and search the customer table, capture the selected customer's details, and close the pop-up window. 3. Key aspects covered include using JSpinner to set the date format, populating JTables with SQL data, handling click and search events to update fields and filter records between the main form and pop-up windows.

Uploaded by

Lilis Febriani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views8 pages

Membuat Form Nota - Pop Up Pelanggan

1. The document discusses setting up a form for sales notes in Java, including importing necessary libraries, creating methods for initializing fields, searching for customers, and generating automatic numbering for notes. 2. It also covers creating a pop-up window to search and select customer data, with methods to load and search the customer table, capture the selected customer's details, and close the pop-up window. 3. Key aspects covered include using JSpinner to set the date format, populating JTables with SQL data, handling click and search events to update fields and filter records between the main form and pop-up windows.

Uploaded by

Lilis Febriani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Desain Tampilan Pada Form Nota

JSpinner Setting

Properties -> Pilih Model (…)


1. Import dan Method Pop Up Pelanggan
package penjualan;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.JSpinner;
import koneksi.koneksi;

public class Nota extends javax.swing.JFrame {


public String id, nama, jenis, telp, almt;
public String kdbrg, nmbrg, jenisbrg, hb, hj;
private Connection conn = new koneksi().connect();
private DefaultTableModel tabmode;
Object[] Baris ={"KD Barang","Nama","Harga Beli","Harga Jual","QTY","Total"};

public Nota() {
initComponents();
kosong();
aktif();
autonumber();
}

2. Method Aktif
protected void aktif(){
txtqty.requestFocus();
jtgl.setEditor(new JSpinner.DateEditor(jtgl,"dd/MM/yyyy"));
tabmode = new DefaultTableModel(null, Baris);
tbltransaksi.setModel(tabmode);
txtidnota.setEnabled(false);
}
3. Method Kosong
protected void kosong(){
txtid.setText("");
txtnm.setText("");
txtalmt.setText("");
txtkdbrg.setText("");
txtnmbrg.setText("");
txthb.setText("");
txthj.setText("");
txtqty.setText("");
txttotal.setText("");
txtttotal.setText("");
tbltransaksi.removeAll();
}

4. Method Autonumber
protected void autonumber(){
try{
String sql = "SELECT idnota FROM nota order by idnota asc";
Statement stat = conn.createStatement();
ResultSet rs=stat.executeQuery(sql);

while(rs.next()){
String idnota = rs.getString("idnota").substring(2);
int nomor = Integer.parseInt(idnota) + 1;
String nol = "";

if (nomor<10)
{nol = "000";}
else if (nomor<100)
{nol = "00";}
else if (nomor<1000)
{nol = "";}

txtidnota.setText("IN" + nol + nomor);


}
}
catch (Exception e){
JOptionPane.showMessageDialog(null,"Penomoran Salah" + e);
}
}

5. Method itemTerpilih
public void itemTerpilih(){
popuppelanggan Pp = new popuppelanggan();
Pp.plgn = this;
txtid.setText(id);
txtnm.setText(nama);
txtalmt.setText(almt);
}

6. Button Cari Pelanggan


private void bcaripActionPerformed(java.awt.event.ActionEvent evt) {
popuppelanggan Pp = new popuppelanggan();
Pp.plgn = this;
Pp.setVisible(true);
Pp.setResizable(false);
}
Membuat Form Pop Up Data Pelanggan

1. Import dan Method Pop Up Pelanggan


package penjualan;
import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import java.awt.event.KeyEvent;
import penjualan.Nota;
import koneksi.koneksi;

public class popuppelanggan extends javax.swing.JFrame {


private Connection conn = new koneksi().connect();
private DefaultTableModel tabmode;

public Nota plgn = null;

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_plgn like '%"+cariitem+"%' or
nm_plgn like '%"+cariitem+"%' order by id_plgn 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);
}
}

3. MouseClicked Pelanggan
private void tblplgnMouseClicked(java.awt.event.MouseEvent evt) {
int tabelPelanggan = tblplgn.getSelectedRow();
plgn.id = tblplgn.getValueAt(tabelPelanggan, 0).toString();
plgn.nama = tblplgn.getValueAt(tabelPelanggan, 1).toString();
plgn.jenis = tblplgn.getValueAt(tabelPelanggan, 2).toString();
plgn.telp = tblplgn.getValueAt(tabelPelanggan, 3).toString();
plgn.almt = tblplgn.getValueAt(tabelPelanggan, 4).toString();
plgn.itemTerpilih();
this.dispose();
}
4. Tombol Cari
private void bcariActionPerformed(java.awt.event.ActionEvent evt) {
datatable();
}

5. KeyPressed Pada Text Field Cari


private void txtcariKeyPressed(java.awt.event.KeyEvent evt) {
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
datatable();
}

You might also like