* @author Labor2
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
public class gajiguru extends javax.swing.JFrame {
private
String q;
private Connection con;
private Statement st;
private ResultSet rs;
/** Creates new form gajiguru */
public gajiguru() {
initComponents();
koneksi();
insert_tabel();
setLocationRelativeTo(null);
this.setExtendedState(MAXIMIZED_BOTH);
}
private void
koneksi(){
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcConnection");
con=DriverManager.getConnection("jdbc:mysql://localhost/db_gajiguru","root","");
st=con.createStatement();
vstatus.setText("ON");
JOptionPane.showMessageDialog(null, "terkoneksi");
} catch (Exception e) {
vstatus.setText("OFF");
}
}
KODING EXIT
this.dispose();
KODING HITUNG
String
gol="";
int
gaji=0,tunj=0,trans=0,pajak=0,gajibersih=0,total=0;
gol=vgol.getText().toString();
if(gol.compareTo("IA")==0)
{
gaji=2000000;
tunj=1000000;
trans=450000;
}else if(gol.compareTo("IB")==0)
{
gaji=2500000;
tunj=500000;
trans=300000;
}else if(gol.compareTo("IC")==0)
{
gaji=3000000;
tunj=300000;
trans=200000;
}
vgaji.setText(String.valueOf(gaji));
vtunjangan.setText(String.valueOf(tunj));
vtransportasi.setText(String.valueOf(trans));
total=gaji+tunj+trans;
vtotal.setText(String.valueOf(total));
pajak=(int)(0.1*total);
vpajak.setText(String.valueOf(pajak));
gajibersih=total-pajak;
vgajibersih.setText(String.valueOf(gajibersih));
KODING CANCEL
vnama.setText("");
vgol.setText("");
vgaji.setText("");
vtunjangan.setText("");
vtransportasi.setText("");
vtotal.setText("");
vpajak.setText("");
vgajibersih.setText("");
KODING PADA COMBO
NIP
int kode=0;
kode=vnip.getSelectedIndex();
kode++;
if (kode==1){
vnama.setText("emsa nurjannah");
vgol.setText("IA");
} else if (kode==2){
vnama.setText("oknanda");
vgol.setText("IB");
} else if (kode==3){
vnama.setText("defrianto");
vgol.setText("IC");
}
KODING SIMPAN
try {
q="insert into gaji_guru values
(' "+vnip.getSelectedItem()+" ',' "+vnama.getText()+" ',' "+vgol.getText()+"','"+vgaji.getText()+"','"+vtunjangan.getText()+"','"+vtransportasi.getText()+"','"+vtotal
.getText()+"','"+vpajak.getText()+"','"+vgajibersih.getText()+"')";
st.execute(q);
JOptionPane.showMessageDialog(null,"data telah disimpan");
insert_tabel();
} catch (Exception e) {
JOptionPane.showMessageDialog(null,e.getMessage());
}
KODING EDIT
try {
st.executeUpdate("update
gaji_guru set
nama='"+vnama.getText()+"',gol='"+vgol.getText()+"',gaji_pokok='"+vgaji.getText()+"',tunjangan='"+vtunjangan.getText()+"',transfortasi='"+vtransportasi.getText()+"',total='"+vtotal.getText()+"',pajak='"+vpajak.getText()+"',gaji_bersih='"+vgajibersih.getText()+"'where
nip='"+vnip.getSelectedItem()+"'");
JOptionPane.showMessageDialog(rootPane,"Update
berhasil.....");
insert_tabel();
} catch (Exception e) {
JOptionPane.showMessageDialog(rootPane,"Update
gagal.......!!!"+e);
}
KODING
HAPUS
try {
st.executeUpdate("delete from
gaji_guru where nip='"+vnip.getSelectedItem()+"'");
JOptionPane.showMessageDialog(rootPane,"Delete berhasil.....SARI
horeeee");
insert_tabel();
} catch (Exception e) {
JOptionPane.showMessageDialog(rootPane,"Delete
gagal.......!!!"+e);
}
KODING
TABEL
public void insert_tabel(){
DefaultTableModel tbl= new
DefaultTableModel();
tbl.addColumn("NIP");
tbl.addColumn("NAMA");
tbl.addColumn("GOL");
tbl.addColumn("GAJI POKOK");
tbl.addColumn("TUNJANGAN");
tbl.addColumn("TRANSPORTASI");
tbl.addColumn("TOTAL");
tbl.addColumn("PAJAK");
tbl.addColumn("GAJI BERSIH");
try {
int nomor= 1 ;
q="select * from
gaji_guru";
st=con.createStatement();
rs=st.executeQuery(q);
while (rs.next()){
tbl.addRow(new Object[]{
rs.getString("nip"),
rs.getString("nama"),
rs.getString("gol"),
rs.getString("gaji_pokok"),
rs.getString("tunjangan"),
rs.getString("transfortasi"),
rs.getString("total"),
rs.getString("pajak"),
rs.getString("gaji_bersih")});
}
tabel.setModel(tbl);
} catch (Exception e) {
JOptionPane.showMessageDialog(null,
e);
}
}
KODING
PEMANGGILAN PADA NIP
try {
q="select * from buku where
kode_buku='"+vkode.getText()+"'";
st=con.createStatement();
rs=st.executeQuery(q);
if (rs.next()) {
vjudul.setText(rs.getString(2));
vjenis.setText(rs.getString(3));
}
} catch (Exception e) {
}
import
com.inet.viewer.SwingReportViewer;
import
com.inet.viewer.URLRenderData;
import java.awt.BorderLayout;
import java.awt.Toolkit;
import javax.swing.JDialog;
public
class lap_gajiguru extends javax.swing.JFrame {
/** Creates new form lap_gajiguru */
public lap_gajiguru() {
initComponents();
setLocationRelativeTo(null);
this.setExtendedState(MAXIMIZED_BOTH);
}
KODING CETAK
try {
JDialog window =new JDialog(this,
"PRINT PREVIEW");
window.setSize(Toolkit.getDefaultToolkit().getScreenSize());
SwingReportViewer viewer=new
SwingReportViewer();
URLRenderData
renderData = new URLRenderData( "http://localhost:9000/?report=file:"+
System.getProperty("user.dir")+"/src/laporan/lap_gajiguru.rpt&prompt0="+vpimpinan.getText()+
"&prompt1="+vbagian_gaji.getText());
viewer.addNewReportView(renderData);
window.getContentPane().add(BorderLayout.CENTER,viewer);
window.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
terima kasihh. . . . :D
Tidak ada komentar:
Posting Komentar