Esempio n. 1
0
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException, SQLException {
    response.setContentType("text/html;charset=UTF-8");
    try (PrintWriter out = response.getWriter()) {
      session = request.getSession();
      dbConn conn = new dbConn();
      IdGenerator IG = new IdGenerator();
      id = IG.current_id();

      plotname = request.getParameter("plotname");

      status = "";
      String checker = "SELECT id FROM plots WHERE name=? OR id=?";
      conn.pst = conn.conn.prepareStatement(checker);
      conn.pst.setString(1, plotname);
      conn.pst.setString(2, id);

      conn.rs = conn.pst.executeQuery();
      if (conn.rs.next() == true) {
        status = "<font color=\"red\"><b>Failed </b> : Plot already exist.</font>";

      } else {
        String inserter = "INSERT INTO plots (id,name) VALUES(?,?)";
        conn.pst = conn.conn.prepareStatement(inserter);
        conn.pst.setString(1, id);
        conn.pst.setString(2, plotname);
        conn.pst.executeUpdate();
        status = "<font color=\"green\"><b>Success : </b> Plot added successfully.</font>";
      }
      out.println(status);
    }
  }
Esempio n. 2
0
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException, SQLException {
    response.setContentType("text/html;charset=UTF-8");
    try (PrintWriter out = response.getWriter()) {
      session = request.getSession();
      dbConn conn = new dbConn();

      houseid = request.getParameter("houseid");
      rooms = "<option value=\"\">Choose Room</option>";
      String getData = "SELECT id,name FROM rooms WHERE house_id='" + houseid + "'";
      conn.rs = conn.st.executeQuery(getData);
      while (conn.rs.next()) {
        rooms +=
            "<option value=\"" + conn.rs.getString(1) + "\">" + conn.rs.getString(2) + "</option>";
      }
      out.println(rooms);
    }
  }
Esempio n. 3
0
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException, SQLException {
    response.setContentType("text/html;charset=UTF-8");
    try (PrintWriter out = response.getWriter()) {
      session = request.getSession();
      dbConn conn = new dbConn();

      data = "";
      position = 0;
      String getData =
          "SELECT rooms.id,plots.name,houses.name,rooms.name FROM rooms JOIN houses ON rooms.house_id=houses.id "
              + "JOIN plots ON houses.plot_id=plots.id ORDER BY plots.name,houses.name,rooms.name";
      conn.rs = conn.st.executeQuery(getData);
      while (conn.rs.next()) {
        id = conn.rs.getString(1);
        plotname = conn.rs.getString(2);
        housename = conn.rs.getString(3);
        roomname = conn.rs.getString(4);
        position++;

        hidden =
            "<input type=\"hidden\" name=\"valrm_"
                + position
                + "\" id=\"valrm_"
                + position
                + "\" value=\""
                + id
                + "\">";
        edit =
            "<button class=\"form-control btn btn-info\" id=\"editrm_"
                + position
                + "\" onclick=\"return editor3("
                + position
                + ");\"  name=\"editrm_"
                + position
                + "\">Edit</button>";
        delete =
            "<button class=\"form-control btn btn-danger\" id=\"deleterm_"
                + position
                + "\" onclick=\"return deletor3("
                + position
                + ");\"  name=\"deleterm_"
                + position
                + "\">Delete</button>";
        data +=
            "<tr><td>"
                + hidden
                + ""
                + position
                + "</td><td>"
                + plotname
                + "</td><td>"
                + housename
                + "</td><td>"
                + roomname
                + "</td><td>"
                + edit
                + "</td><td>"
                + delete
                + "</td></tr>";
      }
      out.println(data);
    }
  }