コード例 #1
0
  public synchronized void service(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    HttpSession dbSession = request.getSession();
    JspFactory _jspxFactory = JspFactory.getDefaultFactory();
    PageContext pageContext =
        _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
    ServletContext dbApplication = dbSession.getServletContext();

    nseer_db_backup1 stock_db = new nseer_db_backup1(dbApplication);

    try {
      if (stock_db.conn((String) dbSession.getAttribute("unit_db_name"))) {
        int i;
        int intRowCount;
        String sqll =
            "select * from stock_config_public_char where describe1='\u51fa\u5165\u5e93\u7406\u7531'";
        ResultSet rs = stock_db.executeQuery(sqll);
        rs.next();
        rs.last();
        intRowCount = rs.getRow();
        String[] del = new String[intRowCount];
        del = (String[]) dbSession.getAttribute("del");
        if (del != null) {
          for (i = 1; i <= intRowCount; i++) {
            String sql = "delete from stock_config_public_char where id='" + del[i - 1] + "'";
            stock_db.executeUpdate(sql);
          }
        }
        stock_db.commit();
        stock_db.close();
        response.sendRedirect("stock/config/apply_gather_pay/reason.jsp");
      } else {
        response.sendRedirect("error_conn.htm");
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
コード例 #2
0
  public void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

    resp.setContentType("text/html");
    PrintWriter out = resp.getWriter();

    Connection con = null; // init DB objects
    PreparedStatement pstmt = null;
    Statement stmt = null;
    ResultSet rs = null;

    try {
      con = dbConn.Connect("demopaul");
    } catch (Exception ignore) {
    }

    String stype_id = req.getParameter("type_id");
    int type_id = 0;

    String sgroup_id = req.getParameter("group_id");
    int group_id = 0;

    String sitem_id = req.getParameter("item_id");
    int item_id = 0;

    try {
      type_id = Integer.parseInt(stype_id);
    } catch (NumberFormatException ignore) {
    }

    try {
      group_id = Integer.parseInt(sgroup_id);
    } catch (NumberFormatException ignore) {
    }

    try {
      item_id = Integer.parseInt(sitem_id);
    } catch (NumberFormatException ignore) {
    }

    out.println(
        "<!-- type_id=" + type_id + ", group_id=" + group_id + ", item_id=" + item_id + " -->");

    out.println("<script>");

    out.println("function load_types() {");
    out.println(" try {document.forms['frmSelect'].item_id.selectedIndex = -1; } catch (err) {}");
    out.println(" document.forms['frmSelect'].group_id.selectedIndex = -1;");
    out.println(" document.forms['frmSelect'].submit();");
    out.println("}");

    out.println("function load_groups() {");
    out.println(" document.forms['frmSelect'].submit();");
    out.println("}");

    out.println("</script>");

    out.println("<form name=frmSelect>");

    // LOAD ACTIVITY TYPES
    out.println("<select name=type_id onchange=\"load_types()\">");

    if (type_id == 0) {

      out.println("<option>CHOOSE TYPE</option>");
    }

    try {

      stmt = con.createStatement();

      rs = stmt.executeQuery("SELECT * FROM activity_types");

      while (rs.next()) {

        Common_Config.buildOption(rs.getInt("type_id"), rs.getString("type_name"), type_id, out);
      }
      stmt.close();

    } catch (Exception exc) {

      out.println("<p>ERROR:" + exc.toString() + "</p>");
    }

    out.println("");
    out.println("</select>");

    // LOAD ACTIVITIES BY GROUP TYPE
    out.println("<select name=group_id onchange=\"load_groups()\">");

    if (type_id == 0) {

      out.println("<option>CHOOSE TYPE</option>");

    } else {

      try {

        stmt = con.createStatement();
        rs =
            stmt.executeQuery(
                "SELECT group_id, group_name FROM activity_groups WHERE type_id = " + type_id);

        rs.last();
        if (rs.getRow() == 1) {
          group_id = rs.getInt("group_id");
          out.println("<!-- ONLY FOUND 1 GROUP -->");
        } else {
          out.println("<option value=\"0\">CHOOSE...</option>");
        }

        rs.beforeFirst();

        while (rs.next()) {

          Common_Config.buildOption(
              rs.getInt("group_id"), rs.getString("group_name"), group_id, out);
        }
        stmt.close();

      } catch (Exception exc) {

        out.println("<p>ERROR:" + exc.toString() + "</p>");
      }
    }

    out.println("");
    out.println("</select>");

    if (group_id > 0) { // || sitem_id != null

      // LOAD ACTIVITIES BY ITEM TYPE
      out.println("<select name=item_id onchange=\"load_times()\">");

      if (group_id == 0) {

        out.println("<option value=\"0\">CHOOSE GROUP</option>");

      } else {

        try {

          stmt = con.createStatement();
          rs =
              stmt.executeQuery(
                  "SELECT item_id, item_name FROM activity_items WHERE group_id = " + group_id);

          rs.last();
          if (rs.getRow() == 1) {
            item_id = rs.getInt("item_id");
            out.println("<!-- ONLY FOUND 1 ITEM -->");
          } else {
            out.println("<option value=\"0\">CHOOSE...</option>");
          }

          rs.beforeFirst();

          while (rs.next()) {

            Common_Config.buildOption(
                rs.getInt("item_id"), rs.getString("item_name"), item_id, out);
          }
          stmt.close();

        } catch (Exception exc) {

          out.println("<p>ERROR:" + exc.toString() + "</p>");
        }
      }

      out.println("");
      out.println("</select>");
    }

    out.println("</form>");

    out.println("<p><a href=\"Member_genrez\">Reset</a></p>");

    try {
      con.close();
    } catch (Exception ignore) {
    }

    out.close();
  }