示例#1
0
  /**
   * saveRegistrationDetails
   *
   * @param loginData
   * @return
   * @throws SQLException
   */
  public boolean saveRegistrationDetails(Employee loginData) throws SQLException {

    boolean loginResult = false;
    Connection con = DBConnectivity.connectDB();
    try {
      String insertTableSQL =
          "INSERT INTO employee_login" + "(employee_id, user_name, password) VALUES" + "(?, ?, ?)";
      PreparedStatement preparedStatement = con.prepareStatement(insertTableSQL);
      preparedStatement.setInt(1, loginData.getEmployeeId());
      preparedStatement.setString(2, loginData.getUserName());
      preparedStatement.setString(3, loginData.getPassword());
      preparedStatement.executeUpdate();
      loginResult = true;
    } catch (SQLException e) {

      e.printStackTrace();
    } finally {
      con.close();
    }

    return loginResult;
  }
示例#2
0
  /**
   * getEmployeeData
   *
   * @param empId
   * @return Employee
   * @throws SQLException
   */
  public Employee getEmployeeData(String empId) throws SQLException {
    Connection con = DBConnectivity.connectDB();
    Employee empData = new Employee();
    Statement ps;
    String employeeDetailsQuery =
        " select employee_id,employee_name,points_remaining,supervisor_id"
            + " from employee_details where employee_id ="
            + Integer.parseInt(empId)
            + "";

    try {
      ps = con.createStatement();
      ResultSet rs = ps.executeQuery(employeeDetailsQuery);
      while (rs.next()) {
        empData.setEmployeeName(rs.getString("employee_name"));
        empData.setPointsRemaining(rs.getInt("points_remaining"));
        empData.setSupervisorId(rs.getInt("supervisor_id"));
        empData.setEmployeeId(rs.getInt("employee_id"));
      }
      String supervisorName =
          "select employee_name from employee_details where employee_id = "
              + empData.getSupervisorId()
              + "";
      rs = ps.executeQuery(supervisorName);
      while (rs.next()) {
        empData.setSupervisorName(rs.getString("employee_name"));
      }
    } catch (SQLException e) {

      e.printStackTrace();
    } finally {
      con.close();
    }

    return empData;
  }
示例#3
0
  /**
   * getEmployeeData
   *
   * @param userName
   * @param password
   * @return Employee
   * @throws SQLException
   */
  public Employee getEmployeeData(String userName, String password) throws SQLException {
    Connection con = DBConnectivity.connectDB();
    List<Bids> itemsList = new ArrayList<Bids>();
    Employee empData = new Employee();
    Statement ps;
    String employeeDetailsQuery =
        " select employee_id,employee_name,points_Achived,points_remaining,supervisor_id,total_points"
            + " from employee_details where employee_id in (select employee_id from employee_login where user_name = '"
            + userName
            + "' and password = '******')";

    try {
      ps = con.createStatement();
      ResultSet rs = ps.executeQuery(employeeDetailsQuery);
      while (rs.next()) {
        empData.setEmployeeName(rs.getString("employee_name"));
        empData.setPointsRemaining(rs.getInt("points_remaining"));
        empData.setPointsAchived(rs.getInt("points_Achived"));
        empData.setSupervisorId(rs.getInt("supervisor_id"));
        empData.setTotal_points(rs.getInt("total_points"));
        empData.setEmployeeId(rs.getInt("employee_id"));
      }
      String bidData =
          "select f.points_added,p.IMG, p.id,p.item_name,p.description from employee_fact f join product_details p"
              + " on f.product_id = p.id where f.employee_id in (select employee_id from employee_login where user_name = '"
              + userName
              + "' and password = '******')";
      rs = ps.executeQuery(bidData);
      while (rs.next()) {
        Bids getBids = new Bids();
        getBids.setItemName(rs.getString("item_name"));
        getBids.setDescription(rs.getString("description"));
        getBids.setPoints(rs.getInt("points_added"));
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] buf = new byte[1024];
        InputStream in = rs.getBinaryStream("IMG");
        int n = 0;
        try {
          while ((n = in.read(buf)) >= 0) {
            baos.write(buf, 0, n);
          }
          in.close();
        } catch (IOException e) {

          e.printStackTrace();
        }
        getBids.setItemImage(baos.toByteArray());
        getBids.setItemId(rs.getInt("id"));
        itemsList.add(getBids);
      }
      empData.setBids(itemsList);
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      con.close();
    }

    return empData;
  }