SINTAK PROGRAM JAVA aplikasi penjualan
/** * Nama File Barang.java
* Program untuk menjalankan Form Barang
* Dipanggil Dari Menu Utama
* APLIKASI PENJUALAN BARANG KOPERASI
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
public class Barang extends JInternalFrame implements ActionListener, FocusListener {
private JPanel jpBarang1 = new JPanel();
private JLabel lblKode_Barang= new JLabel (“Kode Barang
:”),lblNama_Barang = new JLabel (“Nama Barang :”), lblHarga_Beli= new
JLabel (“Harga Beli :”), lblHarga_Jual = new JLabel (“Harga Jual
:”),lblQuantity = new JLabel (“Quantity :”);
private JTextField txtKode_Barang = new JTextField (),
txtNama_Barang = new JTextField (), txtHarga_Beli= new JTextField
(),txtHarga_Jual = new JTextField (),txtQuantity = new JTextField
();
private JButton btnAdd = new JButton (), btnEdit= new JButton
(), btnDelete= new JButton (), btnKosong= new JButton ();Barang () {
/* super(Judul, UkuranFrame, TombolClose, TombolMaksimum, TombolMinimum)*/
super (“Form Barang”, false, true, false, true);setSize (470, 250);jpBarang1.setLayout (null);
/* Mengatur letak objek Label Di container*/
lblKode_Barang.setBounds (15, 20, 100, 25);
lblNama_Barang.setBounds (15, 55, 100, 25);
lblHarga_Beli.setBounds (15, 90, 100, 25);
lblHarga_Jual.setBounds (15, 125, 100, 25);
lblQuantity.setBounds (15, 160, 100, 25);
/* Mengatur letak objek Text Di Container */
txtKode_Barang.setBounds (115, 20, 100, 25);
txtNama_Barang.setBounds (115, 55, 205, 25);
txtHarga_Beli.setBounds (115, 90, 92, 25);
txtHarga_Jual.setBounds (115, 125, 100, 25); txtQuantity.setBounds (115, 160,100,25);
/* Mengatur letak objek Button di Container */
btnAdd.setBounds (340, 20, 85, 25);
btnAdd.setLabel(“Add”);
btnEdit.setBounds (340, 55, 85, 25);
btnEdit.setLabel(“Edit”);
btnDelete.setBounds (340, 90, 85, 25);
btnDelete.setLabel(“Delete”);
btnKosong.setBounds (340, 125, 85, 25);
btnKosong.setLabel(“Bersih”);
/* Mengatur Perataan teks di Text */
txtHarga_Beli.setHorizontalAlignment (JTextField.RIGHT);
txtHarga_Jual.setHorizontalAlignment (JTextField.RIGHT);
txtQuantity.setHorizontalAlignment (JTextField.RIGHT);
/* Objek Button di Non Aktifkan dan di aktifkan */
btnAdd.setEnabled(false);
btnEdit.setEnabled(false);
btnDelete.setEnabled(false);
btnKosong.setEnabled(true);
/* Mengatur objek untuk dapat berinteraksi */
txtKode_Barang.addFocusListener (this);
btnAdd.addActionListener (this);
btnEdit.addActionListener (this);
btnDelete.addActionListener (this);
btnKosong.addActionListener (this);
/* Text Harga_Beli di input hanya bilangan saja pada textfield */
txtHarga_Beli.addKeyListener (new KeyAdapter()
{
public void keyTyped (KeyEvent ke)
{
char c = ke.getKeyChar ();
if (!((Character.isDigit (c) || (c == KeyEvent.VK_BACK_SPACE))))
{
getToolkit().beep (); ke.consume ();
}
}
});
/**
* Nama File Connect.java
* Program untuk menghubungkan database DbInventory dengan Program Java
* Lewat ODBC (Open Database Conectivity) dengan nama DsnDbInventory
* Sistem Informasi Inventory
*/
import java.sql.*;
public class Connect {
public Connect() {
}
public Connection OpenConnect() throws SQLException {
Connection con1 = null;
try {
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
con1=DriverManager.getConnection(“jdbc:odbc:DsnDbInventory”,”",”");
return con1;
}
catch (SQLException se) {
System.out.println(“Perintah SQL Salah!!!”);
return null;
}
catch (Exception ex) {
System.out.println(“Driver Tidak Terhubung!!!”);
return null;
}
}
}
/**
* Nama File Faktur.java
* Program untuk menjalankan Form Barang
* Dipanggil Dari Menu Utama
* APLIKASI PENJUALAN BARANG KOPERAS
*/
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
import java.io.*;
import javax.swing.table.DefaultTableModel;
public class Faktur extends JInternalFrame
{
private JPanel jpFaktur = new JPanel ();
/* Deklarasi Objek Label Ke Form Bagian Transaksi */
private JLabel lblTransaksi = new JLabel (“Transaksi”),
lblRinci = new JLabel (“Rinci Transaksi”),
lblNo_Faktur = new JLabel (“No. Faktur”),
lblKode_Pelanggan = new JLabel (“Kode Pelanggan”),
lblNama_Pelanggan = new JLabel (“Nama Pelanggan”),
lblTgl_Jual = new JLabel (“Tgl. Jual”),
lblPembuat = new JLabel (“Pembuat”),
lblPenerima = new JLabel (“Penerima”),
lblNoSO = new JLabel (“No SO”),
lblFormat_Tgl = new JLabel (“yyyy/mm/dd”);
/* Deklarasi Objek Text Ke Form Bagian Transaksi */
private JTextField txtNo_Faktur = new JTextField (),
txtKode_Pelanggan = new JTextField (),
txtNama_Pelanggan = new JTextField (),
txtTgl_Jual = new JTextField (),
txtPembuat = new JTextField (),
txtPenerima = new JTextField (),
txtNoSO = new JTextField ();
/**
* Nama File SisInven.java
* Program menjalankan ProgressBar
* Memanggil Program Menu Utama
* Sistem Informasi Inventory
*/import java.sql.*;
public class Koneksi {
public Koneksi() {
}
public Connection bukaKoneksi() throws SQLException {
Connection con = null;
try {
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
con=DriverManager.getConnection(“jdbc:odbc:SIP”,”",”");
return con;
}
catch (SQLException se) {
System.out.println(“No Connection Open”);
return null;
}
catch (Exception ex) {
System.out.println(“Cound not open connection”);
return null;
}
}
}
/**
* Nama File Menu_Utama.java
* Program untuk menampilkan Menu Utama
* Menu Utama terdiri dari Menu PullDown, Menu Shortcut (PopUp) dan Menu ToolBar
* APLIKASI PENJUALAN BARANG KOPERASI
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.text.*;
import javax.swing.Timer;
public class Menu_Utama extends JFrame implements ActionListener {
private JDesktopPane desktop1 = new JDesktopPane();
/* Menu Pulldown */
private JMenuBar barMenu1 = new JMenuBar();
private JMenu mnuFileMaster = new JMenu(“File Master”),
mnuFileTransaksi = new JMenu(“File Transaksi”),
mnuReport = new JMenu(“Report”),
mnuExit = new JMenu(“Exit”);
private JMenuItem mnuFMPelanggan = new JMenuItem(“Pelanggan”, new ImageIcon (“”)),
mnuFMBarang = new JMenuItem(“Barang”, new ImageIcon (“”)),
mnuReturn1 = new JMenuItem(“Return”, new ImageIcon (“”)),
mnuFTFaktur = new JMenuItem(“Faktur”, new ImageIcon (“”)),
mnuReturn2 = new JMenuItem(“Return”, new ImageIcon (“”)),
mnuReportBarang = new JMenuItem(“Report Barang”),
mnuReportPelanggan = new JMenuItem(“Report Pelanggan”),
mnuReportFaktur = new JMenuItem(“Report Faktur”), //Revisi
mnuReturn3 = new JMenuItem(“Return”, new ImageIcon (“”)),
mnuExit1 = new JMenuItem(“Exit”, new ImageIcon (“”));
/* Pengaturan Waktu dan Tanggal */
private Date tglsekarang = new Date();
private SimpleDateFormat smpdtfmt = new SimpleDateFormat(“dd MMM yyyy”, Locale.getDefault());
private String tanggal1 = smpdtfmt.format(tglsekarang) ;
/* Pengaturan Status Bar */
private JPanel statusBar1 = new JPanel();
private JLabel lblExit1 =
new JLabel(” ” + “KOPERASI PEGAWAI SMAN 2 KUNINGAN”, JLabel.LEFT),
lblTgl1 = new JLabel(” ” + tanggal1 + ” “, JLabel.RIGHT);
/* Methode Keluar Dari Sistem */
private void Keluar () {
try {
int reply = JOptionPane.showConfirmDialog (this,
“Yakin Mau Keluar ?…Silahkan..”,
“SISTEM INFORMASI PENJUALAN BARANG – BYE”, JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE);
if (reply == JOptionPane.YES_OPTION) {
setVisible (false);
dispose();
System.out.println (“Thank !!!”);
System.out.println (“KOPERASI PEGAWAI SMAN 2 KUNINGAN”);
System.out.println (“\n2009″);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
System.exit (0);
}
}
catch (Exception e) {
}
}
/* Methode Setting Waktu Sistem */
public void setJam() {
ActionListener taskPerformer = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
String nol_jam = “”, nol_menit = “”, nol_detik = “”;
Date dateTime = new Date();
int nilai_jam = dateTime.getHours();
int nilai_menit = dateTime.getMinutes();
int nilai_detik = dateTime.getSeconds();
if (nilai_jam <= 9) nol_jam = “0″;
if (nilai_menit <= 9) nol_menit = “0″;
if (nilai_detik <= 9) nol_detik = “0″;
String jam = nol_jam + Integer.toString(nilai_jam);
String menit = nol_menit + Integer.toString(nilai_menit);
String detik = nol_detik + Integer.toString(nilai_detik);
lblwaktu1.setText(jam + “:” + menit + “:” + detik + ” “);
}
};
new Timer(1000, taskPerformer).start();
}
}
No comments:
Post a Comment