Vous êtes sur la page 1sur 67

LAMPIRAN

A. LISTING PROGRAM

1. KONEKSI DATABASE

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Properties;

public class DBConnection {


public static String URL, USER, PASSWORD, TITLE, PICTURE, CLASS;
public static Properties siswaprops = new Properties();

public static Connection conn = null;


public PreparedStatement ps = null;

public DBConnection()
{
URL = "jdbc:mysql://localhost/psd_obat";
USER ="root";
PASSWORD ="";
PICTURE = "Icon/Loading.gif";
CLASS = "com.mysql.jdbc.Driver";
TITLE = "Sistem Informasi Persediaan Obat";
// CLASS = "sun.jdbc.odbc.JdbcOdbcDriver";//"com.mysql.jdbc.Driver";
}
public void setKoneksi(String url, String username, String password) throws
ClassNotFoundException, SQLException
{
Class.forName(CLASS);
conn = DriverManager.getConnection(url, username, password);
// JOptionPane.showMessageDialog(null, "Connection Succes");
}

2. MENU UTAMA

import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JInternalFrame;
import java.sql.*;
import java.beans.*;
import javax.swing.UIManager;
import javax.swing.JOptionPane;
import java.awt.*;
import javax.swing.*;
import java.awt.Dimension;
import java.text.*;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.net.URL;
import javax.swing.table.*;

public class MdiForm extends javax.swing.JFrame {


public static ResultSet rs;
static DBConnection DB = new DBConnection();
static Connection Connect;
public static String SQL;
static java.sql.Statement stat;
static String useractive;
static JLabel User = new JLabel();
static boolean log = false;
private ProcessBuilder pb=null;
static Frame fr;
final TrayIcon trayIcon = new TrayIcon(createImage("Icon/Kelas.png", "tray
icon"));
final static SystemTray tray = SystemTray.getSystemTray();

/** Creates new form MdiForm */


public MdiForm(Connection Conn)throws SQLException{
Connect = Conn;
try{
initComponents();
loginfail();
cleardesktop();
Epicture.add(Login);
createTray();
setSize(1024, 740);
setTitle(" .:: Sistem Informasi Persediaan Obat ::.");
}
catch (Exception e)
{
System.out.println("iank"+e);
e.printStackTrace();
}
}
public static void cleardesktop()
{
DesktopPane.removeAll();
Epicture.removeAll();
DesktopPane.repaint();
Epicture.repaint();
ImageIcon img = new
ImageIcon(MdiForm.class.getResource("Icon/Desktop.jpg"));
ImageIcon img1 = new
ImageIcon(MdiForm.class.getResource("Icon/1.gif"));
Epicture.setIcon(img);
Epict2.setIcon(img1);
Epicture.setSize(1012, 627);
Epicture.setLocation(0, 0);
Epicture.setVisible(true);
DesktopPane.add(Epicture);
}
protected static Image createImage(String path, String description) {
URL imageURL = MdiForm.class.getResource(path);

if (imageURL == null) {
System.err.println("Resource not found: " + path);
return null;
} else {
return (new ImageIcon(imageURL, description)).getImage();
}
}

private void jMenuExitActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
int yes = JOptionPane.showConfirmDialog(null, "Apakah Anda Yakin Ingin
Menutup Aplikasi Ini..!\nSimpan Semua Data Sebelum Keluar Dari Aplikasi
Sistem Informasi...!","Close Confirm",JOptionPane.YES_NO_OPTION);
if(yes == JOptionPane.YES_OPTION)
{
System.exit(0);
}
}

private void jMenuCalculatorActionPerformed(java.awt.event.ActionEvent evt)


{
// TODO add your handling code here:
try{
pb = new ProcessBuilder("C:/WINDOWS/system32/calc.exe");
pb.start();
}catch(Exception Se){}
}

private void jMenuNotepadActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
try{
pb = new ProcessBuilder("C:/WINDOWS/system32/notepad.exe");
Process start = pb.start();
}catch(Exception Se){}
}

private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
String laf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
try {
UIManager.setLookAndFeel(laf);
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception excep){}
}

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
String laf =
"com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel";
try {
UIManager.setLookAndFeel(laf);
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception excep){}
}

private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
String laf = "javax.swing.plaf.metal.MetalLookAndFeel";
try {
UIManager.setLookAndFeel(laf);
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception excep){}
}

private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
String laf = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
try {
UIManager.setLookAndFeel(laf);
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception excep){}
}

private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
String laf = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel";
try {
UIManager.setLookAndFeel(laf);
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception excep){}
}

private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
String laf = "com.nilo.plaf.nimrod.NimRODLookAndFeel";
try {
UIManager.setLookAndFeel(laf);
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception excep){}
}

private void jmenuobatActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
try{
cleardesktop();
FSObat ar = new FSObat(Connect);
ar.setVisible(true);
DesktopPane.removeAll();
DesktopPane.add(ar);
}
catch (SQLException e){}
}

private void jMenusupplierActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
try{
cleardesktop();
FSupplier ar = new FSupplier(Connect);
DesktopPane.removeAll();
DesktopPane.add(ar);
ar.setVisible(true);
}
catch(SQLException e){}
}
private void jMenuobat_masukActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:
try{
cleardesktop();
FObatMasuk ar = new FObatMasuk(Connect);
DesktopPane.removeAll();
DesktopPane.add(ar);
ar.setVisible(true);
}
catch(SQLException e){}
}

private void jMenuobat_keluarActionPerformed(java.awt.event.ActionEvent


evt) {
// TODO add your handling code here:
try{
cleardesktop();
FObatKeluar ar = new FObatKeluar(Connect);
DesktopPane.removeAll();
DesktopPane.add(ar);
ar.setVisible(true);
}
catch (SQLException e){}
}

private void EcloseActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
Login.dispose();
}

private void EloginActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
try{
if(Eusername.getText().equalsIgnoreCase(""))
{
JOptionPane.showMessageDialog(null, "Silahkan Entrykan User name
Anda...!","Log In",JOptionPane.INFORMATION_MESSAGE);
Eusername.requestFocus();
}else
if(Epassword.getText().equalsIgnoreCase(""))
{
JOptionPane.showMessageDialog(null, "Silahkan Entrykan Password
Anda...!","Log In",JOptionPane.INFORMATION_MESSAGE);
Epassword.requestFocus();
}else
{
try{
stat =
Connect.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.C
ONCUR_READ_ONLY);
rs = stat.executeQuery("Select * From tuser Where Username
='"+Eusername.getText()+"' AND Status ='Actived' AND VALIDATION
='"+cbvalidation.getSelectedItem().toString()+"'");
if(rs.next()){
SQL = "Select * From tuser Where Username
='"+Eusername.getText().trim()+"' AND Password ='"+Epassword.getText()+"'";
rs = stat.executeQuery(SQL);
boolean found = rs.next();
if(found)
{
Login.dispose();
JOptionPane.showMessageDialog(null, "Login Success..!,
Welcome to Sistem Informasi akademik Sekolah ' "+Eusername.getText()+"
'.","Log In",JOptionPane.INFORMATION_MESSAGE);
User.setText(cbvalidation.getSelectedItem().toString());
loginsucces();
Eusername.setText("");
Epassword.setText("");

}else
{
JOptionPane.showMessageDialog(null, "Login Fail..!, ReLog In
again..!","Log In",JOptionPane.ERROR_MESSAGE);
loginfail();
Eusername.setText("");
Epassword.setText("");
Eusername.requestFocus();
}
}else{
JOptionPane.showMessageDialog(null, "Your Account is Not
Actived, Please Contact your Administrator To Activated your Account..!","User
Not Actived",JOptionPane.ERROR_MESSAGE);
Epassword.setText("");
Eusername.requestFocus();
}
}catch(SQLException e){}
}
}catch(Exception Se){JOptionPane.showMessageDialog(null, Se);}
}

private void Regis1ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:

private void Clear1ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
cleardesktop();
}

private void Log1ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
try{
if(evt.getActionCommand().equalsIgnoreCase("Log In")){
cleardesktop();
Login.setVisible(true);
Login.setLocation(10, 10);
Login.setSize(390, 230);
Eusername.setText("");
Epassword.setText("");
Epicture.add(Login);
Eusername.requestFocus();
}else
if(evt.getActionCommand().equalsIgnoreCase("Log Out")){
int yes = JOptionPane.showConfirmDialog(null, "Are you sure to
Log Off, '"+User.getText()+"'..!","System
Confirmation",JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESS
AGE);
if(yes == JOptionPane.YES_OPTION)
{
try{
cleardesktop();
Login.setVisible(true);
Login.setLocation(10, 10);
Login.setSize(390, 230);
Eusername.setText("");
Epassword.setText("");
Epicture.add(Login);
Eusername.requestFocus();
}catch(Exception lg){}
loginfail();
}
}
}catch(Exception Se){}
}
private void LogiActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

private void EusernameKeyPressed(java.awt.event.KeyEvent evt) {


// TODO add your handling code here:
if(evt.getKeyCode() == 10){
Epassword.requestFocus();
}
}

private void jMenupsdobatActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
LapPsdObat ar = new LapPsdObat();
ar.setLocation(300, 300);
ar.setVisible(true);
}

private void jMenuObaKlrBlnActionPerformed(java.awt.event.ActionEvent


evt) {
LapObtMskhari ar = new LapObtMskhari();
ar.setLocation(300, 300);
ar.setVisible(true); // TODO add your handling code here:

private void jMenuObtMskBlnActionPerformed(java.awt.event.ActionEvent


evt) {
LapObtMskBln ar = new LapObtMskBln();
ar.setLocation(300, 300);
ar.setVisible(true); // TODO add your handling code here:

private void jMenuItem10ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
hide();
}

private void menuItem3ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
show();
}

private void menuItem2ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
hide();
}

