public PersonnelDetails getPersonnelDetails(String personnelID) {
    PersonnelDetails pd = new PersonnelDetails();
    PreparedStatement ps;
    ResultSet rs;
    if (dbc.connect()) {
      try {
        String sqlQuery = "select * from " + PERSONNEL_INFO + " where MaNV = '" + personnelID + "'";
        ps = dbc.getConnection().prepareStatement(sqlQuery);
        rs = ps.executeQuery();

        // retrieve data from db by PersonnelID
        while (rs.next()) {

          pd.setPersonnelID(rs.getString(1));
          pd.setlName(rs.getString(2));
          pd.setfName(rs.getString(3));
          pd.setNickName(rs.getString(4));

          pd.setStatusID(rs.getShort(5));
          pd.setKindID(rs.getShort(6));
          pd.setContractID(rs.getShort(7));
          pd.setPosID(rs.getShort(8));
          pd.setOfficeID(rs.getShort(9));

          pd.setEnterDate(rs.getDate(10));

          pd.setStartDate(rs.getDate(11));
          pd.setSex(rs.getBoolean(12));
          pd.setPhoneNum(rs.getString(13));
          pd.setCompEmail(rs.getString(14));
          pd.setEndTraining(rs.getDate(15));

          pd.setPic(rs.getBytes(16));
          pd.setBirth(rs.getDate(17));
          pd.setPlaceOB(rs.getString(18));
          pd.setRecentAdd(rs.getString(19));

          pd.setFolkID(rs.getShort(20));
          pd.setReligionID(rs.getShort(21));
          pd.setNationID(rs.getShort(22));
          pd.setPersonalEmail(rs.getString(23));
          pd.setMariage(rs.getBoolean(24));
          pd.setEducation(rs.getString(25));
          pd.setAdd(rs.getString(26));
          pd.setIDNum(rs.getString(27));
          pd.setIDDay(rs.getDate(28));
          pd.setRegionID(rs.getShort(29));
          //                    System.out.println(rs.getShort(29));
          pd.setBankCode(rs.getString(30));
          pd.setBankID(rs.getShort(31));
          pd.setIDPlace(rs.getString(32));
          pd.setTaxCode(rs.getString(33));
        }
        dbc.close(ps, rs);
      } catch (SQLException ex) {
        Logger.getLogger(PersonnelDAO.class.getName()).log(Level.SEVERE, null, ex);
      }
    }
    return pd;
  }
  //    public static void main(String[] args) {
  //        PersonnelDAO p = new PersonnelDAO();
  //        p.getPersonnelDetails("NV0001");
  ////////
  ////        String a = p.getPersonnelInfo("TenPhongBan", "tblPhongBan", "MaPhongBan", (short) 1);
  ////        System.out.println(a);
  //////        ArrayList h = p.getList("MaMQH", "tblGiaDinh");
  //////        for (int i = 0; i < h.size(); i++) {
  //////            System.out.println(h.get(i));
  //////        }
  //////////        p.getFamilyDetails("NV0001");
  //////////        p.getHealthStatus("NV0001");
  //////////        p.getEducation("NV0001");
  //////////        p.getSkill("NV0001");
  //////////        p.getExperience("NV0001");
  //////////        p.getDocumentsDetails("NV0001");
  //////////        p.getRowPersonnelListTable();
  ////////        ArrayList<PersonnelBasic> a = p.getRowPersonnelListTable();
  ////////        for (int i = 0; i < a.size(); i++) {
  ////////            System.out.println(a.get(i).getName());
  ////////            System.out.println(a.get(i).getBirth());
  ////////            System.out.println(a.get(i).getOffice());
  //        }
  //    }
  public boolean insertPersonnelDetails(PersonnelDetails pd) {
    boolean check = true;
    PreparedStatement ps;
    if (dbc.connect()) {
      try {
        String sqlQuery =
            "INSERT INTO "
                + PERSONNEL_INFO
                + " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        ps = dbc.getConnection().prepareStatement(sqlQuery);
        ps.setString(1, pd.getPersonnelID());
        ps.setNString(2, pd.getlName());
        ps.setNString(3, pd.getfName());
        ps.setNString(4, pd.getNickName());
        ps.setShort(5, pd.getStatusID());
        ps.setShort(6, pd.getKindID());
        ps.setShort(7, pd.getContractID());
        ps.setShort(8, pd.getPosID());
        ps.setShort(9, pd.getOfficeID());

        if (pd.getEnterDate() == null) {
          ps.setNull(10, java.sql.Types.DATE);
        } else {
          ps.setDate(10, pd.getEnterDate());
        }

        if (pd.getStartDate() == null) {
          ps.setNull(11, java.sql.Types.DATE);
        } else {
          ps.setDate(11, pd.getStartDate());
        }

        ps.setBoolean(12, pd.isSex());
        ps.setString(13, pd.getPhoneNum());
        ps.setString(14, pd.getCompEmail());

        if (pd.getEndTraining() == null) {
          ps.setNull(15, java.sql.Types.DATE);
        } else {
          ps.setDate(15, pd.getEndTraining());
        }
        ps.setBytes(16, pd.getPic());

        if (pd.getBirth() == null) {
          ps.setNull(17, java.sql.Types.DATE);
        } else {
          ps.setDate(17, pd.getBirth());
        }
        ps.setNString(18, pd.getPlaceOB());
        ps.setNString(19, pd.getRecentAdd());
        ps.setShort(20, pd.getFolkID());
        ps.setShort(21, pd.getReligionID());
        ps.setShort(22, pd.getNationID());
        ps.setString(23, pd.getPersonalEmail());
        ps.setBoolean(24, pd.isMariage());
        ps.setString(25, pd.getEducation());
        ps.setNString(26, pd.getAdd());
        ps.setString(27, pd.getIDNum());

        if (pd.getIDDay() == null) {
          ps.setNull(28, java.sql.Types.DATE);
        } else {
          ps.setDate(28, pd.getIDDay());
        }
        ps.setShort(29, pd.getRegionID());
        ps.setString(30, pd.getBankCode());
        ps.setShort(31, pd.getBankID());
        ps.setNString(32, pd.getIDPlace());
        ps.setString(33, pd.getTaxCode());

        if (ps.executeUpdate() < 1) {
          check = false;
        }
        dbc.close(ps);
      } catch (SQLException ex) {
        Logger.getLogger(PersonnelDAO.class.getName()).log(Level.SEVERE, null, ex);
      }
    }

    return check;
  }
  public boolean updatePersonnelDetails(PersonnelDetails pd) {
    boolean check = false;
    PreparedStatement ps = null;
    if (dbc.connect()) {
      try {
        String sqlQuery =
            "update "
                + PERSONNEL_INFO
                + " set "
                + "HoDem = ? ,"
                + "Ten = ?   ,"
                + "	Nickname = ?,\n"
                + "	MaTrangThai = ?,\n"
                + "	MaLoaiNV = ?,\n"
                + "	MaLoaiHopDong = ?,\n"
                + "	MaChucVu = ?,\n"
                + "	MaPhongBan = ?,\n"
                + "	NgayVao = ?,\n"
                + "	NgayBatDau = ?,\n"
                + "	GioiTinh = ?,\n"
                + "	SDT = ?,\n"
                + "	EmailCty = ?,\n"
                + "	NgayKTthuViec = ?,\n"
                + "	HinhAnh = ?,\n"
                + "	NgaySinh = ?,\n"
                + "	NguyenQuan = ?,\n"
                + "	ThuongTru = ?,\n"
                + "	MaDanToc = ?,\n"
                + "	MaTonGiao = ?,\n"
                + "	MaQuocGia = ?,\n"
                + "	EmailRieng = ?,\n"
                + "	KetHon = ?,\n"
                + "	TrinhDoVH = ?,\n"
                + "	DiaChi = ?,\n"
                + "	SoCMT = ?,\n"
                + "	NgayCap = ?,\n"
                + "	MaTinh = ?,\n"
                + "	SoTK = ?,\n"
                + "	MaNH = ?,\n"
                + "	NoiCap = ?,\n"
                + "	MaSoThue = ?\n"
                + "where MaNV = ?";
        ps = dbc.getConnection().prepareStatement(sqlQuery);
        ps.setNString(1, pd.getlName());
        ps.setNString(2, pd.getfName());
        ps.setNString(3, pd.getNickName());
        ps.setShort(4, pd.getStatusID());
        ps.setShort(5, pd.getKindID());
        ps.setShort(6, pd.getContractID());
        ps.setShort(7, pd.getPosID());
        ps.setShort(8, pd.getOfficeID());

        if (pd.getEnterDate() == null) {
          ps.setNull(9, java.sql.Types.DATE);
        } else {
          ps.setDate(9, pd.getEnterDate());
        }

        if (pd.getStartDate() == null) {
          ps.setNull(10, java.sql.Types.DATE);
        } else {
          ps.setDate(10, pd.getStartDate());
        }

        ps.setBoolean(11, pd.isSex());
        ps.setString(12, pd.getPhoneNum());
        ps.setString(13, pd.getCompEmail());

        if (pd.getEndTraining() == null) {
          ps.setNull(14, java.sql.Types.DATE);
        } else {
          ps.setDate(14, pd.getEndTraining());
        }

        ps.setBytes(15, pd.getPic());

        if (pd.getBirth() == null) {
          ps.setNull(16, java.sql.Types.DATE);
        } else {
          ps.setDate(16, pd.getBirth());
        }
        ps.setNString(17, pd.getPlaceOB());
        ps.setNString(18, pd.getRecentAdd());
        ps.setShort(19, pd.getFolkID());
        ps.setShort(20, pd.getReligionID());
        ps.setShort(21, pd.getNationID());
        ps.setString(22, pd.getPersonalEmail());
        ps.setBoolean(23, pd.isMariage());
        ps.setString(24, pd.getEducation());
        ps.setNString(25, pd.getAdd());
        ps.setString(26, pd.getIDNum());

        if (pd.getIDDay() == null) {
          ps.setNull(27, java.sql.Types.DATE);
        } else {
          ps.setDate(27, pd.getIDDay());
        }
        ps.setShort(28, pd.getRegionID());
        ps.setString(29, pd.getBankCode());
        ps.setShort(30, pd.getBankID());
        ps.setNString(31, pd.getIDPlace());
        ps.setString(32, pd.getTaxCode());
        ps.setString(33, pd.getPersonnelID());

        if (ps.executeUpdate() > 0) {
          check = true;
        }
        dbc.close(ps);
      } catch (SQLException ex) {
        Logger.getLogger(PersonnelDAO.class.getName()).log(Level.SEVERE, null, ex);
      } finally {
        dbc.close(ps);
      }
    }

    return check;
  }