Lampiran Utama a. Struktur Organisasi Factory Manager Vice Factory Manager Non Produksi Depart.Umum /Personalia Personalia Umum Bag. Kepegawaian Bag.Humas Produksi Dept.PPC Dept. Power Dept Greyee Dept. Finishing Bag. Accounting Bag.Listrik Bag. False Twisting Bag. Dyeing Bag.Bengkel Bag. Sizing Bag. Laborat Bag.Boiler Bag. Weaving Bag. Verpacking Bag. Logistik Bag.Kendaraan Bag.Pengupaha n PPC Bag.Hukum dan Perijinan Bag.Kesra Gudang Benang Bag.Pekerjaan Umum Bag. Gudang Alfa Bag.UPL Gudang Kain Bag. Operator Telepon 47 a. Flowchart Prosedur Perekrutan Karyawan PT. Timatex Departemen yang membutuhkan karyawan Bagian Personalia Pelamar 1 Butuh karyawan Formulir Permintaan Tenaga kerja TTD 2 Formulir Permintaan Tenaga kerja T Surat Panggilan Tes Setuju? Formulir Permintaan Tenaga kerja Data Karyawan Mengisi biodata TTD Formulir Permintaan Tenaga kerja 1 Formulir Permintaan Tenaga kerja Surat Panggilan Tes Cek Bank Data Data karaywan Biodata karyawan Melaku kan Tes Bank Data Evaluasi Y T Lowongan Kerja Surat Panggilan Tes Data karaywan Pelamar 3 Surat Lamaran Seleksi Surat Panggilan Tes TTD Surat Panggilan Tes 2 48 Biodata karyawan Bagian Personalia Departemen yang membutuhkan karyawan 3 4 Surat Panggilan Tes Surat Panggila n Tes Data karaywan Biodata karyawan formulir penilaian calon karyawan. Biodata karyawan Data karaywan Hasil tes Membuat formulir penilaian calon karyawan. Membuat catatan / keputusan penilaian tes calon karayawan dan di ttd Surat Panggila n Tes Data karaywan Biodata karyawan formulir penilaian calon karyawan. Surat Panggilan Tes Hasil tes Data karaywan formulir penilaian calon karyawan. Biodata karyawan Catatan / hasil keputusan Menerima tesdan di ttd 5 Surat Panggilan Tes Data karaywan formulir penilaian calon karyawan. Biodata karyawan Hasil tes 4 5 Surat Panggil an Tes Data karaywa n Biodata karyawa n formulir penilaian calon karyawan. Hasil tes Catatan / hasil keputusan Membuat Surat panggilan kerja Surat Panggil an Tes Data karaywan Biodata karyawan formulir penilaian calon karyawan. Hasil tes Catatan / hasil keputusan Surat panggilan kerja Pelamar 49 c. Coding List 1. Class Koneksi package kontroler; import java.sql.*; import java.sql.Connection; public class koneksi { static void tutup() { throw new UnsupportedOperationException("Not supported yet."); } public static Object createStatement() { throw new UnsupportedOperationException("Not supported yet."); } private String JDBC_DRIVER = "com.mysql.jdbc.Driver"; private String DB_URL = "jdbc:mysql://localhost:3306/kepegawaianta"; private String USER = "root"; private String PASS = ""; public Connection conn = null; public Connection getBuka() throws ClassNotFoundException { try { Class.forName(JDBC_DRIVER); conn = DriverManager.getConnection(DB_URL, USER, PASS); System.out.println("Koneksi Berhasil di Buka"); } catch (SQLException ex) { // ex.printStackTrace(); } return conn; } 50 public Connection getTutup() throws SQLException { try { if (conn != null) { conn.close(); } System.out.println("Koneksi Berhasil di Tutup"); } catch (SQLException ex) { ex.printStackTrace(); } return conn; } Connection getConnection(){ return null; } } 51 1. Class Kontrol package kontroler; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Vector; import java.text.ParseException; import javax.swing.JOptionPane; public class kontrol { public Statement stmt = null; public ResultSet rs; public Vector judulKolom= new Vector(); public Vector tabel = new Vector(); private String v_nikkary; protected ResultSet getRs(){ return rs; } //code untuk menambah data karyawan public void getTambahKary(String v_nikkary, String v_namaKary, String v_alamat, String v_nohp,String v_tempat_lhr, String v_tgl_lhr,String v_jenisKel,String vnama_jabatan,String v_keahlian,String v_statuskary,String v_dept, String v_tgl_masuk, String v_tgl_keluar) throws ClassNotFoundException { try { koneksi ogT = new koneksi(); ogT.getBuka(); PreparedStatement perintah = ogT.conn.prepareStatement("INSERT INTO tb_semuakary VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)"); perintah.setString(1, v_nikkary); perintah.setString(2, v_namaKary); perintah.setString(3, v_alamat); perintah.setString(4, v_nohp); perintah.setString(5, v_keahlian); perintah.setString(6, v_tempat_lhr); perintah.setString(7, v_tgl_lhr); perintah.setString(8, v_jenisKel); perintah.setString(9, vnama_jabatan); perintah.setString(10, v_statuskary); perintah.setString(11, v_dept); perintah.setString(12, v_tgl_masuk); perintah.setString(13, v_tgl_keluar); perintah.executeUpdate(); ogT.getTutup(); } catch (SQLException ex) { ex.printStackTrace(); //code untuk memperbaharui data karayawan JOptionPane.showMessageDialog(null,"NIK sudah ada"); } } public void getperbaharuitab_kary(String v_nikkary, String v_namaKary, String v_alamat, String v_nohp, String v_tempat_lhr, String v_tgl_lhr,String v_jenisKel,String vid_jabatan,String v_keahlian, String vid_statuskary,String vid_dept , String v_tgl_masuk, String v_tgl_keluar) throws ClassNotFoundException { try { koneksi ogPS = new koneksi(); ogPS.getBuka(); PreparedStatement perintah = ogPS.conn.prepareStatement("UPDATE tb_semuakary SET nama_kary=?, alamat=?, nohp=?," + "tempat_lhr=?, tgl_lhr=?,jenis_kel=?,id_jabatan=?,keahlian=?,id_statuskary=?," + "id_dept=?,tgl_masuk=?,tgl_keluar=? WHERE nik=?"); perintah.setString(1, v_namaKary); perintah.setString(2, v_alamat); 52 perintah.setString(3, v_nohp); perintah.setString(4, v_tempat_lhr); perintah.setString(5, v_tgl_lhr); perintah.setString(6, v_jenisKel); perintah.setString(7, vid_jabatan); perintah.setString(8, v_keahlian); perintah.setString(9, vid_statuskary); perintah.setString(10, vid_dept); perintah.setString(11, v_tgl_masuk); perintah.setString(12, v_tgl_keluar); perintah.setString(13, v_nikkary); perintah.executeUpdate(); ogPS.getTutup(); } catch (SQLException ex) { ex.printStackTrace(); } } //code untuk menghapus data karyawan public void gethapustab_kary(String v_nikkary, String v_namaKary, String v_alamat, String v_nohp,String v_keahlian, String v_tempat_lhr, String v_tgl_lhr,String v_jenisKel,String vid_jabatan, String vid_statuskary,String vid_dept ,String vid_karyPHK, String v_tgl_masuk, String v_tgl_keluar) throws ClassNotFoundException { try { koneksi ogPS = new koneksi(); ogPS.getBuka(); PreparedStatement perintah = ogPS.conn.prepareStatement("UPDATE tb_semuakary SET namaKary=?, alamat=?, nohp=?, keahlian=?," + "tempat_lhr=?, tgl_lhr=?,jenisKel=?,id_jabatan=?,id_statuskary=?," + "id_dept,id_karyPHK,tgl_masuk=?,tgl_keluar=? WHERE nikkary=?"); perintah.setString(1, v_nikkary); perintah.setString(2, v_namaKary); perintah.setString(3, v_alamat); perintah.setString(4, v_nohp); perintah.setString(5, v_keahlian); perintah.setString(6, v_tempat_lhr); perintah.setString(7, v_tgl_lhr); perintah.setString(8, v_jenisKel); perintah.setString(9, vid_jabatan); perintah.setString(10, vid_statuskary); perintah.setString(11, vid_dept); perintah.setString(12, vid_karyPHK); perintah.setString(13, v_tgl_masuk); perintah.setString(14, v_tgl_keluar); perintah.executeUpdate(); ogPS.getTutup(); } catch (SQLException ex) { ex.printStackTrace(); } } 53 //code untuk mencari data karyawan public ResultSet getCaritab_kary() throws SQLException { try { koneksi ogCS = new koneksi(); ogCS.getBuka(); PreparedStatement perintah = ogCS.conn.prepareStatement("SELECT * FROM tb_semuakary WHERE v_nikkary=?"); perintah.setString(1, v_nikkary); rs = perintah.executeQuery(); rs.first(); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } return rs; } //code untuk menampilkan semua data karyawan public ResultSet getSemuatab_kary() throws ClassNotFoundException, SQLException { koneksi ogSS = new koneksi(); ogSS.getBuka(); stmt = (Statement) ogSS.conn.createStatement(); rs = stmt.executeQuery("SELECT tb_semuakary.nik, tb_semuakary.nama_kary, tb_semuakary.alamat, tb_semuakary.nohp, tb_semuakary.tempat_lhr, tb_semuakary.tgl_lhr, tb_semuakary.jenis_kel,tbl_jabatan.nama_jabatan, tb_semuakary.keahlian, tb_statuskary.statuskary,tb_dept.dept, tb_semuakary.tgl_masuk, tb_semuakary.tgl_keluar FROM tb_semuakary join tbl_jabatan on tb_semuakary.id_jabatan = tbl_jabatan.id_jabatan\n" + "join tb_statuskary on tb_semuakary.id_statuskary = tb_statuskary.id_statuskary\n" + "join tb_dept on tb_semuakary.id_dept=tb_dept.id_dept"); return rs; } //masih dalam potongan menampilkan semua data karyawan public void isitab_kary() throws Exception { try { koneksi oiT = new koneksi(); judulKolom.add("Nik Karyawan"); judulKolom.add("Nama Karyawan"); judulKolom.add("Alamat"); judulKolom.add("No Hp"); judulKolom.add("Tempat lahir"); judulKolom.add("Tanggal Lahir"); judulKolom.add("Jenis Kelamin"); judulKolom.add("Jabatan"); judulKolom.add("Keahlian"); judulKolom.add("Status Karyawan"); judulKolom.add("Departemen"); judulKolom.add("Tanggal masuk"); judulKolom.add("Tanggal keluar"); while (rs.next()) { Vector baris = new Vector(); baris.add(rs.getString("nik")); baris.add(rs.getString("nama_kary")); baris.add(rs.getString("alamat")); baris.add(rs.getString("nohp")); baris.add(rs.getString("tempat_lhr")); baris.add(rs.getString("tgl_lhr")); baris.add(rs.getString("jenis_kel")); baris.add(rs.getString("nama_jabatan")); baris.add(rs.getString("keahlian")); baris.add(rs.getString("statuskary")); baris.add(rs.getString("dept")); 54 baris.add(rs.getString("tgl_masuk")); baris.add(rs.getString("tgl_keluar")); tabel.add(baris); } System.out.println("Tabel berhasil di Isi"); } catch (SQLException ex) { ex.printStackTrace(); } } //code untuk isi semua data dalam tabel history public void isitab_history() throws Exception { try { koneksi oiT = new koneksi(); judulKolom.add("tanggal"); judulKolom.add("history"); while (rs.next()) { Vector baris = new Vector(); baris.add(rs.getString("tanggal")); baris.add(rs.getString("history")); tabel.add(baris); System.out.println("Tabel berhasil di Isi"); } } catch (SQLException ex) { ex.printStackTrace(); } } //code untuk isi history karyawan public void isitab_history() throws Exception { try { koneksi oiT = new koneksi(); judulKolom.add("tanggal"); judulKolom.add("history"); while (rs.next()) { Vector baris = new Vector(); baris.add(rs.getString("tanggal")); baris.add(rs.getString("history")); tabel.add(baris); System.out.println("Tabel berhasil di Isi"); } } catch (SQLException ex) { ex.printStackTrace(); } } //code isi comboBox public ResultSet getIsiComboJabatan() throws ClassNotFoundException, SQLException { koneksi ogICS = new koneksi(); ogICS.getBuka(); stmt = ogICS.conn.createStatement(); rs = stmt.executeQuery("SELECT DISTINCT nama_jabatan FROM tbl_jabatan ORDER BY id_jabatan"); return rs; } public ResultSet getIsiComboStatusKary() throws ClassNotFoundException, SQLException { koneksi ogICS = new koneksi(); ogICS.getBuka(); stmt = ogICS.conn.createStatement(); 55 rs = stmt.executeQuery("SELECT DISTINCT statuskary FROM tb_statuskary ORDER BY id_statuskary"); return rs; } public ResultSet getIsiComboDepartemen() throws ClassNotFoundException, SQLException { koneksi ogICS = new koneksi(); ogICS.getBuka(); stmt = ogICS.conn.createStatement(); rs = stmt.executeQuery("SELECT DISTINCT dept FROM tb_dept ORDER BY id_dept"); return rs; } //lanjutan code untuk mengisi ComboBox public ResultSet getCariJabatan(String vid_jabatan) throws SQLException { try { koneksi ogCS = new koneksi(); ogCS.getBuka(); PreparedStatement perintah = ogCS.conn.prepareStatement("SELECT * FROM tbl_jabatan WHERE id_jabatan=?"); perintah.setString(1, vid_jabatan); rs = perintah.executeQuery(); rs.first(); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } return rs; } public ResultSet getCaristatuskary(String vid_statuskary) throws SQLException { try { koneksi ogCS = new koneksi(); ogCS.getBuka(); PreparedStatement perintah = ogCS.conn.prepareStatement("SELECT * FROM tb_statuskary WHERE id_statuskary=?"); perintah.setString(1, vid_statuskary); rs = perintah.executeQuery(); rs.first(); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } return rs; } public ResultSet getCariDepartemen(String vid_dept) throws SQLException { try { koneksi ogCS = new koneksi(); ogCS.getBuka(); PreparedStatement perintah = ogCS.conn.prepareStatement("SELECT * FROM tb_dept WHERE id_dept=?"); perintah.setString(1, vid_dept); rs = perintah.executeQuery(); rs.first(); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } return rs; } 56 // code untuk mencari tahun public ResultSet getcaritahun(String tahun) throws ClassNotFoundException, SQLException { koneksi ogSS = new koneksi(); ogSS.getBuka(); stmt = (Statement) ogSS.conn.createStatement(); rs = stmt.executeQuery("SELECT tb_semuakary.nik, tb_semuakary.nama_kary, tb_semuakary.alamat, tb_semuakary.nohp, tb_semuakary.tempat_lhr, tb_semuakary.tgl_lhr, tb_semuakary.jenis_kel,tbl_jabatan.nama_jabatan, tb_semuakary.keahlian, tb_statuskary.statuskary,tb_dept.dept, tb_semuakary.tgl_masuk, tb_semuakary.tgl_keluar FROM tb_semuakary \n" + "join tbl_jabatan on tb_semuakary.id_jabatan = tbl_jabatan.id_jabatan\n" + "join tb_statuskary on tb_semuakary.id_statuskary = tb_statuskary.id_statuskary\n" + "join tb_dept on tb_semuakary.id_dept=tb_dept.id_dept\n" + "Where tb_semuakary.tgl_keluar between '" + tahun + "-01-01' and '" + tahun + "-1231'"); return rs; } 3. Class Menu Form Dituliskan pada setiap menu private void JM_DSKActionPerformed(java.awt.event.ActionEvent evt) { new KaryTetap().show(); dispose(); } private void JM_DKPActionPerformed(java.awt.event.ActionEvent evt) { new karyPHK().show(); dispose(); } private void JM_HKActionPerformed(java.awt.event.ActionEvent evt) { new history().show(); dispose(); } private void keluarActionPerformed(java.awt.event.ActionEvent evt) { new login().show(); dispose(); } 57 2. Class bt_login “login” private void bt_loginActionPerformed(java.awt.event.ActionEvent evt) { koneksi kon = new koneksi (); try{ String sql = "select * from login where user='"+ jf1.getText()+"'and pass ='" + String.valueOf(jf2.getPassword())+"'"; kon.getBuka(); Statement stmt = kon.conn.createStatement (); ResultSet rs = stmt.executeQuery(sql); if (rs.next()){ utama hm = new utama (); hm.setVisible(true); this.dispose(); } else{ JOptionPane.showMessageDialog(null,"LOGIN EROR!!"); } }catch (Exception e ){ jf1.setText(""); jf2.setText(""); JOptionPane.showMessageDialog(null,"Kesalahan dalam Input Data"); } } public void ClearForm(){ jf1.setText(""); jf2.setText(""); } 58 5. Class a. Data Semua Karyawan Button “Tambah” private void bt_tambahkaryActionPerformed(java.awt.event.ActionEvent evt) { if (tf_nikkary.getText().trim().equals("")){ JOptionPane.showMessageDialog(null, "Maaf Nik harus diisi, trimakasih"); } try { String jabatan = null; If (jc_jabatan.getSelectedItem().toString().equalsIgnoreCase("administrasi")){ jabatan = "adm"; }else if(jc_jabatan.getSelectedItem().toString().equalsIgnoreCase("Ketua Regu")){ jabatan = "karu"; }else if (jc_jabatan.getSelectedItem().toString().equalsIgnoreCase("Ketua Bagian")){ jabatan = "kb"; }else if (jc_jabatan.getSelectedItem().toString().equalsIgnoreCase("Karyawan")){ jabatan = "kry"; }else if (jc_jabatan.getSelectedItem().toString().equalsIgnoreCase("Ketua Shift")){ jabatan = "ks"; }else if (jc_jabatan.getSelectedItem().toString().equalsIgnoreCase("Wakil Kepala Shift ")){ jabatan = "wks"; } String status = null; if (jc_statuskary.getSelectedItem().toString().equalsIgnoreCase("kontrak")){ status = "k1"; }else if(jc_statuskary.getSelectedItem().toString().equalsIgnoreCase("tetap")){ status = "t1"; } String dept = null; if (jc_dept.getSelectedItem().toString().equalsIgnoreCase("General Factory Acc")){ 59 dept = "GF - Acc"; }else if(jc_dept.getSelectedItem().toString().equalsIgnoreCase("General Factory Gudang")){ dept = "GF - Gd"; }else if (jc_dept.getSelectedItem().toString().equalsIgnoreCase("General Factory Kendaraan")){ dept = "GF - Kend"; }else if (jc_dept.getSelectedItem().toString().equalsIgnoreCase("General Factory Personal")){ dept = "GF - pers"; }else if (jc_dept.getSelectedItem().toString().equalsIgnoreCase("General Factory UPL")){ dept = "GF - UPL"; }else if (jc_dept.getSelectedItem().toString().equalsIgnoreCase("Logistik ")){ dept = "log"; } SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd"); Calendar cal = Calendar.getInstance(); Date tgl = null; int tahun = 0; if(status.equals("k1")){ tgl = dateformat.parse(tf_tgl_masuk .getText().toString()); tahun = 3; }else if(status.equals("t1")){ tgl = dateformat.parse(tf_tgl_lhr .getText().toString()); tahun = 55; } cal.setTime(tgl); cal.add(Calendar.YEAR, tahun); String tgl_keluar = dateformat.format(cal.getTime()); objCRUD = new kontrol(); objCRUD.getTambahKary(tf_nikkary.getText().toString(), tf_namaKary.getText().toString(), tf_alamat.getText().toString(), tf_nohp .getText().toString(), 60 tf_tempat_lhr .getText().toString(),tf_tgl_lhr .getText().toString(), cb_jenisKel .getSelectedItem().toString(),jabatan, tf_keahlian .getText().toString(), status,dept, tf_tgl_masuk.getText().toString(),tgl_keluar); String history="masuk dengan status "+ jc_statuskary.getSelectedItem().toString()+", menjabat sebagai "+jc_jabatan.getSelectedItem().toString()+" di departemen "+jc_dept.getSelectedItem().toString(); objCRUD.getTambahhistory(tf_nikkary.getText().toString(),tf_tgl_masuk.getText().toString (), history); Tampiltab_kary(); Bersihtab_Kary(); } catch (Exception ex) { ex.printStackTrace(); } } Button “Delete” b. private void bt_deleteActionPerformed(java.awt.event.ActionEvent evt) { try { objCRUD = new kontrol(); if(!tf_nikkary.getText().toString().equals("")){ objCRUD.getdeletetab_kary(tf_nikkary.getText().toString()); Tampiltab_kary(); } } catch (ClassNotFoundException ex) { Logger.getLogger(KaryTetap.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(KaryTetap.class.getName()).log(Level.SEVERE, null, ex); } catch (Exception ex) { Logger.getLogger(KaryTetap.class.getName()).log(Level.SEVERE, null, ex); } } 61 c. Button “Perbaharui” //potongan code untuk memperbaharui yang ada di dalam comboBox private void bt_ubahActionPerformed(java.awt.event.ActionEvent evt) { try { String jabatan = null; if (jc_jabatan.getSelectedItem().toString().equalsIgnoreCase("administrasi")){ jabatan = "adm"; }else if(jc_jabatan.getSelectedItem().toString().equalsIgnoreCase("Ketua Regu")){ jabatan = "karu"; } String status = null; if (jc_statuskary.getSelectedItem().toString().equalsIgnoreCase("kontrak")){ status = "k1"; }else if(jc_statuskary.getSelectedItem().toString().equalsIgnoreCase("tetap")){ status = "t1"; } //code untuk menampilan format tanggal SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd"); Calendar cal = Calendar.getInstance(); Date tgl = null; int tahun = 0; //code untuk menghitung tanggal if(status.equals("k1")){ tgl = dateformat.parse(tf_tgl_masuk .getText().toString()); tahun = 3; }else if(status.equals("t1")){ tgl = dateformat.parse(tf_tgl_lhr .getText().toString()); tahun = 55; } 62 cal.setTime(tgl); cal.add(Calendar.YEAR, tahun); String tgl_keluar = dateformat.format(cal.getTime()); objCRUD = new kontrol(); Button d. “Cari” private void bt_carinikActionPerformed(java.awt.event.ActionEvent evt) { objCRUD = new kontrol(); try { objCRUD.getcarinik(tf_nikkary.getText()); } catch (ClassNotFoundException ex) { Logger.getLogger(KaryTetap.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(KaryTetap.class.getName()).log(Level.SEVERE, null, ex); } try { objCRUD.isitab_kary(); } catch (Exception ex) { Logger.getLogger(KaryTetap.class.getName()).log(Level.SEVERE, null, ex); } DefaultTableModel dtm; dtm = new DefaultTableModel(objCRUD.tabel, objCRUD.judulKolom); tab_kary.setModel(dtm); //objCRUD.getTu(); } b. Class History Karyawan private void bt_carihistoryActionPerformed(java.awt.event.ActionEvent evt) { objCRUD = new kontrol(); try { objCRUD.getcarinikhistory(tf_nikhistory.getText()); } catch (ClassNotFoundException ex) { 63 Logger.getLogger(history.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(history.class.getName()).log(Level.SEVERE, null, ex); } try { objCRUD.isitab_history(); } catch (Exception ex) { Logger.getLogger(history.class.getName()).log(Level.SEVERE, null, ex); } DefaultTableModel dtm; dtm = new DefaultTableModel(objCRUD.tabel, objCRUD.judulKolom); tab_history.setModel(dtm); } 64 65 66 67 68 69 70 71 72 73