private void menuItem1ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
int yes = JOptionPane.showConfirmDialog(null, "Are you sure to Terminate
Sistem Informasi Order Dan Perencanaan Biaya..?","Exit
Confirm",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAG
E);
if(yes == JOptionPane.YES_OPTION){
tray.remove(trayIcon);
System.exit(0);
}else{
show();
}
}

private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {


LapObtKeluarHari ar = new LapObtKeluarHari();
ar.setLocation(300, 300);
ar.setVisible(true); // TODO add your handling code here:
}

private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {


LapObtKeluarBln ar = new LapObtKeluarBln();
ar.setLocation(300, 300);
ar.setVisible(true); // TODO add your handling code here:
}
private void createTray() {
if (!SystemTray.isSupported()) {
System.out.println("SystemTray is not supported");
return;
}

trayIcon.setPopupMenu(Popup);
trayIcon.setImageAutoSize(true);
trayIcon.setToolTip("Sistem Informasi Persediaan Obat");
try {
tray.add(trayIcon);
} catch (AWTException e) {
JOptionPane.showMessageDialog(null, "TrayIcon could not be added...,
System Not support... ?\nPlease, Contact Your Administrator ...","System Tray
Not Support System",JOptionPane.ERROR_MESSAGE);
return;
}
trayIcon.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
show();
// tray.remove(trayIcon);
}
});

trayIcon.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
if(evt.getButton() == MouseEvent.BUTTON1){
trayIcon.displayMessage("Information ... ", "Click Here to Showing
...\nSistem Informasi Absensi Dan Nilai Siswa SMUN 4
Padang",TrayIcon.MessageType.INFO);
}
}
});
trayIcon.displayMessage("Information ... ", "Sistem Informasi Persediaan
Obat",TrayIcon.MessageType.INFO);
}

public void loginsucces()


{
Etsts.setText(" User Name : "+Eusername.getText());
Etsts1.setText(" Validation : "+User.getText());

if(cbvalidation.getModel().getSelectedItem().toString().compareTo("Administrato
r") == 0){

jmenuobat.setEnabled(true);
jMenusupplier.setEnabled(true);

jMenuobat_masuk.setEnabled(true);
jMenuobat_keluar.setEnabled(true);

jMenupsdobat.setEnabled(true);

jMenuObtMskBln.setEnabled(true);
//
jMenuObaKlrBln.setEnabled(true);

}else

if(cbvalidation.getModel().getSelectedItem().toString().compareTo("User") == 0)
{

jmenuobat.setEnabled(false);
jMenusupplier.setEnabled(false);

jMenuobat_masuk.setEnabled(false);
jMenuobat_keluar.setEnabled(false);

jMenupsdobat.setEnabled(false);

jMenuObtMskBln.setEnabled(false);
//
jMenuObaKlrBln.setEnabled(true);

}
}
public void loginfail()
{
//
jmenuobat.setEnabled(false);
jMenusupplier.setEnabled(false);

jMenuobat_masuk.setEnabled(false);
jMenuobat_keluar.setEnabled(false);

jMenupsdobat.setEnabled(false);

jMenuObtMskBln.setEnabled(false);
//
jMenuObaKlrBln.setEnabled(false);

Etsts.setText("Log in Fail, No User To Aktivated..!");


Log1.setText("Log In");
}

public static void main(String args[]) throws SQLException {


try
{

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

DBC.setKoneksi(DBConnection.URL,DBConnection.USER,DBConnection.PAS
SWORD);
//System.out.println(DBC.conn.getCatalog());
Stat = DBC.conn.createStatement();
Rs = Stat.executeQuery("");

}catch (Exception ex)


{
// JOptionPane.showMessageDialog(null,ex.toString(),"Pesan",1);
}
MdiForm Menu = new MdiForm(DBC.conn);
Menu.setVisible(true);
}

// Variables declaration - do not modify


private javax.swing.JMenuItem Clear1;
private static javax.swing.JDesktopPane DesktopPane;
private javax.swing.JButton Eclose;
private javax.swing.JButton Elogin;
private javax.swing.JPasswordField Epassword;
private static javax.swing.JLabel Epict2;
private static javax.swing.JLabel Epicture;
private javax.swing.JLabel Etsts;
private javax.swing.JLabel Etsts1;
private javax.swing.JTextField Eusername;
private javax.swing.JMenuItem Log1;
private javax.swing.JInternalFrame Login;
private java.awt.PopupMenu Popup;
private javax.swing.JMenuItem Regis1;
private javax.swing.JComboBox cbvalidation;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenu jMenu4;
private javax.swing.JMenu jMenu5;
private javax.swing.JMenu jMenu6;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuCalculator;
private javax.swing.JMenuItem jMenuExit;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem10;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JMenuItem jMenuItem6;
private javax.swing.JMenuItem jMenuItem7;
private javax.swing.JMenuItem jMenuItem8;
private javax.swing.JMenuItem jMenuNotepad;
private javax.swing.JMenuItem jMenuObaKlrBln;
private javax.swing.JMenuItem jMenuObtMskBln;
private javax.swing.JMenuItem jMenuobat_keluar;
private javax.swing.JMenuItem jMenuobat_masuk;
private javax.swing.JMenuItem jMenupsdobat;
private javax.swing.JMenuItem jMenusupplier;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JSeparator jSeparator3;
private javax.swing.JSeparator jSeparator4;
private static javax.swing.JMenuItem jmenuobat;
private java.awt.MenuItem menuItem1;
private java.awt.MenuItem menuItem2;
private java.awt.MenuItem menuItem3;
// End of variables declaration
static DBConnection DBC = new DBConnection();
// static Connection Connect;
static java.sql.Statement Stat;
public static ResultSet Rs;
static Dimension d = Toolkit.getDefaultToolkit().getScreenSize();

3. Entry Data Obat

import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.*;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import java.beans.*;
import java.awt.*;
import java.text.NumberFormat;
import javax.swing.*;
import java.util.*;

public class FAddObat extends javax.swing.JDialog {


/** Creates new form FAddSalesman */
public FAddObat(boolean ADD_STATE, JFrame OwnerForm, Connection
Conn, String SQL) {
initComponents();
fs = new Fungsi();
Connect = Conn;

setSize(475, 320);
btnEdit.setEnabled(false);
try
{
stat =
Connect.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.C
ONCUR_READ_ONLY);
}catch(SQLException ex){}

ff = new Fungsi();

setLocation((d.width-465)/2,((d.height-400)/2)-60);
if(ADD_STATE==true){btnSimpan.setText("Tambah");}
else
{
// btnEdit.setEnabled(false);
try
{
rs = stat.executeQuery(SQL);
rs.next();
btnSimpan.setEnabled(false);
btnBatal.setEnabled(false);
btnEdit.setEnabled(true);
txtKode.setEditable(false);

txtKode.setText("" + rs.getString("kd_obat"));
txtNama.setText("" + rs.getString("nm_obat"));
txsatuan.setText("" + rs.getString("satuan"));
txtharga_jual.setText("" + rs.getString("harga"));
tstock.setText("" + rs.getInt("stock"));

txtNama.requestFocus();
}
catch(SQLException sqlEx)
{System.out.println(sqlEx.getMessage());}
}

}
private void txtharga_jualCaretUpdate(javax.swing.event.CaretEvent evt) {
// TODO add your handling code here:
if (txtharga_jual.getText().length()==4)
{
// txtHarga.requestFocus();
}
}

private void btnBatalActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
Hapus();
}

