SISTEM INFORMASI GAJI KARYAWAN
NIM
= 13121038
NAMA
= VEGA DWI SURYANI
KELAS
= 21
FAKULTAS TEKNOLOGI INFORMASI PROGRAM STUDI SISTEM INFORMASI UNIVERSITAS MERCU BUANA YOGYAKARTA
DAFTAR ISI
DAFTAR ISI ..................................................................................................................................................... 2 BAB 1 ............................................................................................................................................................. 4 PENDAHULUAN ............................................................................................................................................. 4 A. Latar Belakang ...................................................................................................................................... 4 B. Alasan Pemilihan Masalah .................................................................................................................... 4 BAB II ............................................................................................................................................................. 5 A.
RANCANGAN TABLE .......................................................................................................................... 5
BAB III ............................................................................................................................................................ 7 JDBC .............................................................................................................................................................. 7 TABEL KARYAWAN .................................................................................................................................... 7 Input .......................................................................................................................................................... 7 a.
Update......................................................................................................................................... 10
b.
View ............................................................................................................................................ 11
c.
Delete .......................................................................................................................................... 13
A.
TABEL GAJI ...................................................................................................................................... 16 a.
Input ............................................................................................................................................ 16
b.
Update......................................................................................................................................... 19
c.
View ............................................................................................................................................ 20
d.
Delete .......................................................................................................................................... 22
B.
TABEL ABSEN ................................................................................................................................... 23 a.
Input ............................................................................................................................................ 23
b.
Update......................................................................................................................................... 26
c.
Delete .......................................................................................................................................... 27
d.
View ............................................................................................................................................ 28
BAB IV.......................................................................................................................................................... 31 MENU .......................................................................................................................................................... 31 A.
MENU ................................................................................................. Error! Bookmark not defined. 1.
pengaturan tampilan menu ....................................................................................................... 31
INTEGRASI MENU .................................................................................................................................... 37
A.
Kesimpulan...................................................................................................................................... 42
B.
Kesulitan.......................................................................................................................................... 42
BAB 1 PENDAHULUAN A. Latar Belakang Di dalam perkembangan teknologi yang semakin pesat. Perusahaan-perusahaan semakin berkembang dan persaingan semakin banyak. Perusahaan sekarang masih kesulitan dalam melakukan penggajian karyawan. Dengan aplikasi Sistem Informasi Gaji Karyawan ini pihak perusahaan bisa lebih mudah dalam melakukan penggajian karyawan.
B. Alasan Pemilihan Masalah Oleh karena itu penulis “SISTEM
INFORMASI GAJI KARYAWAN” sebagai judul
pemrograman java kali ini. Semoga sistem ini bisa digunakan oleh perusahaan-perusahaan yang akan melakukan penggajian karyawannya.
BAB II DATABASE A. RANCANGAN TABLE import java.sql.*; class Koneksi { String url,usr,pwd,dbn; public Koneksi() { dbn="java"; url="jdbc:mysql://localhost/"+dbn; usr="root"; pwd=""; } public Connection getConnection() { Connection con=null; try { Class.forName("com.mysql.jdbc.Driver"); con=DriverManager.getConnection(url,usr,pwd); System.out.println("OK: Driver Ditemukan"); } catch ( ClassNotFoundException e) { System.out.println("Error: Driver tidak ditemukan\n" +e+"\n"); System.exit(0); } catch (SQLException e) { System.out.println("Error:tidak bisa koneksi ke database\n" +e+"\n"); System.exit(0); } return con; } public static void main(String[] args) { Koneksi dnd= new Koneksi(); dnd.getConnection(); } }
Salah satu langkah pembuatan tabel dengan java. Tabel-tabel yang lain dibuat dengan menggunakan phpmyadmin.
B. RELASI DATABASE
BAB III JDBC 1. TABEL KARYAWAN Input Source Code import java.awt.event.*; import java.sql.*; import javax.swing.*; class input_karyawan extends JFrame { // DEKLARASI LABEL JLabel labelNIK=new JLabel("NIK"); JTextField textNIK=new JTextField(30); JLabel labelNmKaryawan=new JLabel("Nama Karyawan"); JTextField textNmKaryawan=new JTextField(30); JLabel labelAlamat=new JLabel("Alamat"); JTextField textAlamat=new JTextField(50); JLabel labelJK=new JLabel("Jenis Kelamin"); JButton buttonSAVE=new JButton("SAVE"); JButton buttonEXIT=new JButton("EXIT"); JRadioButton radioPerempuan=new JRadioButton("Perempuan"); JRadioButton radioLaki2=new JRadioButton("Laki-Laki"); ButtonGroup groupJK=new ButtonGroup(); JLabel labelStatus=new JLabel("Status"); String[] GStatus={"Aktif","Tidak Aktif"}; JComboBox comboStatus=new JComboBox(GStatus); JLabel labelBagian=new JLabel("Bagian"); String[] GBagian={"Karyawan","Kasir","OB","Gudang"}; JComboBox comboBagian=new JComboBox(GBagian); input_karyawan() { setTitle("INPUT DATA KARYAWAN"); setLocation(400,200); setSize(400,300); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); } void GUI() { // LABEL getContentPane().setLayout(null); getContentPane().add(labelNIK); labelNIK.setBounds(10,10,70,20); getContentPane().add(textNIK); textNIK.setBounds(80,10,110,20); getContentPane().add(labelNmKaryawan); labelNmKaryawan.setBounds(10,30,70,20); getContentPane().add(textNmKaryawan); textNmKaryawan.setBounds(80,30,110,20); getContentPane().add(labelAlamat); labelAlamat.setBounds(10,50,70,20); getContentPane().add(textAlamat); textAlamat.setBounds(80,50,160,20); getContentPane().add(labelJK); labelJK.setBounds(10,70,70,20);
getContentPane().add(radioPerempuan); radioPerempuan.setBounds(80,70,120,20); getContentPane().add(radioLaki2); radioLaki2.setBounds(180,70,80,20); groupJK.add(radioPerempuan); groupJK.add(radioLaki2); getContentPane().add(labelStatus); labelStatus.setBounds(10,90,70,20); getContentPane().add(comboStatus); comboStatus.setBounds(80,90,100,20); getContentPane().add(labelBagian); labelBagian.setBounds(10,120,90,20); getContentPane().add(comboBagian); comboBagian.setBounds(80,120,100,20); getContentPane().add(buttonSAVE); buttonSAVE.setBounds(60,160,90,20); getContentPane().add(buttonEXIT); buttonEXIT.setBounds(160,160,80,20); setVisible(true); } void perintah() { //button exit buttonEXIT.addActionListener ( new ActionListener() { public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog( null,"Anda Yakin Ingin Keluar?","KONFIRMASI", JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) { System.exit(0); } } } ); //button save buttonSAVE.addActionListener ( new ActionListener() { public void actionPerformed(ActionEvent e) { String NIK, NmKaryawan, Alamat, JK, Status, Bagian; NIK = textNIK.getText(); NmKaryawan = textNmKaryawan.getText(); Alamat = textAlamat.getText(); if (radioPerempuan.isSelected()==true) { JK = radioPerempuan.getText(); } else { JK = radioLaki2.getText(); } Status = (String) comboStatus.getSelectedItem(); Bagian = (String)
comboBagian.getSelectedItem(); //input ke database Koneksi open = new Koneksi(); Connection mysql = open.getConnection(); try { Statement stmt = mysql.createStatement(); String sql = "INSERT INTO t_karyawan VALUES ('"+NIK+"','"+ NmKaryawan+"','"+Alamat+"','"+JK+"','"+Status+"','"+Bagian+"');"; int i =stmt.executeUpdate(sql); if(i==1) { JOptionPane.showMessageDialog(null, "data karyawan berhasil disimpan"); } } catch(Exception ex) { JOptionPane.showMessageDialog(null, ex.getMessage()); } } }); } public static void main(String []args) { input_karyawan inputan = new input_karyawan(); inputan.GUI(); inputan.perintah(); } }
Update
//BUTTON UPDATE buttonUPDATE.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e) { String NIK, NmKaryawan, Alamat, JK, Status, Bagian; NIK = textNIK.getText(); NmKaryawan = textNmKaryawan.getText(); Alamat = textAlamat.getText(); if (radioPerempuan.isSelected()==true) { JK = radioPerempuan.getText(); } else { JK = radioLaki2.getText(); } Status = (String) comboStatus.getSelectedItem(); Bagian = (String) comboBagian.getSelectedItem();
//update ke database Koneksi open = new Koneksi (); Connection mysql = open.getConnection(); try { Statement stmt = mysql.createStatement(); String sql = "UPDATE t_karyawan SET NmKaryawan='"+NmKaryawan +"',Alamat='"+Alamat+"',JK='"+JK+"',Status='"+Status+"',Bagian='"+Bagian+"' WHERE NIK='"+NIK+"'"; int i = stmt.executeUpdate (sql); if (i==1) { JOptionPane.showMessageDialog(null, "Data Karyawan berhasil diupdate"); } } catch (Exception ex) { JOptionPane.showMessageDialog(null, ex.getMessage()); } } } );
View
import java.awt.*; import java.sql.*; import javax.swing.*; import javax.swing.table.*; public class view_karyawan extends JPanel { String [] header = {"NIK","NmKaryawan","Alamat","JK","Status","Bagian"}; JTable table = new JTable(); JScrollPane scrollTable = new JScrollPane(); private Object[][] dataTable = null; view_karyawan() { Koneksi open = new Koneksi(); Connection mysql = open.getConnection(); try { Statement stmt = mysql.createStatement(); String sql = "SELECT * FROM t_karyawan"; ResultSet rs = stmt.executeQuery(sql); ResultSetMetaData meta = rs.getMetaData (); int kolom = meta.getColumnCount(); int baris = 0; while (rs.next()) { baris = rs.getRow(); } dataTable = new Object[baris][kolom]; int x = 0; rs.beforeFirst(); while(rs.next()) {
dataTable[x][0] = rs.getString("NIK"); dataTable[x][1] = rs.getString("NmKaryawan"); dataTable[x][2] = rs.getString("Alamat"); dataTable[x][3] = rs.getString("JK"); dataTable[x][4] = rs.getString("Status"); dataTable[x][5] = rs.getString("Bagian"); x++; } scrollTable.setViewportView(table); table.setModel(new DefaultTableModel(dataTable, header)); add(scrollTable,BorderLayout.NORTH); stmt.close(); rs.close(); } catch (Exception ex) { JOptionPane.showMessageDialog(null, "DATA KARYAWAN ERROR"); } } void GUI() { JFrame frame = new JFrame("Form Data Karyawan Penggajian"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); view_karyawan content = new view_karyawan(); content.setOpaque(true); frame.setContentPane(content); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true);
} public static void main(String []args) { view_karyawan inputan = new view_karyawan(); inputan.GUI(); } }
Delete
//button delete buttonDELETE.addActionListener ( new ActionListener() { public void actionPerformed(ActionEvent e) { String NIK, NmKaryawan, Alamat, JK, Status, Bagian; NIK = textNIK.getText(); NmKaryawan = textNmKaryawan.getText(); Alamat = textAlamat.getText(); if (radioPerempuan.isSelected()==true) { JK = radioPerempuan.getText(); } else { JK = radioLaki2.getText(); } Status = (String) comboStatus.getSelectedItem(); Bagian = (String) comboBagian.getSelectedItem();
//hapus ke database Koneksi open = new Koneksi();
Connection mysql = open.getConnection(); try { Statement stmt = mysql.createStatement(); String sql = "DELETE FROM t_karyawan WHERE NIK='"+NIK+"'"; int i =stmt.executeUpdate(sql); if(i == 1) { JOptionPane.showMessageDialog(null, "data karyawan berhasil dihapus"); } } catch(Exception ex) { JOptionPane.showMessageDialog(null, ex.getMessage()); } } });
2. TABEL GAJI Input
import javax.swing.*; import java.awt.event.*; import java.io.*; import java.sql.*; import java.awt.*; class input_gaji extends JFrame { // DEKLARASI LABEL
JLabel labelid_gaji=new JLabel("KODE"); JTextField textid_gaji=new JTextField(""); JLabel labelnama_karyawan=new JLabel("Nama Karyawan"); JTextField textnama_karyawan=new JTextField(""); JLabel labelgaji_pokok=new JLabel("Gaji Pokok"); JTextField textgaji_pokok=new JTextField(""); JLabel labelgaji_lembur=new JLabel("Gaji Lembur"); JTextField textgaji_lembur=new JTextField("");
JButton buttonSAVE =new JButton("SAVE"); JButton buttonEXIT =new JButton("EXIT");
input_gaji() { setTitle("INPUT DATA GAJI"); setLocation(400,200); setSize(400,300); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); } void GUI() { // LABEL getContentPane().setLayout(null); getContentPane().add(labelid_gaji); labelid_gaji.setBounds(10,10,70,25); getContentPane().add(textid_gaji); textid_gaji.setBounds(80,10,120,25); getContentPane().add(labelnama_karyawan); labelnama_karyawan.setBounds(10,40,70,25); getContentPane().add(textnama_karyawan); textnama_karyawan.setBounds(80,40,150,25);
getContentPane().add(labelgaji_pokok); labelgaji_pokok.setBounds(10,70,70,25); getContentPane().add(textgaji_pokok); textgaji_pokok.setBounds(80,70,150,25); getContentPane().add(labelgaji_lembur); labelgaji_lembur.setBounds(10,100,70,25); getContentPane().add(textgaji_lembur); textgaji_lembur.setBounds(80,100,150,25);
getContentPane().add(buttonSAVE); buttonSAVE.setBounds(80,190,90,25); getContentPane().add(buttonEXIT); buttonEXIT.setBounds(165,190,90,25);
setVisible(true); }
void perintah() { //button exit buttonEXIT.addActionListener ( new ActionListener() { public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog( null,"Anda Yakin Ingin Keluar?","KONFIRMASI", JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) { System.exit(0); } } } );
//buttonsave buttonSAVE.addActionListener ( new ActionListener() { public void actionPerformed(ActionEvent e) { String id_gaji, nama_karyawan, gaji_pokok, gaji_lembur; id_gaji = textid_gaji.getText(); nama_karyawan = textnama_karyawan.getText(); gaji_pokok = textgaji_pokok.getText(); gaji_lembur = textgaji_lembur.getText();
//input ke database Koneksi open = new Koneksi(); Connection mysql = open.getConnection(); try
{ Statement stmt = mysql.createStatement(); String sql = "INSERT INTO t_gaji values('"+id_gaji+"','"+ nama_karyawan+"','"+gaji_pokok+"','"+gaji_lembur+"');"; int i =stmt.executeUpdate(sql); if(i==1) { JOptionPane.showMessageDialog(null, "data gaji berhasil disimpan"); } } catch(Exception ex) { JOptionPane.showMessageDialog(null, ex.getMessage()); } } }); } public static void main(String []args) { input_gaji inputan = new input_gaji (); inputan.GUI(); inputan.perintah(); }
}
Update //BUTTON UPDATE buttonUPDATE.addActionListener ( new ActionListener() { public void actionPerformed (ActionEvent e) { String id_gaji, nama_karyawan, gaji_pokok, gaji_lembur; id_gaji = textid_gaji.getText(); nama_karyawan = textnama_karyawan.getText(); gaji_pokok = textgaji_pokok.getText(); gaji_lembur = textgaji_lembur.getText(); //update ke database Koneksi open = new Koneksi (); Connection mysql = open.getConnection(); try { Statement stmt = mysql.createStatement(); String sql = "UPDATE t_gaji SET nama_karyawan='"+nama_karyawan +"',gaji_pokok='"+gaji_pokok +"',gaji_lembur='"+gaji_lembur +"' WHERE id_gaji='"+id_gaji+"'";
int i = stmt.executeUpdate (sql); if (i==1) { JOptionPane.showMessageDialog(null, "Data Gaji berhasil diupdate"); } } catch (Exception ex) { JOptionPane.showMessageDialog(null, ex.getMessage()); } } } );
View import java.awt.*; import java.sql.*; import javax.swing.*; import javax.swing.table.*; public class view_gaji extends JPanel { String [] header = {"id_gaji","nama_karyawan", "gaji_pokok","gaji_lembur"}; JTable table = new JTable(); JScrollPane scrollTable = new JScrollPane(); private Object[][] dataTable = null; view_gaji() { Koneksi open = new Koneksi(); Connection mysql = open.getConnection(); try { Statement stmt = mysql.createStatement(); String sql = "SELECT * FROM t_gaji"; ResultSet rs = stmt.executeQuery(sql); ResultSetMetaData meta = rs.getMetaData (); int kolom = meta.getColumnCount(); int baris = 0; while (rs.next()) { baris = rs.getRow(); } dataTable = new Object[baris][kolom]; int x = 0; rs.beforeFirst(); while(rs.next()) {
dataTable[x][0] = rs.getString("id_gaji"); dataTable[x][1] = rs.getString("nama_karyawan"); dataTable[x][2] = rs.getString("gaji_pokok"); dataTable[x][3] = rs.getString("gaji_lembur"); x++; } scrollTable.setViewportView(table); table.setModel(new DefaultTableModel(dataTable, header)); add(scrollTable,BorderLayout.NORTH); stmt.close(); rs.close(); } catch (Exception ex) { JOptionPane.showMessageDialog(null, "DATA GAJI ERROR"); } } void GUI() { JFrame frame = new JFrame("Form Data Gaji"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); view_gaji content = new view_gaji(); content.setOpaque(true); frame.setContentPane(content); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true);
} public static void main(String []args) { view_gaji inputan = new view_gaji(); inputan.GUI(); } }
Delete //button delete buttonDELETE.addActionListener ( new ActionListener() { public void actionPerformed(ActionEvent e) { String id_gaji, nama_karyawan, gaji_pokok, gaji_lembur; id_gaji = textid_gaji.getText(); nama_karyawan = textnama_karyawan.getText(); gaji_pokok = textgaji_pokok.getText(); gaji_lembur = textgaji_lembur.getText();
//hapus ke database Koneksi open = new Koneksi(); Connection mysql = open.getConnection(); try { Statement stmt = mysql.createStatement(); String sql = "DELETE FROM t_gaji WHERE id_gaji='"+id_gaji+"'"; int i =stmt.executeUpdate(sql); if(i==1) { JOptionPane.showMessageDialog(null, "data gaji berhasil dihapus"); } }
catch(Exception ex) { JOptionPane.showMessageDialog(null, ex.getMessage()); } } });
3. TABEL ABSEN Input import javax.swing.*; import java.awt.event.*; import java.io.*; import java.sql.*; import java.awt.*; class input_absen extends JFrame { // DEKLARASI LABEL
JLabel labelid_absen=new JLabel("KODE"); JTextField textid_absen=new JTextField(""); JLabel labelnama=new JLabel("NAMA"); JTextField textnama=new JTextField(""); JLabel labeljam_kerja=new JLabel("Jam Kerja"); JTextField textjam_kerja=new JTextField(""); JLabel labeljam_lembur=new JLabel("Jam Lembur"); JTextField textjam_lembur=new JTextField("");
JButton buttonSAVE =new JButton("SAVE"); JButton buttonEXIT =new JButton("EXIT");
input_absen() { setTitle("INPUT DATA ABSEN"); setLocation(400,200); setSize(400,300); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); } void GUI() {
// LABEL getContentPane().setLayout(null); getContentPane().add(labelid_absen); labelid_absen.setBounds(10,10,70,25); getContentPane().add(textid_absen); textid_absen.setBounds(80,10,120,25); getContentPane().add(labelnama); labelnama.setBounds(10,40,70,25); getContentPane().add(textnama); textnama.setBounds(80,40,150,25); getContentPane().add(labeljam_kerja); labeljam_kerja.setBounds(10,70,70,25); getContentPane().add(textjam_kerja); textjam_kerja.setBounds(80,70,150,25); getContentPane().add(labeljam_lembur); labeljam_lembur.setBounds(10,100,70,25); getContentPane().add(textjam_lembur); textjam_lembur.setBounds(80,100,150,25);
getContentPane().add(buttonSAVE); buttonSAVE.setBounds(80,190,90,25); getContentPane().add(buttonEXIT); buttonEXIT.setBounds(165,190,90,25);
setVisible(true); }
void perintah() { //button exit buttonEXIT.addActionListener ( new ActionListener() { public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog( null,"Anda Yakin Ingin Keluar?","KONFIRMASI", JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) { System.exit(0); } } } );
//buttonsave buttonSAVE.addActionListener ( new ActionListener() { public void actionPerformed(ActionEvent e)
{ String id_absen, nama, jam_kerja, jam_lembur; id_absen = textid_absen.getText(); nama = textnama.getText(); jam_kerja = textjam_kerja.getText(); jam_lembur = textjam_lembur.getText();
//input ke database Koneksi open = new Koneksi(); Connection mysql = open.getConnection(); try { Statement stmt = mysql.createStatement(); String sql = "INSERT INTO t_absen values('"+id_absen+"','"+ nama+"','"+jam_kerja+"','"+jam_lembur+"');"; int i =stmt.executeUpdate(sql); if(i==1) { JOptionPane.showMessageDialog(null, "data absen berhasil disimpan"); } } catch(Exception ex) { JOptionPane.showMessageDialog(null, ex.getMessage()); } } }); } public static void main(String []args) { input_absen inputan = new input_absen(); inputan.GUI(); inputan.perintah(); }
}
Update //BUTTON UPDATE buttonUPDATE.addActionListener ( new ActionListener() { public void actionPerformed (ActionEvent e) { String id_absen, nama, jam_kerja, jam_lembur; id_absen = textid_absen.getText(); nama = textnama.getText(); jam_kerja = textjam_kerja.getText(); jam_lembur = textjam_lembur.getText(); //update ke database Koneksi open = new Koneksi (); Connection mysql = open.getConnection(); try { Statement stmt = mysql.createStatement(); String sql = "UPDATE t_absen SET nama='"+nama +"',jam_kerja='"+jam_kerja +"',jam_lembur='"+jam_lembur +"' WHERE id_absen='"+id_absen+"'";
int i = stmt.executeUpdate (sql); if (i==1) { JOptionPane.showMessageDialog(null, "Data absen berhasil diupdate"); } } catch (Exception ex) { JOptionPane.showMessageDialog(null, ex.getMessage()); }
} } );
Delete
//button delete buttonDELETE.addActionListener ( new ActionListener() { public void actionPerformed(ActionEvent e) { String id_absen, nama, jam_kerja, jam_lembur; id_absen = textid_absen.getText(); nama = textnama.getText(); jam_kerja = textjam_kerja.getText(); jam_lembur = textjam_lembur.getText();
//hapus ke database Koneksi open = new Koneksi(); Connection mysql = open.getConnection(); try { Statement stmt = mysql.createStatement(); String sql = "DELETE FROM t_absen WHERE id_absen='"+id_absen+"'"; int i =stmt.executeUpdate(sql); if(i==1) { JOptionPane.showMessageDialog(null, "data absen berhasil dihapus"); }
} catch(Exception ex) { JOptionPane.showMessageDialog(null, ex.getMessage()); } } } );
View
import java.awt.*; import java.sql.*; import javax.swing.*; import javax.swing.table.*; public class view_absen extends JPanel { String [] header = {"id_absen","nama", "jam_kerja","jam_lembur"}; JTable table = new JTable(); JScrollPane scrollTable = new JScrollPane(); private Object[][] dataTable = null; view_absen() { Koneksi open = new Koneksi(); Connection mysql = open.getConnection(); try { Statement stmt = mysql.createStatement(); String sql = "SELECT * FROM t_absen";
ResultSet rs = stmt.executeQuery(sql); ResultSetMetaData meta = rs.getMetaData (); int kolom = meta.getColumnCount(); int baris = 0; while (rs.next()) { baris = rs.getRow(); } dataTable = new Object[baris][kolom]; int x = 0; rs.beforeFirst(); while(rs.next()) { dataTable[x][0] = rs.getString("id_absen"); dataTable[x][1] = rs.getString("nama"); dataTable[x][2] = rs.getString("jam_kerja"); dataTable[x][3] = rs.getString("jam_lembur"); x++; } scrollTable.setViewportView(table); table.setModel(new DefaultTableModel(dataTable, header)); add(scrollTable,BorderLayout.NORTH); stmt.close(); rs.close(); } catch (Exception ex) { JOptionPane.showMessageDialog(null, "DATA ABSEN ERROR"); } } void GUI() { JFrame frame = new JFrame("Form Data Absen"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); view_absen content = new view_absen(); content.setOpaque(true); frame.setContentPane(content); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true);
} public static void main(String []args) { view_absen inputan = new view_absen (); inputan.GUI(); } }
BAB IV MENU A. Pengaturan Tampilan Menu import javax.swing.*; import java.awt.event.*; class menu extends JFrame
{ JMenuBar menubar=new JMenuBar(); JMenu Data_Karyawan=new JMenu("Data Karyawan"); JMenuItem inputk=new JMenuItem("Input data karyawan"); JMenuItem updatek=new JMenu("Update data karyawan"); JMenuItem deletek=new JMenuItem("Delete data karyawan"); JMenuItem viewk=new JMenu("View data karyawan"); JMenuItem exitk=new JMenu("Exit data karyawan"); JMenu Data_Gaji=new JMenu("Data Gaji"); JMenuItem inputg=new JMenuItem("Input data gaji"); JMenuItem updateg=new JMenu("Update data gaji"); JMenuItem deleteg=new JMenuItem("Delete data gaji"); JMenuItem viewg=new JMenu("View data karyawan"); JMenuItem exitg=new JMenu("Exit data karyawan");
JMenu Data_Absen=new JMenu("Data Absen"); JMenuItem inputa=new JMenuItem("Input data absen"); JMenuItem updatea=new JMenu("Update data absen"); JMenuItem deletea=new JMenuItem("Delete data absen"); JMenuItem viewa=new JMenu("View data absen"); JMenuItem exita=new JMenu("Exit data karyawan");
JMenu about=new JMenu("About");
JMenuItem tentang=new JMenuItem("About Us"); JMenuItem exit=new JMenu("Exit data karyawan"); menu(){ setTitle("Sistem Informasi Gaji Karyawan"); setLocation(300,200); setSize(300,250); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
void tampilanmenu() { setJMenuBar(menubar);
menubar.add(Data_Karyawan); Data_Karyawan.add(inputk); Data_Karyawan.add(updatek); Data_Karyawan.add(deletek); Data_Karyawan.add(viewk); Data_Karyawan.add(exitk);
menubar.add(Data_Gaji); Data_Gaji.add(inputg); Data_Gaji.add(updateg); Data_Gaji.add(deleteg); Data_Gaji.add(viewg); Data_Gaji.add(exitg); menubar.add(Data_Absen); Data_Absen.add(inputa); Data_Absen.add(updatea); Data_Absen.add(deletea); Data_Absen.add(viewa);
Data_Absen.add(exita);
menubar.add(about); about.add(tentang); exit.add(exit); setVisible(true); } void perintah() { exit.addActionListener (new ActionListener() { public void actionPerformed (ActionEvent e) { System.exit(0); } }); //KONEKSI KE FILE TABEL DATA KARYAWAN inputk.addActionListener (new ActionListener(){ public void actionPerformed(ActionEvent e){ input_karyawan inputan=new input_karyawan(); inputan.GUI(); inputan.perintah(); } }); updatek.addActionListener (new ActionListener(){ public void actionPerformed(ActionEvent e){ update_karyawan inputan=new update_karyawan(); inputan.GUI(); inputan.perintah(); } });
deletek.addActionListener (new ActionListener(){ public void actionPerformed(ActionEvent e){ hapus_karyawan inputan=new hapus_karyawan(); inputan.GUI(); inputan.perintah(); } }); viewk.addActionListener (new ActionListener(){ public void actionPerformed(ActionEvent e){ view_karyawan inputan=new view_karyawan(); inputan.GUI(); } }); //KONEKSI KE FILE TABEL GAJI inputg.addActionListener (new ActionListener(){ public void actionPerformed(ActionEvent e){ input_gaji inputan=new input_gaji(); inputan.GUI(); inputan.perintah(); } }); inputg.addActionListener (new ActionListener(){ public void actionPerformed(ActionEvent e){ update_gaji inputan=new update_gaji(); inputan.GUI(); inputan.perintah();
} }); viewg.addActionListener (new ActionListener(){ public void actionPerformed(ActionEvent e){
view_gaji inputan=new view_gaji(); inputan.GUI(); } }); deleteg.addActionListener (new ActionListener(){ public void actionPerformed(ActionEvent e){ hapus_gaji inputan=new hapus_gaji(); inputan.GUI(); inputan.perintah(); } }); //KONEKSI KE FILE TABEL ABSEN inputa.addActionListener (new ActionListener(){ public void actionPerformed(ActionEvent e){ input_absen inputan=new input_absen(); inputan.GUI(); inputan.perintah(); } }); viewa.addActionListener (new ActionListener(){ public void actionPerformed(ActionEvent e){ view_absen inputan=new view_absen(); inputan.GUI(); } }); updatea.addActionListener (new ActionListener(){ public void actionPerformed(ActionEvent e){ update_absen inputan=new update_absen(); inputan.GUI(); inputan.perintah(); }
}); deletea.addActionListener (new ActionListener(){ public void actionPerformed(ActionEvent e){ hapus_absen inputan=new hapus_absen(); inputan.GUI(); inputan.perintah(); } }); tentang.addActionListener (new ActionListener(){ public void actionPerformed (ActionEvent e){ JOptionPane.showMessageDialog(null, " Tugas Java - by : Vega Dwi Suryani (13121038) ", "About",JOptionPane.INFORMATION_MESSAGE); } }); } public static void main(String[]args){ menu y = new menu(); y.tampilanmenu(); y.perintah(); } }
B. INTEGRASI MENU Menu
Data Karyawan
Data Gaji
Data Absen
About us
BAB V
PENUTUP A.
Kesimpulan Dengan menggunakan system aplikasi gaji karyawank ini, diharapkan masyarakat Indonesia nanti, khususnya para pengusaha bisa lebih akurat dan cepat dalam penggajian karyawan.
B.
Kesulitan Ada beberapa kesulitan dalam pembuatan system aplikasi ini, diantaranya : -
Optimalisasi antar tabel yang masih belum terlalu di kuasai. Menu tabel masih belum bisa.