private static void SaveUnity(JPanel PanelComponent, AdmUnity admUnity, AdmNewUnity admNewUnity) { String id, satuan; id = UnityLog.getId(); satuan = UnityLog.getSatuan(); String message, sql; sql = "INSERT INTO " + "unity_id(id, satuan) " + "VALUES('" + id + "', '" + satuan + "')"; Integer operation; operation = SQLAdapter.dataOperation(1, sql); if (operation == 1) { message = "Data berhasil disimpan."; Pesan.Information(message); admNewUnity.setVisible(false); CloseFrame(PanelComponent, admUnity); } }
private static void CheckID(JPanel PanelComponent, AdmUnity admUnity, AdmNewUnity admNewUnity) { String id; id = UnityLog.getId(); String message, sql; sql = "SELECT id AS `ID` FROM unity_id WHERE id = '" + id + "';"; resultSet = SQLAdapter.getData(sql); try { if (resultSet.next()) { message = "Mohon gunakan id lain !"; Pesan.Warning(message); } else { SaveUnity(PanelComponent, admUnity, admNewUnity); } } catch (SQLException ex) { ex.printStackTrace(); } }
private static void CheckID(String idUpdate, JPanel PanelComponent, RootPeoples rootPeoples) { String message, sql; sql = "SELECT person_id.id AS `ID` " + "FROM person_id " + "WHERE person_id.id = '" + idUpdate + "';"; resultSet = SQLAdapter.getData(sql); try { if (resultSet.next()) { message = "Mohon gunakan id lain !"; Pesan.Warning(message); } else { UpdatePersonID(idUpdate, PanelComponent, rootPeoples); } } catch (SQLException ex) { ex.printStackTrace(); } }
public static void GettingInformation( JLabel labelCompanyID, JLabel labelCompanyName, JLabel labelCompanyPhone, JLabel labelCompanyDirectedBy, JLabel labelCompanyCity, JLabel labelCompanyAddress, link linkCompanyEmployersCount) { String rootID, sql; rootID = UserLog.getId(); sql = "SELECT office_id.id AS `Office ID`, office_id.nama AS `Office Name`, office_id.kontak AS `Office Phone`, " + "person_id.nama AS `Directed by`, person_id.kelamin AS `Kelamin`, " + "office_id.kota AS `Office City`, office_id.alamat AS `Office Address`, " + "(SELECT COUNT(office_peoples.id_person) AS `Count Peoples`" + " " + "FROM office_id, office_peoples, person_id" + " " + "WHERE " + " " + "office_peoples.id_office = office_id.id AND" + " " + "person_id.id = office_peoples.id_person" + ") AS `Employers Count` " + "FROM office_id, office_peoples, person_id " + "WHERE office_peoples.id_office = office_id.id AND " + "person_id.id = office_peoples.id_person AND " + "office_id.id_person = '" + rootID + "';"; resultSet = SQLAdapter.getData(sql); try { if (resultSet.next()) { String id, nama, kontak, pemilik, preparedPemilik, kelamin, kota, alamat; id = resultSet.getString("Office ID"); nama = resultSet.getString("Office Name"); kontak = resultSet.getString("Office Phone"); preparedPemilik = resultSet.getString("Directed by"); kelamin = resultSet.getString("Kelamin"); if (kelamin.equals("Laki-laki") == true) { pemilik = "Tn." + " " + preparedPemilik; } else { pemilik = "Ny." + " " + preparedPemilik; } kota = resultSet.getString("Office City"); alamat = resultSet.getString("Office Address"); Integer count; count = resultSet.getInt("Employers Count"); labelCompanyID.setText(id); labelCompanyName.setText(nama); labelCompanyPhone.setText(kontak); labelCompanyDirectedBy.setText(pemilik); labelCompanyCity.setText(kota); labelCompanyAddress.setText(alamat); String message; if (count == 0) { message = "No employer !"; } else { if (count == 1) { message = count.toString() + " " + "Employer"; } else { message = count.toString() + " " + "Employers"; } } linkCompanyEmployersCount.setText(message); SetInformation(id, nama, kontak, pemilik, kota, alamat); } } catch (SQLException ex) { ex.printStackTrace(); } }
private static void UpdatePersonID( String idUpdate, JPanel PanelComponent, RootPeoples rootPeoples) { String idDefault; idDefault = PeoplesLog.getId(); String nama, kelamin, kota, tglLahir, dLahir, kontak, alamat; nama = PeoplesLog.getNama(); kelamin = PeoplesLog.getKelamin(); kota = PeoplesLog.getKota(); tglLahir = PeoplesLog.getTglLahir(); dLahir = PeoplesLog.getdLahir(); kontak = PeoplesLog.getKontak(); alamat = PeoplesLog.getAlamat(); String message, sql; if (idUpdate.equals(idDefault) == true) { sql = "UPDATE person_id " + "SET " + "nama = '" + nama + "', kelamin = '" + kelamin + "', kota = '" + kota + "', " + "tgl_lahir = '" + tglLahir + "', d_lahir = '" + dLahir + "', " + "kontak = '" + kontak + "', alamat = '" + alamat + "' " + "WHERE id = '" + idDefault + "';"; } else { sql = "UPDATE person_id " + "SET " + "id = '" + idUpdate + "', " + "nama = '" + nama + "', kelamin = '" + kelamin + "', kota = '" + kota + "', " + "tgl_lahir = '" + tglLahir + "', d_lahir = '" + dLahir + "', " + "kontak = '" + kontak + "', alamat = '" + alamat + "' " + "WHERE id = '" + idDefault + "';"; } Integer operation; operation = SQLAdapter.dataOperation(1, sql); if (operation == 1) { message = "Terima kasih telah memperbaharui data."; Pesan.Information(message); ReturnFrame(PanelComponent, rootPeoples); } }