private void txtKodeCaretUpdate(javax.swing.event.CaretEvent evt) {


// TODO add your handling code here:
try
{
rs = stat.executeQuery("select * from obat where
kd_obat='"+txtKode.getText()+"'");
while (rs.next())
{
txtNama.setText("" + rs.getString("nm_obat"));
txsatuan.setText("" + rs.getString("satuan"));;
txtharga_jual.setText("" + rs.getString("harga"));

tstock.setText("" + rs.getInt("stock"));

txtKode.setEditable(false);
txtNama.requestFocus();
btnSimpan.setEnabled(false);
btnEdit.setEnabled(true);
}
}catch (SQLException e){
System.out.println("Salah"+e);
}

private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
try {
stat.executeUpdate("update obat set nm_obat='"+
txtNama.getText()+"',satuan='"+
txsatuan.getText() +"',harga='"+
txtharga.getText() +"',hrg_jual='"+
txtharga_jual.getText() +"',stock='"+
tstock.getText() +"' where kd_obat ='"+txtKode.getText()+"'");

FSObat.reloadRecord("select * FROM obat");


JOptionPane.showMessageDialog(null,"Pengubahan Data telah sukses
disimpan.","Info. Suku_Cadang",JOptionPane.INFORMATION_MESSAGE);
dispose();
} catch(Exception sqlEx) {
JOptionPane.showMessageDialog(null,sqlEx.getMessage(),"Info.
Suku_Cadang",JOptionPane.ERROR_MESSAGE);
System.out.println(sqlEx.getMessage());
}

private void btnSimpanActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
if(ADDING_STATE == true) {
try {
stat.executeUpdate("insert into obat values('"+
txtKode.getText()+"','"+
txtNama.getText()+"','"+
txsatuan.getText() +"','"+
txtharga.getText()+"','"+
txtharga_jual.getText()+"','"+
tstock.getText()+"')");

JOptionPane.showMessageDialog(null,"Record baru telah sukses


disimpan.","Info. obat",JOptionPane.INFORMATION_MESSAGE);
FSObat.reloadRecord("select * FROM obat");
String ObjButtons[] = {"Ya","Tidak"};
int PromptResult = JOptionPane.showOptionDialog(null,"Apakah
Masih Ada Data?","Info.
obat",JOptionPane.DEFAULT_OPTION,JOptionPane.QUESTION_MESSAGE,n
ull,ObjButtons,ObjButtons[0]);
if(PromptResult==0) {
Hapus();
txtKode.requestFocus();
} else{
dispose();
}
} catch(SQLException sqlEx) {
JOptionPane.showMessageDialog(null,"Kode Ini sudah ada yang
menggunakan. Silahkan cari kode yang lain.","Info.
obat",JOptionPane.ERROR_MESSAGE);
System.out.println(sqlEx.getMessage());
}
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


Double hrg,hrgJ,perJ;
hrg = Double.parseDouble(txtharga.getText());
perJ = Double.parseDouble(txtPjual.getText());
// ppn = Double.parseDouble(vPPN.getText());
//hna = ((ppn/100)*hrg)+hrg;
hrgJ = ((perJ/100)*hrg)+hrg;

txtharga_jual.setText(String.valueOf(hrgJ)); // TODO add your handling


code here:
}

public void Hapus()


{
txsatuan.setText("");
txtKode.setText("");
txtNama.setText("");
txtharga.setText("");
txtPjual.setText("");
txtharga_jual.setText("");
tstock.setText("");
tstock.setText("");
btnSimpan.setEnabled(true);
btnEdit.setEnabled(false);
txtKode.setEditable(true);
txtKode.requestFocus();
}

// Variables declaration - do not modify


private javax.swing.JButton btnBatal;
private javax.swing.JButton btnEdit;
private javax.swing.JButton btnSimpan;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
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.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField tstock;
private javax.swing.JTextField txsatuan;
private javax.swing.JTextField txtKode;
private javax.swing.JTextField txtNama;
private javax.swing.JTextField txtPjual;
private javax.swing.JTextField txtharga;
private javax.swing.JTextField txtharga_jual;
// End of variables declaration
public static Fungsi fs;
public static Statement stat;
public static ResultSet rs;
public static String Content[][];
public static int rowNum = 0;
public static int total = 0;
Connection Connect;
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
boolean ADDING_STATE = true;
public static Fungsi ff;

4. Informasi Data Obat

import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.*;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.UIManager;
public class FSObat extends javax.swing.JPanel {

/** Creates new form FSalesman */


public FSObat(Connection Conn) throws SQLException {
initComponents();
Connect = Conn;

stat =
Connect.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.C
ONCUR_READ_ONLY);
SQL = "select * FROM obat";

setSize(1020, 660);
JSP.getViewport().remove(Tabel);
Tabel= CreateTable();
JSP.getViewport().add(Tabel);
Tabel.setGridColor(UIManager.getColor("Button.background"));
Tabel.getTableHeader().setReorderingAllowed(false);
}
private void btnRefreshActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
FSObat.reloadRecord("select * from obat");
}

private void btnCariActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
if (cbKunci.getModel().getSelectedItem().toString().compareTo("Kode
Obat") == 0){
FSObat.reloadRecord("select * from obat where kd_obat like '"+
txtCari.getText() +"%'");
}else
if (cbKunci.getModel().getSelectedItem().toString().compareTo("Nama
Obat") == 0){
FSObat.reloadRecord("select * from obat where kd_obat like '"+
txtCari.getText() +"%'");
}
}

private void txtCariCaretUpdate(javax.swing.event.CaretEvent evt) {


// TODO add your handling code here:
if (cbKunci.getModel().getSelectedItem().toString().compareTo("Kode
Obat") == 0){
FSObat.reloadRecord("select * from obat where kd_obat like '"+
txtCari.getText() +"%'");
}else
if (cbKunci.getModel().getSelectedItem().toString().compareTo("Nama
Obat") == 0){
FSObat.reloadRecord("select * from obat where kd_obat like '"+
txtCari.getText() +"%'");
}
}

private void btnKeluarActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
setVisible(false);
MdiForm.cleardesktop();
//MDIForm.img();
}

private void btnHapusActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
try {
int reply = JOptionPane.showConfirmDialog(this,
"Apakah Data dengan Kode
"+Tabel.getValueAt(Tabel.getSelectedRow(),0)+" Akan Dihapus",
"Info. obat" ,
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE);
// If the confirmation was affirmative, handle exiting.
if (reply == JOptionPane.YES_OPTION) {
try {
stat.executeUpdate("delete from obat where kd_obat =
'"+Tabel.getValueAt(Tabel.getSelectedRow(),0)+"'");
JOptionPane.showMessageDialog(null,"Data dengan Kode
"+Tabel.getValueAt(Tabel.getSelectedRow(),0)+" Sudah Dihapus","Info.
Pelanggan",1);
FSObat.reloadRecord("select * from obat");
}catch (Exception ex){}
}
} catch(Exception e) {}
}

private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:

try {
if(Tabel.getValueAt(Tabel.getSelectedRow(),Tabel.getSelectedColumn()) !
= null) {
JDialog JDEdit = new
FAddObat(false,JFParentFrame,Connect,"SELECT * FROM obat WHERE
kd_obat ='" + Tabel.getValueAt(Tabel.getSelectedRow(),0)+"'");
JDEdit.setTitle("Update Data Obat");
JDEdit.show();
}
} catch(Exception sqlE) {
System.out.println(""+sqlE);
if(sqlE.getMessage() != null){System.out.println(sqlE.getMessage());}
else {
JOptionPane.showMessageDialog(null,"Please select a record in the list
to modify.","Tidak ada Record yang
dipilih",JOptionPane.INFORMATION_MESSAGE);
}

}
}

private void btnTambahActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
JDialog JDAdd = new FAddObat(true,JFParentFrame,Connect,"");
JDAdd.setTitle("Entry Data Obat");
JDAdd.show();
}
public static JTable CreateTable(){
String ColumnHeaderName[] = {"KODE OBAT","NAMA
OBAT","SATUAN", "HARGA","HARGA JUAL","STOCK"};
try{
rs = stat.executeQuery(SQL);
total = 0;
//Move to the last record
rs.afterLast();
//Get the current record position
if(rs.previous())total = rs.getRow();
//Move back to the first record;
rs.beforeFirst();
if(total != 0)
{
Content = new String[total][7];
while(rs.next())
{
Content[rowNum][0] = "" + rs.getString("kd_obat");
Content[rowNum][1] = "" + rs.getString("nm_obat");
Content[rowNum][2] = "" + rs.getString("satuan");
Content[rowNum][3] = "" + rs.getString("harga");
Content[rowNum][4] = "" + rs.getString("hrg_jual");
Content[rowNum][5] = "" + rs.getString("stock");

rowNum++;
}
}
else
{
Content = new String[0][5];
Content[0][0] = "";
Content[0][1] = "";
Content[0][2] = "";
}
}
catch(Exception eE){
// System.out.println("Salah2 = "+eE);
}
JTable NewTable = new JTable (Content,ColumnHeaderName)
{
public boolean isCellEditable (int iRows, int iCols)
{return false;}
};

NewTable.setPreferredScrollableViewportSize(new Dimension(708, 323));

//Start resize the table column


NewTable.getColumnModel().getColumn(0).setMinWidth(0);
NewTable.getColumnModel().getColumn(0).setPreferredWidth(60);
NewTable.getColumnModel().getColumn(1).setPreferredWidth(150);
NewTable.getColumnModel().getColumn(2).setPreferredWidth(80);
NewTable.getColumnModel().getColumn(3).setPreferredWidth(60);
NewTable.getColumnModel().getColumn(4).setPreferredWidth(150);
NewTable.getColumnModel().getColumn(5).setPreferredWidth(100);

//Disposed variables
ColumnHeaderName=null;
Content=null;

rowNum = 0;

return NewTable;
}
public static void reloadRecord(String sSQL)
{
SQL = sSQL;
JSP.getViewport().remove(Tabel);
Tabel= CreateTable();
JSP.getViewport().add(Tabel);
Tabel.setGridColor(UIManager.getColor("Button.background"));
// jpnlMain.repaint();
}

// Variables declaration - do not modify


public static javax.swing.JScrollPane JSP;
public static javax.swing.JTable Tabel;
private javax.swing.JButton btnCari;
private javax.swing.JButton btnEdit;
private javax.swing.JButton btnHapus;
private javax.swing.JButton btnKeluar;
private javax.swing.JButton btnRefresh;
private javax.swing.JButton btnTambah;
private javax.swing.JComboBox cbKunci;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JSplitPane jSplitPane1;
private javax.swing.JTextField txtCari;
// End of variables declaration
public static Statement stat;
public static ResultSet rs;
public static String SQL;
public static String Content[][];
public static int rowNum = 0;
public static int total = 0;
Connection Connect;
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
boolean ADDING_STATE = true;
public static JFrame JFParentFrame;
}

5. Entry Data Supplier

import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.*;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import java.beans.*;
import java.awt.*;
import java.text.NumberFormat;
import javax.swing.*;
import java.util.*;

public class FAddSupplier extends javax.swing.JDialog {

/** Creates new form FAddSalesman */


public FAddSupplier(boolean ADD_STATE, JFrame OwnerForm, Connection
Conn, String SQL) {
initComponents();
fs = new Fungsi();
Connect = Conn;

setSize(465, 245);
btnEdit.setEnabled(false);
try
{
stat =
Connect.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.C
ONCUR_READ_ONLY);
}catch(SQLException ex){}

ff = new Fungsi();

setLocation((d.width-465)/2,((d.height-400)/2)-60);
if(ADD_STATE==true){btnSimpan.setText("Tambah");}
else
{
// btnEdit.setEnabled(false);
try
{
rs = stat.executeQuery(SQL);
rs.next();
btnSimpan.setEnabled(false);
btnBatal.setEnabled(false);
btnEdit.setEnabled(true);
txtKode.setEditable(false);

txtKode.setText("" + rs.getString("kd_sup"));
txtNama.setText("" + rs.getString("nm_sup"));
txtAlamat.setText("" + rs.getString("alamat"));
txtTelp.setText("" + rs.getString("telepon"));
txtNama.requestFocus();
}
catch(SQLException sqlEx)
{System.out.println(sqlEx.getMessage());}
}
}
private void btnBatalActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Hapus();
}

private void txtKodeCaretUpdate(javax.swing.event.CaretEvent evt) {


// TODO add your handling code here:
try
{
rs = stat.executeQuery("select * from supplier where
kd_sup='"+txtKode.getText()+"'");
while (rs.next())
{
txtNama.setText("" + rs.getString("nm_sup"));

txtAlamat.setText("" + rs.getString("alamat"));
txtTelp.setText("" + rs.getString("telepon"));
txtKode.setEditable(false);
txtNama.requestFocus();
btnSimpan.setEnabled(false);
btnEdit.setEnabled(true);
}
}catch (SQLException e){
System.out.println("Salah"+e);
}

private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
try {
stat.executeUpdate("update supplier set nm_sup='"+
txtNama.getText()+"',alamat='"+
txtAlamat.getText() +"',telepon='"+
txtTelp.getText() +"' where kd_sup ='"+txtKode.getText()+"'");
FSupplier.reloadRecord("select * FROM supplier ");
JOptionPane.showMessageDialog(null,"Pengubahan Data telah sukses
disimpan.","Info. supplier ",JOptionPane.INFORMATION_MESSAGE);
dispose();
} catch(Exception sqlEx) {
JOptionPane.showMessageDialog(null,sqlEx.getMessage(),"Info. supplier
",JOptionPane.ERROR_MESSAGE);
System.out.println(sqlEx.getMessage());
}

private void btnSimpanActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
if(ADDING_STATE == true) {
try {
stat.executeUpdate("insert into supplier values('"+
txtKode.getText()+"','"+
txtNama.getText()+"','"+
txtAlamat.getText() +"','"+
txtTelp.getText() +"')");
JOptionPane.showMessageDialog(null,"Record baru telah sukses
disimpan.","Info. supplier ",JOptionPane.INFORMATION_MESSAGE);
FSupplier.reloadRecord("select * FROM supplier ");
String ObjButtons[] = {"Ya","Tidak"};
int PromptResult = JOptionPane.showOptionDialog(null,"Apakah
Masih Ada Data?","Info. supplier
",JOptionPane.DEFAULT_OPTION,JOptionPane.QUESTION_MESSAGE,null,
ObjButtons,ObjButtons[0]);
if(PromptResult==0) {
Hapus();
txtKode.requestFocus();
} else{
dispose();
}
} catch(SQLException sqlEx) {
JOptionPane.showMessageDialog(null,"Kode Ini sudah ada yang
menggunakan. Silahkan cari kode yang lain.","Info.
Pelanggan",JOptionPane.ERROR_MESSAGE);
System.out.println(sqlEx.getMessage());
}
}

public void Hapus()


{
txtAlamat.setText("");
txtKode.setText("");
txtNama.setText("");
txtTelp.setText("");
btnSimpan.setEnabled(true);
btnEdit.setEnabled(false);
txtKode.setEditable(true);
txtKode.requestFocus();
}

// Variables declaration - do not modify


private javax.swing.JButton btnBatal;
private javax.swing.JButton btnEdit;
private javax.swing.JButton btnSimpan;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel9;
private javax.swing.JTextField txtAlamat;
private javax.swing.JTextField txtKode;
private javax.swing.JTextField txtNama;
private javax.swing.JTextField txtTelp;
// End of variables declaration
public static Fungsi fs;
public static Statement stat;
public static ResultSet rs;
public static String Content[][];
public static int rowNum = 0;
public static int total = 0;
Connection Connect;
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
boolean ADDING_STATE = true;
public static Fungsi ff;

6. Informasi Data Supplier

import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.*;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.UIManager;

public class FSupplier extends javax.swing.JPanel {

/** Creates new form FSalesman */


public FSupplier(Connection Conn) throws SQLException {
initComponents();
Connect = Conn;

stat =
Connect.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.C
ONCUR_READ_ONLY);
SQL = "select * FROM supplier ";

setSize(1020, 660);
JSP.getViewport().remove(Tabel);
Tabel= CreateTable();
JSP.getViewport().add(Tabel);
Tabel.setGridColor(UIManager.getColor("Button.background"));
Tabel.getTableHeader().setReorderingAllowed(false);
}

private void btnCariActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
if (cbKunci.getModel().getSelectedItem().toString().compareTo("Kode
Supplier") == 0){
FSupplier.reloadRecord("select * from supplier where kd_sup like '"+
txtCari.getText() +"%'");
}else
if (cbKunci.getModel().getSelectedItem().toString().compareTo("Nama
Supplier ") == 0){
FSupplier.reloadRecord("select * from supplier where nm_sup like '"+
txtCari.getText() +"%'");
}
}

private void txtCariCaretUpdate(javax.swing.event.CaretEvent evt) {


// TODO add your handling code here:
if (cbKunci.getModel().getSelectedItem().toString().compareTo("Kode
supplier ") == 0){
FSupplier.reloadRecord("select * from supplier where kd_sup like '"+
txtCari.getText() +"%'");
}else
if (cbKunci.getModel().getSelectedItem().toString().compareTo("Nama
supplier ") == 0){
FSupplier.reloadRecord("select * from Pelanggan where nm_sup like '"+
txtCari.getText() +"%'");
}
}

private void btnKeluarActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
setVisible(false);
MdiForm.cleardesktop();
// MDIForm.img();
}

private void btnRefreshActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
FSupplier.reloadRecord("select * from supplier ");
}

private void btnHapusActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
try {
int reply = JOptionPane.showConfirmDialog(this,
"Apakah Data dengan Kode
"+Tabel.getValueAt(Tabel.getSelectedRow(),0)+" Akan Dihapus",
"Info. Pelanggan" ,
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE);
// If the confirmation was affirmative, handle exiting.
if (reply == JOptionPane.YES_OPTION) {
try {
stat.executeUpdate("delete from supplier where kd_sup =
'"+Tabel.getValueAt(Tabel.getSelectedRow(),0)+"'");
JOptionPane.showMessageDialog(null,"Data dengan Kode
"+Tabel.getValueAt(Tabel.getSelectedRow(),0)+" Sudah Dihapus","Info.
Pelanggan",1);
FSupplier.reloadRecord("select * from supplier ");
}catch (Exception ex){}
}
} catch(Exception e) {}
}
private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(total != 0)
try
{

if(Tabel.getValueAt(Tabel.getSelectedRow(),Tabel.getSelectedColumn()) != null)
{
JDialog JDEdit = new
FAddSupplier(false,JFParentFrame,Connect,"SELECT * FROM supplier
WHERE kd_sup ='" + Tabel.getValueAt(Tabel.getSelectedRow(),0)+"'");
JDEdit.setTitle("Update Data Supplier");
JDEdit.show();
}
}
catch(Exception sqlE)
{ System.out.println(""+sqlE);
if(sqlE.getMessage() != null){System.out.println(sqlE.getMessage());}
else
{
JOptionPane.showMessageDialog(null,"Please select a record in the
list to modify.","Tidak ada Record yang
dipilih",JOptionPane.INFORMATION_MESSAGE);
}

}
}

private void btnTambahActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
JDialog JDAdd = new FAddSupplier(true,JFParentFrame,Connect,"");
JDAdd.setTitle("Entry Data Pelanggan");
JDAdd.show();
}
public static JTable CreateTable(){
String ColumnHeaderName[] = {"KODE SUPPLIER ","NAMA
SUPPLIER","ALAMAT", "NO. TELP"};
try{
rs = stat.executeQuery(SQL);
total = 0;
//Move to the last record
rs.afterLast();
//Get the current record position
if(rs.previous())total = rs.getRow();
//Move back to the first record;
rs.beforeFirst();
if(total != 0)
{
Content = new String[total][4];
while(rs.next())
{
Content[rowNum][0] = "" + rs.getString("kd_sup");
Content[rowNum][1] = "" + rs.getString("nm_sup");
Content[rowNum][2] = "" + rs.getString("alamat");
Content[rowNum][3] = "" + rs.getString("telepon");
rowNum++;
}
}
else
{
Content = new String[0][5];
Content[0][0] = "";
Content[0][1] = "";
Content[0][2] = "";
}
}
catch(Exception eE){
// System.out.println("Salah2 = "+eE);
}
JTable NewTable = new JTable (Content,ColumnHeaderName)
{
public boolean isCellEditable (int iRows, int iCols)
{return false;}
};

NewTable.setPreferredScrollableViewportSize(new Dimension(708, 323));

//Start resize the table column


NewTable.getColumnModel().getColumn(0).setMinWidth(0);
NewTable.getColumnModel().getColumn(0).setPreferredWidth(60);
NewTable.getColumnModel().getColumn(1).setPreferredWidth(150);
NewTable.getColumnModel().getColumn(2).setPreferredWidth(80);
NewTable.getColumnModel().getColumn(3).setPreferredWidth(100);

//End resize the table column

//Disposed variables
ColumnHeaderName=null;
Content=null;

rowNum = 0;
return NewTable;
}
public static void reloadRecord(String sSQL)
{
SQL = sSQL;
JSP.getViewport().remove(Tabel);
Tabel= CreateTable();
JSP.getViewport().add(Tabel);
Tabel.setGridColor(UIManager.getColor("Button.background"));
// jpnlMain.repaint();
}

// Variables declaration - do not modify


public static javax.swing.JScrollPane JSP;
public static javax.swing.JTable Tabel;
private javax.swing.JButton btnCari;
private javax.swing.JButton btnEdit;
private javax.swing.JButton btnHapus;
private javax.swing.JButton btnKeluar;
private javax.swing.JButton btnRefresh;
private javax.swing.JButton btnTambah;
private javax.swing.JComboBox cbKunci;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JSplitPane jSplitPane1;
private javax.swing.JTextField txtCari;
// End of variables declaration
public static Statement stat;
public static ResultSet rs;
public static String SQL;
public static String Content[][];
public static int rowNum = 0;
public static int total = 0;
Connection Connect;
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
boolean ADDING_STATE = true;
public static JFrame JFParentFrame;
}

7. Entry Obata Masuk


import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.*;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import java.beans.*;
import java.awt.*;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import javax.swing.*;
import java.util.*;

import javax.swing.Timer;
import java.util.Timer.*;
import java.util.Date;
public class Eobatmasuk extends javax.swing.JDialog {

/** Creates new form Eobatmasuk */


public Eobatmasuk(boolean ADD_STATE, JFrame OwnerForm, Connection
Conn, String SQL) {

initComponents();

KDOBAT();
KDSUPP();

fs = new Fungsi();
Connect = Conn;

setSize(745, 500);
btnEdit.setEnabled(false);
try
{
stat =
Connect.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.C
ONCUR_READ_ONLY);
}catch(SQLException ex){}

ff = new Fungsi();
setLocation((d.width-628)/2,((d.height-366)/2)-60);
if(ADD_STATE==true){btnSimpan.setText("Save");}
else
{
// btnEdit.setEnabled(false);
try
{
rs = stat.executeQuery(SQL);
rs.next();
btnSimpan.setEnabled(false);
btnBatal.setEnabled(false);
btnEdit.setEnabled(true);
kd_faktur.setEditable(false);

kd_faktur.setText("" + rs.getString("no_fak"));
txt_tgl.setText("" + rs.getString("tgl_msk"));
txtJml.setText("" + rs.getInt("jml_obtmsk "));
tot.setText("" + rs.getInt("tot_beli"));

cb_kodesup.setSelectedItem("" + rs.getString("kd_sup"));

cb_kodesup.requestFocus();

}
catch(SQLException sqlEx)
{System.out.println(sqlEx.getMessage());}
}
if(ADD_STATE==true){btnSimpan.setText("Save");}
else
{
try
{
rs = stat.executeQuery(SQL);
rs.next();
cb_kodesup.setSelectedItem("" + rs.getString("kd_sup"));
}
catch(SQLException sqlEx)
{System.out.println(sqlEx.getMessage());}
}
if(ADD_STATE==true){btnSimpan.setText("Save");}
else
{
try
{
rs = stat.executeQuery(SQL);
rs.next();
cb_kdobat.setSelectedItem("" + rs.getString("kd_obat"));
}
catch(SQLException sqlEx)
{System.out.println(sqlEx.getMessage());}
}

}
private void btnBatalActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

private void cb_kodesupItemStateChanged(java.awt.event.ItemEvent evt) {


try
{
rs = stat.executeQuery("select * from supplier where kd_sup
='"+cb_kodesup.getSelectedItem()+"'");
if(rs.next())
{
nm_sup.setText(""+rs.getString("nm_sup"));
}
}catch (Exception e){} // TODO add your handling code here:
}

private void btnSimpanActionPerformed(java.awt.event.ActionEvent evt) {


if(ADDING_STATE == true) {

try {
int executeUpdate = stat.executeUpdate("insert into obat_masuk
values('" +
kd_faktur.getText() + "','" +
txt_tgl.getText() + "','" +
cb_kodesup.getSelectedItem().toString() + "','" +
cb_kdobat.getSelectedItem().toString() + "','" +
txtJml.getText() + "','" +
tot.getText() + "')");

int stock;
stock = (Integer.parseInt(tstock.getText()) +
Integer.parseInt(txtJml.getText()));
stat.executeUpdate("update obat set stock = '"+stock+"' where
kd_obat='"+cb_kdobat.getSelectedItem()+"'");

JOptionPane.showMessageDialog(null,"Data Baru Sukses


Disimpan.","Obat Masuk",JOptionPane.INFORMATION_MESSAGE);
FObatMasuk.reloadRecord("select * FROM obat_masuk");
String ObjButtons[] = {"Ya","Tidak"};
int PromptResult = JOptionPane.showOptionDialog(null,"Apakah
Masih Ada Data?","Info.
obat",JOptionPane.DEFAULT_OPTION,JOptionPane.QUESTION_MESSAGE,n
ull,ObjButtons,ObjButtons[0]);
if(PromptResult==0) {
Hapus();
kd_faktur.requestFocus();
} else{
dispose();
}
} catch(SQLException sqlEx) {
JOptionPane.showMessageDialog(null,"Kode Ini sudah ada yang
menggunakan. Silahkan cari kode yang lain.","Info.
obat",JOptionPane.ERROR_MESSAGE);
System.out.println(sqlEx.getMessage());
}
}

// TODO add your handling code here:


}

private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {

try {
stat.executeUpdate("update obat_masuk set tgl_msk='"+
txt_tgl.getText() +"',jml_obtmsk='"+
txtJml.getText() +"',tot_beli='"+
tot.getText() +"' where no_fak ='"+kd_faktur.getText()+"' and kd_sup
='"+cb_kodesup.getSelectedItem()+"' and kd_obat
='"+cb_kdobat.getSelectedItem()+"' ");
FObatMasuk.reloadRecord("select * FROM obat_masuk");
JOptionPane.showMessageDialog(null,"Pengubahan Data telah sukses
disimpan.","Info. Transaksi",JOptionPane.INFORMATION_MESSAGE);
dispose();
} catch(Exception sqlEx) {
JOptionPane.showMessageDialog(null,sqlEx.getMessage(),"Info.
Transaksi",JOptionPane.ERROR_MESSAGE);
System.out.println(sqlEx.getMessage());
}
// TODO add your handling code here:
}

private void cb_kdobatItemStateChanged(java.awt.event.ItemEvent evt) {


try
{
rs = stat.executeQuery("select * from obat where kd_obat
='"+cb_kdobat.getSelectedItem()+"'");
if(rs.next())
{
txtnm_obat.setText(""+rs.getString("nm_obat"));
txsatuan.setText(""+rs.getString("satuan"));
thrg_obat.setText(""+rs.getString("harga"));
tstock.setText(""+rs.getString("stock"));

}
}catch (Exception e){}
// TODO add your handling code here:
}

private void txtJmlKeyPressed(java.awt.event.KeyEvent evt) {


int ascii = evt.getKeyCode();
if (ascii == 10)
{
double total,jmldisk,tb, disk;

total = (Double.parseDouble(thrg_obat.getText()) *
Double.parseDouble(txtJml.getText()));
// jmldisk = total * disk;

// txtJDisc.setText(String.valueOf(jmldisk));
tot.setText(String.valueOf(total));
} // TODO add your handling code here:
}

private void jDateChooser1PropertyChange(java.beans.PropertyChangeEvent


evt) {
if (this.jDateChooser1.getDate() != null) {
SimpleDateFormat format = new
SimpleDateFormat(this.jDateChooser1.getDateFormatString());

this.txt_tgl.setText(format.format(this.jDateChooser1.getDate()));
}
}
public void Hapus()
{
kd_faktur.setText("");
thrg_obat.setText("");
txtJml.setText("");
tot.setText("");
nm_sup.setText("");
txtnm_obat.setText("");
txsatuan.setText("");

cb_kodesup.setSelectedIndex(0);
cb_kdobat.setSelectedIndex(0);

btnSimpan.setEnabled(true);
btnEdit.setEnabled(false);
kd_faktur.setEditable(true);
kd_faktur.requestFocus();
}

public void KDOBAT()


{
cb_kdobat.removeAllItems();
cb_kdobat.addItem("");

try {
Class.forName("com.mysql.jdbc.Driver");
Connection con=
DriverManager.getConnection("jdbc:mysql://localhost/psd_obat","root", "");
java.sql.Statement cari = con.createStatement();
ResultSet rst = cari.executeQuery("select * from obat" );
while (rst.next())
{
String Kodeb = rst.getString("kd_obat");
cb_kdobat.addItem(Kodeb);
}

}catch (Exception e)
{
cb_kdobat.setSelectedItem("");
JOptionPane.showMessageDialog(null,"Ada Kesalahan :
\n"+e,"Error",1);
System.out.println("salah "+e);
}
}
public void KDSUPP()
{
cb_kodesup.removeAllItems();
cb_kodesup.addItem("");

try {
Class.forName("com.mysql.jdbc.Driver");
Connection con=
DriverManager.getConnection("jdbc:mysql://localhost/psd_obat","root", "");
java.sql.Statement cari = con.createStatement();
ResultSet rst = cari.executeQuery("select * from supplier" );
while (rst.next())
{
String Kodeb = rst.getString("kd_sup");
cb_kodesup.addItem(Kodeb);
}

}catch (Exception e)
{
cb_kodesup.setSelectedItem("");
JOptionPane.showMessageDialog(null,"Ada Kesalahan :
\n"+e,"Error",1);
System.out.println("salah "+e);
}
}

// Variables declaration - do not modify


private javax.swing.JButton btnBatal;
private javax.swing.JButton btnEdit;
private javax.swing.JButton btnSimpan;
private javax.swing.JComboBox cb_kdobat;
private javax.swing.JComboBox cb_kodesup;
private com.toedter.calendar.JDateChooser jDateChooser1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
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.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private javax.swing.JPanel jPanel6;
private javax.swing.JPanel jPanel7;
private javax.swing.JTextField kd_faktur;
private javax.swing.JTextField nm_sup;
private javax.swing.JTextField thrg_obat;
private javax.swing.JTextField tot;
private javax.swing.JTextField tstock;
private javax.swing.JTextField txsatuan;
private javax.swing.JTextField txtJml;
private javax.swing.JTextField txt_tgl;
private javax.swing.JTextField txtnm_obat;
// End of variables declaration
public static Fungsi fs;
public static Statement stat;
public static ResultSet rs;
public static String Content[][];
public static int rowNum = 0;
public static int total = 0;
Connection Connect;
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
boolean ADDING_STATE = true;
public static Fungsi ff;
}

8. Informasi Obat Masuk

import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.*;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.UIManager;
public class FObatMasuk extends javax.swing.JPanel {

/** Creates new form FSalesman */


public FObatMasuk(Connection Conn) throws SQLException {
initComponents();
Connect = Conn;

stat =
Connect.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.C
ONCUR_READ_ONLY);
SQL = "select * FROM obat_masuk";

setSize(1020, 660);
JSP.getViewport().remove(Tabel);
Tabel= CreateTable();
JSP.getViewport().add(Tabel);
Tabel.setGridColor(UIManager.getColor("Button.background"));
Tabel.getTableHeader().setReorderingAllowed(false);
}

private void btnCariActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
if (cbKunci.getModel().getSelectedItem().toString().compareTo("No Faktur")
== 0){
FObatMasuk.reloadRecord("select * from obat_masuk where no_fak like '"+
txtCari.getText() +"%'");
}else
if (cbKunci.getModel().getSelectedItem().toString().compareTo("Kode
Supplier") == 0){
FObatMasuk.reloadRecord("select * from obat_masuk where kd_sup like
'"+ txtCari.getText() +"%'");
}else
if (cbKunci.getModel().getSelectedItem().toString().compareTo("Kode Obat")
== 0){
FObatMasuk.reloadRecord("select * from obat_masuk where kd_sup like
'"+ txtCari.getText() +"%'");
}
}

private void txtCariCaretUpdate(javax.swing.event.CaretEvent evt) {


// TODO add your handling code here:
if (cbKunci.getModel().getSelectedItem().toString().compareTo("No Faktur")
== 0){
FObatMasuk.reloadRecord("select * from obat_masuk where no_fak like '"+
txtCari.getText() +"%'");
}else
if (cbKunci.getModel().getSelectedItem().toString().compareTo("Kode
Supplier") == 0){
FObatMasuk.reloadRecord("select * from obat_masuk where kd_sup like
'"+ txtCari.getText() +"%'");
}else
if (cbKunci.getModel().getSelectedItem().toString().compareTo("Kode Obat")
== 0){
FObatMasuk.reloadRecord("select * from obat_masuk where kd_sup like
'"+ txtCari.getText() +"%'");
}
}

private void btnKeluarActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
setVisible(false);
MdiForm.cleardesktop();
// MDIForm.img();
}

private void btnRefreshActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
FObatMasuk.reloadRecord("select * from obat_masuk");
}

private void btnHapusActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
try {
int reply = JOptionPane.showConfirmDialog(this,
"Apakah Data dengan Kode
"+Tabel.getValueAt(Tabel.getSelectedRow(),0)+" Akan Dihapus",
"Info. Transaksi" ,
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE);
// If the confirmation was affirmative, handle exiting.
if (reply == JOptionPane.YES_OPTION) {
try {
stat.executeUpdate("delete from obat_masuk where no_fak =
'"+Tabel.getValueAt(Tabel.getSelectedRow(),0)+"' and kd_sup =
'"+Tabel.getValueAt(Tabel.getSelectedRow(),2)+"' and kd_obat =
'"+Tabel.getValueAt(Tabel.getSelectedRow(),3)+"' ");
JOptionPane.showMessageDialog(null,"Data dengan Kode
"+Tabel.getValueAt(Tabel.getSelectedRow(),0)+" Sudah Dihapus","Info.
Transaksi",1);
FObatMasuk.reloadRecord("select * from obat_masuk");
}catch (Exception ex){}
}
} catch(Exception e) {}
}

private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
if(total != 0)
try
{

if(Tabel.getValueAt(Tabel.getSelectedRow(),Tabel.getSelectedColumn()) != null)
{
JDialog JDEdit = new
Eobatmasuk(false,JFParentFrame,Connect,"SELECT * FROM obat_masuk where
no_fak = '"+Tabel.getValueAt(Tabel.getSelectedRow(),0)+"' and kd_sup =
'"+Tabel.getValueAt(Tabel.getSelectedRow(),2)+"' and kd_obat =
'"+Tabel.getValueAt(Tabel.getSelectedRow(),3)+"' ");
JDEdit.setTitle("Update Data Obat Masuk");
JDEdit.show();
}
}
catch(Exception sqlE)
{ System.out.println(""+sqlE);
if(sqlE.getMessage() != null){System.out.println(sqlE.getMessage());}
else
{
JOptionPane.showMessageDialog(null,"Please select a record in the
list to modify.","Tidak ada Record yang
dipilih",JOptionPane.INFORMATION_MESSAGE);
}

}
}

private void btnTambahActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
JDialog JDAdd = new Eobatmasuk(true,JFParentFrame,Connect,"");
JDAdd.setTitle("Entry Data Obat Masuk");
JDAdd.show();
}
public static JTable CreateTable(){
String ColumnHeaderName[] = {"NO FAKTUR","TGL MASUK","KODE
SUPPLIER","KODE OBAT","JML OBAT","TOTAL"};
try{
rs = stat.executeQuery(SQL);
total = 0;
//Move to the last record
rs.afterLast();
//Get the current record position
if(rs.previous())total = rs.getRow();
//Move back to the first record;
rs.beforeFirst();
if(total != 0)
{
Content = new String[total][9];
while(rs.next())
{
Content[rowNum][0] = "" + rs.getString("no_fak");
Content[rowNum][1] = "" + rs.getString("tgl_msk");
Content[rowNum][2] = "" + rs.getString("kd_sup");
Content[rowNum][3] = "" + rs.getString("kd_obat");
Content[rowNum][4] = "" + rs.getString("jml_obtmsk");
Content[rowNum][5] = "" + rs.getDouble("tot_beli");

rowNum++;
}
}
else
{
Content = new String[0][5];
Content[0][0] = "";
Content[0][1] = "";
Content[0][2] = "";
}
}
catch(Exception eE){
// System.out.println("Salah2 = "+eE);
}
JTable NewTable = new JTable (Content,ColumnHeaderName)
{
public boolean isCellEditable (int iRows, int iCols)
{return false;}
};

NewTable.setPreferredScrollableViewportSize(new Dimension(708, 323));

//Start resize the table column


NewTable.getColumnModel().getColumn(0).setMinWidth(0);
NewTable.getColumnModel().getColumn(0).setPreferredWidth(60);
NewTable.getColumnModel().getColumn(1).setPreferredWidth(150);
NewTable.getColumnModel().getColumn(2).setPreferredWidth(80);
NewTable.getColumnModel().getColumn(3).setPreferredWidth(100);
NewTable.getColumnModel().getColumn(4).setPreferredWidth(140);
NewTable.getColumnModel().getColumn(5).setPreferredWidth(100);

//End resize the table column

//Disposed variables
ColumnHeaderName=null;
Content=null;

rowNum = 0;

return NewTable;
}
public static void reloadRecord(String sSQL)
{
SQL = sSQL;
JSP.getViewport().remove(Tabel);
Tabel= CreateTable();
JSP.getViewport().add(Tabel);
Tabel.setGridColor(UIManager.getColor("Button.background"));
// jpnlMain.repaint();
}

// Variables declaration - do not modify


public static javax.swing.JScrollPane JSP;
public static javax.swing.JTable Tabel;
private javax.swing.JButton btnCari;
private javax.swing.JButton btnEdit;
private javax.swing.JButton btnHapus;
private javax.swing.JButton btnKeluar;
private javax.swing.JButton btnRefresh;
private javax.swing.JButton btnTambah;
private javax.swing.JComboBox cbKunci;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JSplitPane jSplitPane1;
private javax.swing.JTextField txtCari;
// End of variables declaration
public static Statement stat;
public static ResultSet rs;
public static String SQL;
public static String Content[][];
public static int rowNum = 0;
public static int total = 0;
Connection Connect;
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
boolean ADDING_STATE = true;
public static JFrame JFParentFrame;
}

9. Entry Obat Keluar

import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.*;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import java.beans.*;
import java.awt.*;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import javax.swing.*;
import java.util.*;
import javax.swing.Timer;
import java.util.Timer.*;
import java.util.Date;

public class EObatKeluar extends javax.swing.JDialog {

/** Creates new form EObatKeluar */


public EObatKeluar(boolean ADD_STATE, JFrame OwnerForm, Connection
Conn, String SQL) {
initComponents();

KDOBAT();

fs = new Fungsi();
Connect = Conn;

setSize(700, 420);
btnEdit.setEnabled(false);
try
{
stat =
Connect.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.C
ONCUR_READ_ONLY);
}catch(SQLException ex){}

ff = new Fungsi();

setLocation((d.width-628)/2,((d.height-366)/2)-60);
if(ADD_STATE==true){btnSimpan.setText("Save");}
else
{
// btnEdit.setEnabled(false);
try
{
rs = stat.executeQuery(SQL);
rs.next();
btnSimpan.setEnabled(false);
btnBatal.setEnabled(false);
btnEdit.setEnabled(true);
no_dok.setEditable(false);

no_dok.setText("" + rs.getString("no_dok"));
txt_tgl.setText("" + rs.getString("tgl_klr"));
jml_obtklr.setText("" + rs.getInt("jml_obtklr "));
tot_jual.setText("" + rs.getInt("tot_beli"));

}
catch(SQLException sqlEx)
{System.out.println(sqlEx.getMessage());}
}

if(ADD_STATE==true){btnSimpan.setText("Save");}
else
{
try
{
rs = stat.executeQuery(SQL);
rs.next();
cb_kdobat.setSelectedItem("" + rs.getString("kd_obat"));
}
catch(SQLException sqlEx)
{System.out.println(sqlEx.getMessage());}
}

}
private void cb_kdobatItemStateChanged(java.awt.event.ItemEvent evt) {
try {
rs = stat.executeQuery("select * from obat where kd_obat
='"+cb_kdobat.getSelectedItem()+"'");
if(rs.next()) {
txtnm_obat.setText(""+rs.getString("nm_obat"));
txsatuan.setText(""+rs.getString("satuan"));
thrg_obat.setText(""+rs.getString("hrg_jual"));
stock.setText(""+rs.getString("stock"));

}
}catch (Exception e){}
// TODO add your handling code here:
}

private void jml_obtklrKeyPressed(java.awt.event.KeyEvent evt) {


int ascii = evt.getKeyCode();
if (ascii == 10) {
double total,jmldisk,tb, disk;

total = (Double.parseDouble(thrg_obat.getText()) *
Double.parseDouble(jml_obtklr.getText()));
// jmldisk = total * disk;

// txtJDisc.setText(String.valueOf(jmldisk));
tot_jual.setText(String.valueOf(total));
} // TODO add your handling code here:
}

private void btnSimpanActionPerformed(java.awt.event.ActionEvent evt) {


if(ADDING_STATE == true) {

try {
int executeUpdate = stat.executeUpdate("insert into obat_keluar
values('" +
no_dok.getText() + "','" +
txt_tgl.getText() + "','" +
cb_kdobat.getSelectedItem().toString() + "','" +
jml_obtklr.getText() + "','" +
tot_jual.getText() + "')");

int stock;
stock = (Integer.parseInt(this.stock.getText()) -
Integer.parseInt(jml_obtklr.getText()));
stat.executeUpdate("update obat set stock = '"+stock+"' where
kd_obat='"+cb_kdobat.getSelectedItem()+"'");
JOptionPane.showMessageDialog(null,"Data Baru Sukses
Disimpan.","Obat Keluar",JOptionPane.INFORMATION_MESSAGE);
FObatKeluar.reloadRecord("select * FROM obat_keluar");
String ObjButtons[] = {"Ya","Tidak"};
int PromptResult = JOptionPane.showOptionDialog(null,"Apakah
Masih Ada Data?","Info.
obat",JOptionPane.DEFAULT_OPTION,JOptionPane.QUESTION_MESSAGE,n
ull,ObjButtons,ObjButtons[0]);
if(PromptResult==0) {
Hapus();
no_dok.requestFocus();
} else{
dispose();
}
} catch(SQLException sqlEx) {
JOptionPane.showMessageDialog(null,"Kode Ini sudah ada yang
menggunakan. Silahkan cari kode yang lain.","Info.
obat",JOptionPane.ERROR_MESSAGE);
System.out.println(sqlEx.getMessage());
}
}

// TODO add your handling code here:


}

private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {

try {
stat.executeUpdate("update obat_keluar set tgl_klr='"+
txt_tgl.getText() +"',jml_obtklr ='"+
jml_obtklr.getText() +"',tot_jual='"+
tot_jual.getText() +"' where no_dok ='"+no_dok.getText()+"' and
kd_obat ='"+cb_kdobat.getSelectedItem()+"' ");
FObatKeluar.reloadRecord("select * FROM obat_keluar");
JOptionPane.showMessageDialog(null,"Pengubahan Data telah sukses
disimpan.","Info. Transaksi",JOptionPane.INFORMATION_MESSAGE);
dispose();
} catch(Exception sqlEx) {
JOptionPane.showMessageDialog(null,sqlEx.getMessage(),"Info.
Transaksi",JOptionPane.ERROR_MESSAGE);
System.out.println(sqlEx.getMessage());
}
// TODO add your handling code here:
}

private void btnBatalActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
}

private void jDateChooser1PropertyChange(java.beans.PropertyChangeEvent


evt) {
if (this.jDateChooser1.getDate() != null) {
SimpleDateFormat format = new
SimpleDateFormat(this.jDateChooser1.getDateFormatString());

this.txt_tgl.setText(format.format(this.jDateChooser1.getDate()));
}
}

public void Hapus()


{
no_dok.setText("");
thrg_obat.setText("");
jml_obtklr.setText("");
tot_jual.setText("");

txtnm_obat.setText("");
txsatuan.setText("");
cb_kdobat.setSelectedIndex(0);

btnSimpan.setEnabled(true);
btnEdit.setEnabled(false);
no_dok.setEditable(true);
no_dok.requestFocus();
}

public void KDOBAT()


{
cb_kdobat.removeAllItems();
cb_kdobat.addItem("");

try {
Class.forName("com.mysql.jdbc.Driver");
Connection con=
DriverManager.getConnection("jdbc:mysql://localhost/psd_obat","root", "");
java.sql.Statement cari = con.createStatement();
ResultSet rst = cari.executeQuery("select * from obat" );
while (rst.next())
{
String Kodeb = rst.getString("kd_obat");
cb_kdobat.addItem(Kodeb);
}

}catch (Exception e)
{
cb_kdobat.setSelectedItem("");
JOptionPane.showMessageDialog(null,"Ada Kesalahan :
\n"+e,"Error",1);
System.out.println("salah "+e);
}
}

// Variables declaration - do not modify


private javax.swing.JButton btnBatal;
private javax.swing.JButton btnEdit;
private javax.swing.JButton btnSimpan;
private javax.swing.JComboBox cb_kdobat;
private com.toedter.calendar.JDateChooser jDateChooser1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel6;
private javax.swing.JPanel jPanel7;
private javax.swing.JTextField jml_obtklr;
private javax.swing.JTextField no_dok;
private javax.swing.JTextField stock;
private javax.swing.JTextField thrg_obat;
private javax.swing.JTextField tot_jual;
private javax.swing.JTextField txsatuan;
private javax.swing.JTextField txt_tgl;
private javax.swing.JTextField txtnm_obat;
// End of variables declaration
public static Fungsi fs;
public static Statement stat;
public static ResultSet rs;
public static String Content[][];
public static int rowNum = 0;
public static int total = 0;
Connection Connect;
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
boolean ADDING_STATE = true;
public static Fungsi ff;
}

10. Informasi Obat Keluar

import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.*;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.UIManager;

public class FObatKeluar extends javax.swing.JPanel {

/** Creates new form FSalesman */


public FObatKeluar(Connection Conn) throws SQLException {
initComponents();
Connect = Conn;
stat =
Connect.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.C
ONCUR_READ_ONLY);
SQL = "select * FROM obat_keluar";

setSize(1020, 660);
JSP.getViewport().remove(Tabel);
Tabel= CreateTable();
JSP.getViewport().add(Tabel);
Tabel.setGridColor(UIManager.getColor("Button.background"));
Tabel.getTableHeader().setReorderingAllowed(false);
}

private void btnCariActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
if (cbKunci.getModel().getSelectedItem().toString().compareTo("No Faktur")
== 0){
FObatKeluar.reloadRecord("select * from obat_keluar where no_dok like
'"+ txtCari.getText() +"%'");
}else
if (cbKunci.getModel().getSelectedItem().toString().compareTo("Kode Obat")
== 0){
FObatKeluar.reloadRecord("select * from obat_keluar where kd_obat like
'"+ txtCari.getText() +"%'");
}
}

private void txtCariCaretUpdate(javax.swing.event.CaretEvent evt) {


// TODO add your handling code here:
if (cbKunci.getModel().getSelectedItem().toString().compareTo("No Faktur")
== 0){
FObatKeluar.reloadRecord("select * from obat_keluar where no_dok like
'"+ txtCari.getText() +"%'");
}else
if (cbKunci.getModel().getSelectedItem().toString().compareTo("Kode Obat")
== 0){
FObatKeluar.reloadRecord("select * from obat_keluar where kd_obat like
'"+ txtCari.getText() +"%'");
}
}

private void btnKeluarActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
setVisible(false);
MdiForm.cleardesktop();
// MDIForm.img();
}

private void btnRefreshActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
FObatMasuk.reloadRecord("select * from obat_keluar");
}

private void btnHapusActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
try {
int reply = JOptionPane.showConfirmDialog(this,
"Apakah Data dengan Kode
"+Tabel.getValueAt(Tabel.getSelectedRow(),0)+" Akan Dihapus",
"Info. Transaksi" ,
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE);
// If the confirmation was affirmative, handle exiting.
if (reply == JOptionPane.YES_OPTION) {
try {
stat.executeUpdate("delete from obat_keluar where no_dok =
'"+Tabel.getValueAt(Tabel.getSelectedRow(),0)+"' and kd_obat =
'"+Tabel.getValueAt(Tabel.getSelectedRow(),2)+"' ");
JOptionPane.showMessageDialog(null,"Data dengan Kode
"+Tabel.getValueAt(Tabel.getSelectedRow(),0)+" Sudah Dihapus","Info.
Transaksi",1);
FObatKeluar.reloadRecord("select * from obat_keluar");
}catch (Exception ex){}
}
} catch(Exception e) {}
}

private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
if(total != 0)
try
{

if(Tabel.getValueAt(Tabel.getSelectedRow(),Tabel.getSelectedColumn()) != null)
{
JDialog JDEdit = new
EObatKeluar(false,JFParentFrame,Connect,"SELECT * FROM obat_keluar
where no_dok = '"+Tabel.getValueAt(Tabel.getSelectedRow(),0)+"' and kd_obat =
'"+Tabel.getValueAt(Tabel.getSelectedRow(),2)+"' ");
JDEdit.setTitle("Update Data Obat Keluar");
JDEdit.show();
}
}
catch(Exception sqlE)
{ System.out.println(""+sqlE);
if(sqlE.getMessage() != null){System.out.println(sqlE.getMessage());}
else
{
JOptionPane.showMessageDialog(null,"Please select a record in the
list to modify.","Tidak ada Record yang
dipilih",JOptionPane.INFORMATION_MESSAGE);
}

}
}

private void btnTambahActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
JDialog JDAdd = new EObatKeluar(true,JFParentFrame,Connect,"");
JDAdd.setTitle("Entry Data Obat Keluar");
JDAdd.show();
}
public static JTable CreateTable(){
String ColumnHeaderName[] = {"NO FAKTUR","TGL KELUAR","KODE
OBAT","JML OBAT","TOTAL"};
try{
rs = stat.executeQuery(SQL);
total = 0;
//Move to the last record
rs.afterLast();
//Get the current record position
if(rs.previous())total = rs.getRow();
//Move back to the first record;
rs.beforeFirst();
if(total != 0)
{
Content = new String[total][9];
while(rs.next())
{
Content[rowNum][0] = "" + rs.getString("no_dok");
Content[rowNum][1] = "" + rs.getString("tgl_klr");
Content[rowNum][2] = "" + rs.getString("kd_obat");
Content[rowNum][3] = "" + rs.getString("jml_obtklr");
Content[rowNum][4] = "" + rs.getDouble("tot_jual");

rowNum++;
}
}
else
{
Content = new String[0][5];
Content[0][0] = "";
Content[0][1] = "";
Content[0][2] = "";
}
}
catch(Exception eE){
// System.out.println("Salah2 = "+eE);
}
JTable NewTable = new JTable (Content,ColumnHeaderName)
{
public boolean isCellEditable (int iRows, int iCols)
{return false;}
};

NewTable.setPreferredScrollableViewportSize(new Dimension(708, 323));

//Start resize the table column


NewTable.getColumnModel().getColumn(0).setMinWidth(0);
NewTable.getColumnModel().getColumn(0).setPreferredWidth(60);
NewTable.getColumnModel().getColumn(1).setPreferredWidth(150);
NewTable.getColumnModel().getColumn(2).setPreferredWidth(80);
NewTable.getColumnModel().getColumn(3).setPreferredWidth(100);
NewTable.getColumnModel().getColumn(4).setPreferredWidth(140);

//End resize the table column

//Disposed variables
ColumnHeaderName=null;
Content=null;

rowNum = 0;

return NewTable;
}
public static void reloadRecord(String sSQL)
{
SQL = sSQL;
JSP.getViewport().remove(Tabel);
Tabel= CreateTable();
JSP.getViewport().add(Tabel);
Tabel.setGridColor(UIManager.getColor("Button.background"));
// jpnlMain.repaint();
}

// Variables declaration - do not modify


public static javax.swing.JScrollPane JSP;
public static javax.swing.JTable Tabel;
private javax.swing.JButton btnCari;
private javax.swing.JButton btnEdit;
private javax.swing.JButton btnHapus;
private javax.swing.JButton btnKeluar;
private javax.swing.JButton btnRefresh;
private javax.swing.JButton btnTambah;
private javax.swing.JComboBox cbKunci;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JSplitPane jSplitPane1;
private javax.swing.JTextField txtCari;
// End of variables declaration
public static Statement stat;
public static ResultSet rs;
public static String SQL;
public static String Content[][];
public static int rowNum = 0;
public static int total = 0;
Connection Connect;
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
boolean ADDING_STATE = true;
public static JFrame JFParentFrame;
}

11. Laporan Persediaan Obat

import java.util.HashMap;
import javax.swing.JOptionPane;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.view.JasperViewer;
/**
*
* @author Locozters-X
*/
public class LapPsdObat extends javax.swing.JFrame {

/** Creates new form LapPsdObat */


public LapPsdObat() {
initComponents();
setSize(400, 320);
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
String path0;
HashMap map=new HashMap();
map.put("Pimpinan", txpimpinan.getText());
path0=System.getProperty("user.dir")+"/src/Laporan/LapPsdObat.jrxml";
JasperReport report=JasperCompileManager.compileReport(path0);
JasperPrint jprint=JasperFillManager.fillReport(report, map,
DBConnection.conn);
this.setVisible(false);
JasperViewer.viewReport(jprint, false);
} catch (Exception ex) {
JOptionPane.showMessageDialog(rootPane, ex.getMessage());
} // TODO add your handling code here:
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


this.dispose(); // 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() {
new LapPsdObat().setVisible(true);
}
});
}

// Variables declaration - do not modify


private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JTextField txpimpinan;
// End of variables declaration

12. Laporan Obat Masuk Per Hari

import java.text.SimpleDateFormat;
import java.util.HashMap;
import javax.swing.JOptionPane;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.view.JasperViewer;

public class LapObtMskhari extends javax.swing.JFrame {

/** Creates new form LapPsdObat */


public LapObtMskhari() {
initComponents();
setSize(400, 320);
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
try {
String path0;
HashMap map=new HashMap();
map.put("Tanggal", tanggal.getText());
map.put("Pimpinan", txpimpinan.getText());
path0=System.getProperty("user.dir")+"/src/Laporan/ObtMskHari.jrxml";
JasperReport report=JasperCompileManager.compileReport(path0);
JasperPrint jprint=JasperFillManager.fillReport(report, map,
DBConnection.conn);
this.setVisible(false);
JasperViewer.viewReport(jprint, false);
} catch (Exception ex) {
JOptionPane.showMessageDialog(rootPane, ex.getMessage());
} // TODO add your handling code here:
}
private void jDateChooser1PropertyChange(java.beans.PropertyChangeEvent
evt) {
if (this.jDateChooser1.getDate() != null) {
SimpleDateFormat format = new
SimpleDateFormat(this.jDateChooser1.getDateFormatString());

this.tanggal.setText(format.format(this.jDateChooser1.getDate()));
}
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


this.dispose(); // 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() {
new LapPsdObat().setVisible(true);
}
});
}

// Variables declaration - do not modify


private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private com.toedter.calendar.JDateChooser jDateChooser1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JTextField tanggal;
private javax.swing.JTextField txpimpinan;
// End of variables declaration

}
13. Laporan Obat Masuk Per Bulan
import java.util.HashMap;
import javax.swing.JOptionPane;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.view.JasperViewer;
/**
*
* @author Locozters-X
*/
public class LapObtMskBln extends javax.swing.JFrame {

/** Creates new form LapPsdObat */


public LapObtMskBln() {
initComponents();
setSize(400, 320);
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
try {
String path0;
HashMap map=new HashMap();
map.put("bulanan", bln.getText());
map.put("Pimpinan", txpimpinan.getText());
path0=System.getProperty("user.dir")+"/src/Laporan/ObtMskBln.jrxml";
JasperReport report=JasperCompileManager.compileReport(path0);
JasperPrint jprint=JasperFillManager.fillReport(report, map,
DBConnection.conn);
this.setVisible(false);
JasperViewer.viewReport(jprint, false);
} catch (Exception ex) {
JOptionPane.showMessageDialog(rootPane, ex.getMessage());
} // TODO add your handling code here:
}

private void jDateChooser1PropertyChange(java.beans.PropertyChangeEvent


evt) {
if (this.jDateChooser1.getDate() != null) {
SimpleDateFormat format = new
SimpleDateFormat(this.jDateChooser1.getDateFormatString());

this.bln.setText(format.format(this.jDateChooser1.getDate()));
}
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


this.dispose(); // 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() {
new LapPsdObat().setVisible(true);
}
});
}

// Variables declaration - do not modify


private javax.swing.JTextField bln;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private com.toedter.calendar.JDateChooser jDateChooser1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel15;
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.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JTextField txpimpinan;
// End of variables declaration

14. Laporan Obat Keluar Per Hari

import java.text.SimpleDateFormat;
import java.util.HashMap;
import javax.swing.JOptionPane;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.view.JasperViewer;

public class LapObtKeluarHari extends javax.swing.JFrame {

/** Creates new form LapPsdObat */


public LapObtKeluarHari() {
initComponents();
setSize(400, 320);
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
String path0;
HashMap map=new HashMap();
map.put("Tanggal", tgl.getText());
map.put("Pimpinan", txpimpinan.getText());
path0=System.getProperty("user.dir")+"/src/Laporan/ObtKlrHari.jrxml";
JasperReport report=JasperCompileManager.compileReport(path0);
JasperPrint jprint=JasperFillManager.fillReport(report, map,
DBConnection.conn);
this.setVisible(false);
JasperViewer.viewReport(jprint, false);
} catch (Exception ex) {
JOptionPane.showMessageDialog(rootPane, ex.getMessage());
} // TODO add your handling code here:
}

private void jDateChooser1PropertyChange(java.beans.PropertyChangeEvent


evt) {
if (this.jDateChooser1.getDate() != null) {
SimpleDateFormat format = new
SimpleDateFormat(this.jDateChooser1.getDateFormatString());

this.tgl.setText(format.format(this.jDateChooser1.getDate()));
}
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


this.dispose(); // TODO add your handling code here:
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new LapPsdObat().setVisible(true);
}
});
}

// Variables declaration - do not modify


private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private com.toedter.calendar.JDateChooser jDateChooser1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JTextField tgl;
private javax.swing.JTextField txpimpinan;
// End of variables declaration

15. Laporan Obat Keluar Per Hari

import java.text.SimpleDateFormat;
import java.util.HashMap;
import javax.swing.JOptionPane;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.view.JasperViewer;
/**
*
* @author Locozters-X
*/
public class LapObtKeluarBln extends javax.swing.JFrame {

/** Creates new form LapPsdObat */


public LapObtKeluarBln() {
initComponents();
setSize(400, 320);
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
try {
String path0;
HashMap map=new HashMap();
map.put("bulanan", bln.getText());
map.put("Pimpinan", txpimpinan.getText());
path0=System.getProperty("user.dir")
+"/src/Laporan/ObtKeluarBlan.jrxml";
JasperReport report=JasperCompileManager.compileReport(path0);
JasperPrint jprint=JasperFillManager.fillReport(report, map,
DBConnection.conn);
this.setVisible(false);
JasperViewer.viewReport(jprint, false);
} catch (Exception ex) {
JOptionPane.showMessageDialog(rootPane, ex.getMessage());
} // TODO add your handling code here:
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


this.dispose(); // TODO add your handling code here:
}

private void jDateChooser1PropertyChange(java.beans.PropertyChangeEvent


evt) {
if (this.jDateChooser1.getDate() != null) {
SimpleDateFormat format = new
SimpleDateFormat(this.jDateChooser1.getDateFormatString());

this.bln.setText(format.format(this.jDateChooser1.getDate()));
}
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new LapPsdObat().setVisible(true);
}
});
}

// Variables declaration - do not modify


private javax.swing.JTextField bln;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private com.toedter.calendar.JDateChooser jDateChooser1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JTextField txpimpinan;
// End of variables declaration