コード例 #1
0
  //    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;
  }
コード例 #2
0
  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;
  }