Exemple #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();

    ServletContext application;
    HttpSession session = request.getSession();
    nseer_db_backup1 finance_db = new nseer_db_backup1(dbApplication);

    try {

      if (finance_db.conn((String) dbSession.getAttribute("unit_db_name"))) {
        String finance_cheque_id = request.getParameter("finance_cheque_id");
        String sql = "delete from finance_bill where id='" + finance_cheque_id + "'";
        finance_db.executeUpdate(sql);
        finance_db.commit();
        finance_db.close();

      } else {
        response.sendRedirect("error_conn.htm");
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    System.out.println("[Servlet3.doPost]");

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

    out.println("FILTER-REQUEST:" + request.getSession().getAttribute("FILTER-REQUEST"));
    out.println("FILTER-FORWARD:" + request.getSession().getAttribute("FILTER-FORWARD"));
    out.println("FILTER-INCLUDE:" + request.getSession().getAttribute("FILTER"));
  }
Exemple #3
0
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    PrintWriter writer = response.getWriter();
    HttpSession session = request.getSession();

    String username = request.getParameter("username");
    String password = request.getParameter("password");
    String type = request.getParameter("type");
    System.out.println(username + password + type);

    session.setAttribute("user", username);

    try {
      writer.println("<html>");
      writer.println("<body bgcolor=green>");
      writer.println("<center>");
      ps.setString(1, username);
      ps.setString(2, password);
      ps.setString(3, type);
      ResultSet rs = ps.executeQuery();

      if (rs.next()) {
        writer.println("<h1>LOGIN SUCCESSFUL</h1><br><br>");
        writer.println("<a href=account.html>click here to see your account</a>");
      } else {
        writer.println("<h1>LOGIN FAILED</h1><br><br>");
        writer.println("<a href=login.html>click here to login again</a>");
      }
      writer.println("</center>");
      writer.println("</body>");
      writer.println("</html>");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

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

    String support = "support"; // valid username

    HttpSession session = null;
    session = req.getSession(false); // Get user's session object (no new one)
    if (session == null) {

      invalidUser(out); // Intruder - reject
      return;
    }

    String userName = (String) session.getAttribute("user"); // get username

    if (!userName.equals(support)) {

      invalidUser(out); // Intruder - reject
      return;
    }

    String action = "";
    if (req.getParameter("todo") != null) action = req.getParameter("todo");

    if (action.equals("update")) {

      doUpdate(out);
      return;
    }

    out.println("<p>Nothing to do.</p>todo=" + action);
  }
  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {

    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    Enumeration values = req.getParameterNames();
    String name = "";
    String value = "";
    String id = "";
    while (values.hasMoreElements()) {
      name = ((String) values.nextElement()).trim();
      value = req.getParameter(name).trim();
      if (name.equals("id")) id = value;
    }
    if (url.equals("")) {
      url = getServletContext().getInitParameter("url");
      cas_url = getServletContext().getInitParameter("cas_url");
    }
    HttpSession session = null;
    session = req.getSession(false);
    if (session != null) {
      session.invalidate();
    }
    res.sendRedirect(cas_url);
    return;
  }
Exemple #6
0
  /**
   * Get a populated User object from the request passed in.
   *
   * @param The request object to check for the user
   * @return The user object, or null if no user object was found
   */
  public static User getUser(HttpServletRequest request) {
    HttpSession session = request.getSession();
    if (session == null) {
      return null;
    }

    return (User) (session.getAttribute("user"));
  }
 public void doPost(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   Integer etat = (Integer) request.getSession().getAttribute("etat");
   if (etat == null) {
     RequestDispatcher dispatcher = request.getRequestDispatcher("/login.jsp");
     dispatcher.forward(request, response);
   } else {
     try {
       String titre = request.getParameter("titre");
       String dateSortie = request.getParameter("dateSortie");
       String nom = request.getParameter("nom");
       String role = request.getParameter("role");
       // conversion du parametre dateSortie en SQLDate
       Date date;
       try {
         date = new Date(FormatDate.convertirDate(dateSortie).getTime());
       } catch (ParseException e) {
         throw new Tp6Exception(
             "Format de la date " + dateSortie + " incorrect. AAAA-MM-JJ attendue.");
       }
       // executer la transaction
       GestionTp6 tp6Update = (GestionTp6) request.getSession().getAttribute("tp6Update");
       synchronized (tp6Update) {
         tp6Update.gestionFilm.ajoutActeurFilm(titre, date, nom, role);
       }
       RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/menu.jsp");
       dispatcher.forward(request, response);
     } catch (Tp6Exception e) {
       List<String> listeMessageErreur = new LinkedList<String>();
       listeMessageErreur.add(e.toString());
       request.setAttribute("listeMessageErreur", listeMessageErreur);
       RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/menu.jsp");
       dispatcher.forward(request, response);
     } catch (Exception e) {
       e.printStackTrace();
       response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
     }
   }
 }
Exemple #8
0
  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter toClient = res.getWriter();
    toClient.println("<!DOCTYPE HTML>");
    toClient.println("<html>");
    toClient.println("<head><title>Books</title></head>");
    toClient.println("<body>");
    toClient.println("<a href=\"index.html\">Home</A>");
    toClient.println("<h2>List of books</h2>");

    HttpSession session = req.getSession(false);
    if (session != null) {
      String name = (String) session.getAttribute("name");
      if (name != null) {
        toClient.println("<h2>name: " + name + "</h2>");
      }
    }

    toClient.print("<form action=\"bookOpinion\" method=GET>");
    toClient.println("<table border='1'>");

    String sql = "Select code, title, author FROM books";
    System.out.println(sql);
    try {
      Statement statement = connection.createStatement();
      ResultSet result = statement.executeQuery(sql);
      while (result.next()) {
        toClient.println("<tr>");
        String codeStr = result.getString("code");
        toClient.println(
            "<td><input type=\"radio\" name=\"book" + "\" value=\"" + codeStr + "\"></td>");
        toClient.println("<td>" + codeStr + "</td>");
        toClient.println("<td>" + result.getString("title") + "</td>");
        toClient.println("<td>" + result.getString("author") + "</td>");
        toClient.println("</tr>");
      }
    } catch (SQLException e) {
      e.printStackTrace();
      System.out.println("Resulset: " + sql + " Exception: " + e);
    }
    toClient.println("</table>");
    toClient.println("<textarea rows=\"8\" cols=\"60\" name=\"comment\"></textarea><BR>");
    toClient.println("<input type=submit>");
    toClient.println("</form>");
    toClient.println("</body>");
    toClient.println("</html>");
    toClient.close();
  }
  public void service(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    res.setContentType("text/html");
    int cost;
    PrintWriter out = res.getWriter();
    System.out.println("CreditCard");

    HttpSession CCsession = req.getSession(true);
    cost = (Integer) CCsession.getValue("ba");

    Integer billamt = new Integer(cost);
    CCsession.putValue("ba", billamt);

    out.println("<html>");
    out.println("<title>CC..</title>");
    out.println("<body bgcolor=#737CA >");

    out.println("<form action=\"http://localhost:8080/servlet/CreditThanks\">");

    out.println("<font size=36 align=center color=#ffd7ff>");
    out.println("<center>Payment mode: Credit Card</center></font><br><br>");
    out.println("<br><br><br><br>");

    out.println("<font size=4>Enter your user id:");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    out.println("&nbsp;&nbsp;&nbsp;");
    out.println("<input type=text name=\"userid\">");
    out.println("<br><br>Enter your Credit card no:");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;");
    out.println("<input type=text name=\"cardno\"><br><br>");

    out.println("Enter your Bank name:");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    out.println("<input type=text name=\"bankname\"><br><br>");

    out.println("Bill amount:</b>");
    out.println(
        "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");

    out.println("&nbsp;&nbsp;&nbsp;&nbsp;Rs. &nbsp;");
    out.println("<input type=text name=\"billamt\" value=" + cost + ">&nbsp;&nbsp;/-");
    out.println("</font><br><br><br><br>");

    out.println("<input type=submit value=\"submit\">");

    out.println("</form></body></html>");
  } // service
  @Override
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    // get a connection
    ConnectionPool pool = ConnectionPool.getInstance();
    Connection connection = pool.getConnection();

    String sqlStatement = request.getParameter("sqlStatement");
    String sqlResult = "";
    try {
      // create a statement
      Statement statement = connection.createStatement();

      // parse the SQL string
      sqlStatement = sqlStatement.trim();
      if (sqlStatement.length() >= 6) {
        String sqlType = sqlStatement.substring(0, 6);
        if (sqlType.equalsIgnoreCase("select")) {
          // create the HTML for the result set
          ResultSet resultSet = statement.executeQuery(sqlStatement);
          sqlResult = SQLUtil.getHtmlTable(resultSet);
          resultSet.close();
        } else {
          int i = statement.executeUpdate(sqlStatement);
          if (i == 0) {
            sqlResult = "<p>The statement executed successfully.</p>";
          } else { // an INSERT, UPDATE, or DELETE statement
            sqlResult = "<p>The statement executed successfully.<br>" + i + " row(s) affected.</p>";
          }
        }
      }
      statement.close();
      connection.close();
    } catch (SQLException e) {
      sqlResult = "<p>Error executing the SQL statement: <br>" + e.getMessage() + "</p>";
    } finally {
      pool.freeConnection(connection);
    }

    HttpSession session = request.getSession();
    session.setAttribute("sqlResult", sqlResult);
    session.setAttribute("sqlStatement", sqlStatement);

    String url = "/index.jsp";
    getServletContext().getRequestDispatcher(url).forward(request, response);
  }
Exemple #11
0
  public void doPost(HttpServletRequest req, HttpServletResponse res)
      throws IOException, ServletException {

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

    /* Get Session */
    HttpSession s = req.getSession(true);
    /* Make sure user is logged in */
    if (s.getAttribute("login") == null || (String) s.getAttribute("login") != "go") {
      req.getRequestDispatcher("login.jsp").forward(req, res);
    }

    try {
      String dbuser = this.getServletContext().getInitParameter("dbuser");
      String dbpassword = this.getServletContext().getInitParameter("dbpassword");

      Class.forName("com.mysql.jdbc.Driver");
      Connection conn =
          DriverManager.getConnection("jdbc:mysql://localhost/project", dbuser, dbpassword);

      Statement stmt = conn.createStatement();
      stmt.execute(
          "INSERT INTO songs VALUES(null, '"
              + req.getParameter("song_name")
              + "', '"
              + req.getParameter("artist")
              + "', '"
              + req.getParameter("album")
              + "', '"
              + req.getParameter("genre")
              + "', 0)");

      stmt.close();
      conn.close();

      // delete memcache since new song is now added
      MemcachedClient c = new MemcachedClient(new InetSocketAddress("127.0.0.1", 11211));
      c.delete("master");

      req.getRequestDispatcher("add_song_success.jsp").forward(req, res);

    } catch (Exception e) {
      out.println(e.getMessage());
    }
  }
  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

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

    String support = "support"; // valid username

    HttpSession session = null;
    session = req.getSession(false); // Get user's session object (no new one)

    if (session == null) {

      invalidUser(out); // Intruder - reject
      return;
    }

    String userName = (String) session.getAttribute("user"); // get username

    if (!userName.equals(support)) {

      invalidUser(out); // Intruder - reject
      return;
    }

    out.println("<HTML><HEAD><TITLE>Database Upgrade</TITLE></HEAD>");
    out.println("<BODY><CENTER>");
    out.println(
        "<BR><BR><H3>This job will check all clubs' session logs for caller=clubster.</H3>");
    out.println("<BR><BR>Click 'Continue' to start the job.");
    out.println("<BR><BR> <A HREF=\"/v5/servlet/Support_main\">Return</A><BR><BR>");

    out.println(
        "<form method=post><input type=submit value=\"Continue\" onclick=\"return confirm('Are you sure?')\">");
    out.println(" <input type=hidden value=\"update\" name=\"todo\"></form>");
    /*
    out.println("<form method=post><input type=submit value=\"  Test  \">");
    out.println(" <input type=hidden value=\"test\" name=\"todo\"></form>");
    *
    */

    out.println("</CENTER></BODY></HTML>");

    out.close();
  }
 /** checks database for this user */
 private boolean realAuthentication(HttpServletRequest request, ConnectionPool conPool)
     throws SQLException {
   // user authentication is required!
   User user = (User) request.getSession().getAttribute(StringInterface.USERATTR);
   if (user == null) {
     return false;
   }
   Connection con = conPool.getConnection();
   boolean authenticated = false;
   try {
     authenticated = userUtils.confirmUserWithEncrypted(user.getID(), user.getEncrypted(), con);
   } catch (Exception e) {
     throw new SQLException(e.getMessage());
   } finally {
     conPool.free(con);
     con = null;
   }
   return authenticated;
 } // end realAuthentication
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    javax.servlet.jsp.PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;

    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/xml;charset=ISO-8859-1");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\n");
      out.write("\n");

      HttpSession user = request.getSession(true);
      Notification newNotice = (Notification) user.getAttribute("newNotice");
      List exclude = new ArrayList();
      exclude.add(NotificationWizardServlet.WT_VENDOR_NAME); // Exclude WebTelemetry

      out.print(buildTree(newNotice, exclude));
      out.write("\n");
    } catch (Throwable t) {
      out = _jspx_out;
      if (out != null && out.getBufferSize() != 0) out.clearBuffer();
      if (pageContext != null) pageContext.handlePageException(t);
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
    }
  }
 public void doPost(HttpServletRequest req, HttpServletResponse res)
     throws IOException, ServletException {
   res.setContentType("text/html");
   hs = req.getSession(true);
   PrintWriter pw = res.getWriter();
   uid = req.getParameter("did");
   if (!uid.equals("")) {
     v = D.getDealer(uid);
     pw.println(
         "<html><head><TITLE>Web-Enabled Automated Manufacturing System</TITLE><script language=javascript>function set() {");
     pw.println(
         "document.deldealer.select1.value='"
             + (String) v.elementAt(4)
             + "'} </script></head><P align=center><FONT color=deepskyblue size=4><STRONG>MODIFY&nbsp;DEALER </STRONG></FONT></P> ");
     pw.println(
         "<body onLoad=set()><br><br><form name=deldealer method=post action='http://peers:8080/servlet/DelDealer'>");
     pw.println(
         "<center><TABLE border=0 cellPadding=1 cellSpacing=1 width='75%' style='HEIGHT: 147px; WIDTH: 248px'>");
     pw.println(
         "<TR><TD>DealerId&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD><TD><INPUT id=text1 name=did value="
             + (String) v.elementAt(0)
             + "></TD></TR>");
     pw.println(
         "<TR><TD>DealerName</TD><TD><INPUT id=text2 name=dname value="
             + (String) v.elementAt(1)
             + " ></TD></TR><TR><TD>DealerAddress</TD>");
     pw.println(
         "<TD><INPUT id=text2 type=text name=daddr value="
             + (String) v.elementAt(2)
             + "></TD></TR><TR><TD>CreditLimit</TD><TD><INPUT id=text4 name=cl value="
             + v.get(3).toString());
     pw.println(
         "></TD></TR><TR><TD><P>Staus</P></TD><td><SELECT id=select1 name=status style='HEIGHT: 22px; LEFT: 1px; TOP: 1px; WIDTH: 136px'> <OPTION ");
     pw.println(
         "selected value=''></OPTION><OPTION value=Active>Active</OPTION><OPTION value=Inactive>Inactive</OPTION></SELECT><INPUT id=submit1 name=submit1 style='LEFT: 151px; TOP: 318px' type=submit value=Delete></TD></TR>");
     pw.println("</table></center></form></body></html>");
     pw.flush();
     pw.close();
   }
 }
 public void service(
     HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
     throws ServletException, IOException {
   System.out.println("This is my service");
   String s = "";
   String s2 = "";
   String s4 = "";
   String s6 = "";
   String s7 = "";
   String s8 = "";
   java.io.PrintWriter printwriter = httpservletresponse.getWriter();
   httpservletresponse.setContentType("text/html");
   HttpSession httpsession = httpservletrequest.getSession(true);
   s6 = (String) httpsession.getValue("co");
   s7 = (String) httpsession.getValue("na");
   s8 = (String) httpsession.getValue("ss");
   try {
     String s1 = httpservletrequest.getParameter("text1");
     String s3 = httpservletrequest.getParameter("text2");
     String s5 = httpservletrequest.getParameter("text3");
     System.out.println("code iiiiis" + s1);
     System.out.println("cname iss" + s3);
     System.out.println("status iss" + s5);
     int i =
         st.executeUpdate(
             "update categoryies set categoryname='"
                 + s3
                 + "',status='"
                 + s5
                 + "' where categoryid='"
                 + s1
                 + "'");
     System.out.println(
         "update categoryies set categoryname='" + s3 + "' where categorycode='" + s1 + "'");
     System.out.println(i + " is updated");
     httpservletresponse.sendRedirect("./categories");
   } catch (Exception exception) {
     System.out.println(exception);
   }
 }
 public void doPost(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   // I use "session" in order to throws the object named user bean.
   HttpSession session = request.getSession(true);
   response.setContentType("text/html");
   request.setCharacterEncoding("UTF-8");
   UserBean ub = (UserBean) session.getAttribute("user");
   if (ub == null) {
     String haveLogin = "******";
     session.setAttribute("haveLogin", haveLogin);
     response.sendRedirect("cart");
   } else {
     String mID = ub.getmID();
     String iID = (String) request.getParameter("iID");
     // String idx = (String)request.getParameter("idx");
     Connection conn = null;
     try {
       // Getting the connection from database.
       Class.forName("com.mysql.jdbc.Driver");
       /*conn = DriverManager
       .getConnection("jdbc:mysql://localhost/se?"
       		+ "user=root");*/
       conn =
           DriverManager.getConnection(
               "jdbc:mysql://localhost/user_register?"
                   + "user=sqluser&password=sqluserpw&useUnicode=true&characterEncoding=UTF-8");
       String sql = "delete from cart_item_mapping where mID=? and iID = ?";
       PreparedStatement pst = conn.prepareStatement(sql);
       // Using preparedstatement by set the parameter related to "?" symbol.
       pst.setString(1, mID);
       pst.setString(2, iID);
       pst.executeUpdate();
       pst.close();
       response.sendRedirect("ShowCartController");
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
  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();
    }
  }
Exemple #19
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    response.setContentType("text/html");
    HttpSession session = request.getSession(false);
    String reseller = null;
    if (session != null && session.getAttribute("reseller") != null)
      reseller = "%" + session.getAttribute("reseller") + "%";
    List<LicenseData> searchResult = null;
    if (reseller != null) {
      /*  session.setAttribute("fieldsearch", true);
      session.removeAttribute("datesearch");*/

      if (request.getParameter("so") != null && !request.getParameter("so").isEmpty()) {

        log.info(
            "Search Fields : Sales Order Search "
                + request.getParameter("so")
                + " for reseller "
                + session.getAttribute("reseller"));

        searchResult = getSearchByFieldResults(reseller, request.getParameter("so"), "so");

        session.setAttribute("so", request.getParameter("so"));
        session.removeAttribute("enduser");
        session.removeAttribute("ek");
        session.setAttribute("label", "Sales Order");
        session.setAttribute("value", request.getParameter("so"));

      } else if (request.getParameter("enduser") != null
          && !request.getParameter("enduser").isEmpty()) {

        log.info(
            "Search Fields : End User Search "
                + request.getParameter("enduser")
                + " for reseller "
                + session.getAttribute("reseller"));

        searchResult =
            getSearchByFieldResults(reseller, request.getParameter("enduser"), "enduser");
        session.setAttribute("enduser", request.getParameter("enduser"));
        session.removeAttribute("so");
        session.removeAttribute("sno");
        session.removeAttribute("ek");
        session.setAttribute("label", "End User");
        session.setAttribute("value", request.getParameter("enduser"));

      } else if (request.getParameter("ek") != null && !request.getParameter("ek").isEmpty()) {

        log.info(
            "Search Fields : Entitlement Key Search "
                + request.getParameter("ek")
                + " for reseller "
                + session.getAttribute("reseller"));

        searchResult = getSearchByFieldResults(reseller, request.getParameter("ek"), "ek");
        session.setAttribute("ek", request.getParameter("ek"));
        session.removeAttribute("so");
        session.removeAttribute("sno");
        session.removeAttribute("enduser");
        session.setAttribute("label", "Entitlement Key");
        session.setAttribute("value", request.getParameter("ek"));

      } else if (request.getParameter("sno") != null && !request.getParameter("sno").isEmpty()) {

        log.info(
            "Search Fields : Serial Number Search "
                + request.getParameter("sno")
                + " for reseller "
                + session.getAttribute("reseller"));

        searchResult = getSearchByFieldResults(reseller, request.getParameter("sno"), "sno");
        session.setAttribute("sno", request.getParameter("sno"));
        session.removeAttribute("ek");
        session.removeAttribute("so");
        session.removeAttribute("enduser");
        request.setAttribute("sno", 1);
        session.setAttribute("label", "Serial Number");
        session.setAttribute("value", request.getParameter("sno"));

      } else if (request.getParameter("po") != null && !request.getParameter("po").isEmpty()) {

        log.info(
            "Search Fields : Purchase Order Search "
                + request.getParameter("po")
                + " for reseller "
                + session.getAttribute("reseller"));

        searchResult = getSearchByFieldResults(reseller, request.getParameter("po"), "po");
        session.setAttribute("po", request.getParameter("po"));
        session.setAttribute("label", "Purchase Order");
        session.setAttribute("value", request.getParameter("po"));

      } else if (request.getParameter("hm") != null && !request.getParameter("hm").isEmpty()) {

        log.info(
            "Search Fields : HM ID Search "
                + request.getParameter("hm")
                + " for reseller "
                + session.getAttribute("hm"));

        searchResult = getSearchByFieldResults(reseller, request.getParameter("hm"), "hm");
        session.setAttribute("hm", request.getParameter("hm"));
        session.setAttribute("label", "Hive Manager ID");
        session.setAttribute("value", request.getParameter("hm"));
      }

      session.setAttribute("fieldSearchList", searchResult);
      String nextJSP = "/viewFieldSearchResult.jsp";
      RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
      dispatcher.forward(request, response);
    } else {

      log.info("Search Fields : Reseller Blank  ");
      String nextJSP = "/login.jsp";
      RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
      dispatcher.forward(request, response);
    }
  }
  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();
    PrintWriter out = response.getWriter();
    ServletContext application;
    HttpSession session = request.getSession();
    nseer_db_backup1 finance_db = new nseer_db_backup1(dbApplication);
    ValidataNumber validata = new ValidataNumber();
    try {

      if (finance_db.conn((String) dbSession.getAttribute("unit_db_name"))) {
        String file_id = request.getParameter("file_id");
        String balance_sum = request.getParameter("balance_sum");
        String balance_sum1 = request.getParameter("balance_sum1");
        if (validata.validata(balance_sum) && validata.validata(balance_sum1)) {
          String sql2 = "select id from finance_bill where tag='1' and file_id='" + file_id + "'";
          ResultSet rs2 = finance_db.executeQuery(sql2);
          String sql = "";
          if (rs2.next()) {
            sql =
                "update finance_bill set debit_subtotal='"
                    + balance_sum1
                    + "' where tag='1' and file_id='"
                    + file_id
                    + "'";
          } else {

            sql =
                "insert into finance_bill(debit_subtotal,file_id,tag) values('"
                    + balance_sum1
                    + "','"
                    + file_id
                    + "','1')";
          }
          finance_db.executeUpdate(sql);

          sql2 =
              "select id from finance_voucher where account_period='18' and chain_id='"
                  + file_id
                  + "'";
          rs2 = finance_db.executeQuery(sql2);
          if (rs2.next()) {
            sql =
                "update finance_voucher set debit_subtotal='"
                    + balance_sum
                    + "' where account_period='18' and chain_id='"
                    + file_id
                    + "'";
          } else {

            sql =
                "insert into finance_voucher(debit_subtotal,chain_id,account_period) values('"
                    + balance_sum
                    + "','"
                    + file_id
                    + "','18')";
          }
          finance_db.executeUpdate(sql);

          finance_db.commit();
          finance_db.close();
        } else {
          out.println("1");
        }
      } else {
        response.sendRedirect("error_conn.htm");
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Exemple #21
0
  public synchronized void doPost(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();

    try {
      PrintWriter out = response.getWriter();

      nseer_db_backup1 stock_db = new nseer_db_backup1(dbApplication);
      nseer_db_backup1 crm_db = new nseer_db_backup1(dbApplication);
      if (stock_db.conn((String) dbSession.getAttribute("unit_db_name"))
          && crm_db.conn((String) dbSession.getAttribute("unit_db_name"))) {

        FileKind FileKind = new FileKind();
        ValidataNumber validata = new ValidataNumber();
        ValidataRecord vr = new ValidataRecord();

        counter count = new counter(dbApplication);
        ValidataTag vt = new ValidataTag();
        String register_ID = (String) dbSession.getAttribute("human_IDD");
        String config_id = request.getParameter("config_id");
        String pay_ID = request.getParameter("pay_ID");
        String product_amount = request.getParameter("product_amount");
        int num = Integer.parseInt(product_amount);
        String payer_name = request.getParameter("payer_name");
        String payer_ID = request.getParameter("payer_ID");
        String reason = request.getParameter("reason");
        String not_return_tag = request.getParameter("not_return_tag");
        String register = request.getParameter("register");
        String register_time = request.getParameter("register_time");
        String demand_return_time = request.getParameter("demand_return_time");
        String sales_name = request.getParameter("sales_name");
        String sales_ID = request.getParameter("sales_ID");
        String bodyc = new String(request.getParameter("remark").getBytes("UTF-8"), "UTF-8");
        String remark = exchange.toHtml(bodyc);
        String time = "";
        java.util.Date now = new java.util.Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
        time = formatter.format(now);
        String[] product_IDn = request.getParameterValues("product_ID");
        String[] amountn = request.getParameterValues("amount");
        if (num == 0 && product_IDn.length == 1) {
          response.sendRedirect("draft/crm/credit_ok_a.jsp?pay_ID=" + pay_ID);
        } else {
          int p = 0;
          for (int i = 1; i <= num; i++) {
            String tem_amount = "amount" + i;
            String amount = request.getParameter(tem_amount);
            if (amount.equals("")) amount = "0";
            if (!validata.validata(amount)) {
              p++;
            }
          }
          int n = 0;
          String product_ID_group = "";
          for (int j = 1; j < product_IDn.length; j++) {
            product_ID_group += product_IDn[j] + ",";
            if (amountn[j].equals("")) amountn[j] = "0";
            if (!validata.validata(amountn[j])) {
              p++;
            }
          }
          for (int i = 1; i <= num; i++) {
            String tem_product_ID = "product_ID" + i;
            String product_ID = request.getParameter(tem_product_ID);
            if (product_ID_group.indexOf(product_ID) != -1) n++;
          }
          if (vt.validata(
                      (String) dbSession.getAttribute("unit_db_name"),
                      "stock_apply_pay",
                      "pay_ID",
                      pay_ID,
                      "check_tag")
                  .equals("9")
              || vt.validata(
                      (String) dbSession.getAttribute("unit_db_name"),
                      "stock_apply_pay",
                      "pay_ID",
                      pay_ID,
                      "check_tag")
                  .equals("5")) {

            if (p == 0) {
              try {
                if (n == 0) {
                  boolean flag = false;
                  List rsList = GetWorkflow.getList(crm_db, "crm_config_workflow", "05");
                  String[] elem = new String[3];
                  if (rsList.size() == 0) {
                    flag = true;
                  }
                  String sqll = "";
                  String[] aaa1 =
                      FileKind.getKind(
                          (String) dbSession.getAttribute("unit_db_name"),
                          "crm_file",
                          "customer_ID",
                          payer_ID);

                  String stock_pay_ID =
                      NseerId.getId("stock/pay", (String) dbSession.getAttribute("unit_db_name"));
                  double demand_amount = 0.0d;
                  double list_price_sum = 0.0d;
                  double cost_price_sum = 0.0d;

                  for (int i = 1; i <= num; i++) {
                    String tem_product_name = "product_name" + i;
                    String tem_product_ID = "product_ID" + i;
                    String tem_available_amount = "available_amount" + i;
                    String tem_amount = "amount" + i;
                    String tem_list_price = "list_price" + i;
                    String tem_cost_price = "cost_price" + i;
                    String tem_type = "type" + i;
                    String tem_amount_unit = "amount_unit" + i;
                    String product_name = request.getParameter(tem_product_name);
                    String product_ID = request.getParameter(tem_product_ID);
                    String available_amount = request.getParameter(tem_available_amount);
                    String amount = request.getParameter(tem_amount);
                    if (amount.equals("")) amount = "0";
                    String list_price2 = request.getParameter(tem_list_price);
                    String cost_price = request.getParameter(tem_cost_price);
                    String type = request.getParameter(tem_type);
                    StringTokenizer tokenTO3 = new StringTokenizer(list_price2, ",");
                    String list_price = "";
                    while (tokenTO3.hasMoreTokens()) {
                      String list_price1 = tokenTO3.nextToken();
                      list_price += list_price1;
                    }
                    String amount_unit = request.getParameter(tem_amount_unit);
                    double list_price_subtotal =
                        Double.parseDouble(list_price) * Double.parseDouble(amount);
                    list_price_sum += list_price_subtotal;
                    double cost_price_subtotal =
                        Double.parseDouble(cost_price) * Double.parseDouble(amount);
                    cost_price_sum += cost_price_subtotal;
                    demand_amount += Double.parseDouble(amount);
                    String sql1 =
                        "update stock_apply_pay_details set amount='"
                            + amount
                            + "',list_price='"
                            + list_price
                            + "',list_price_subtotal='"
                            + list_price_subtotal
                            + "',cost_price='"
                            + cost_price
                            + "',subtotal='"
                            + cost_price_subtotal
                            + "' where pay_ID='"
                            + pay_ID
                            + "' and details_number='"
                            + i
                            + "'";
                    stock_db.executeUpdate(sql1);
                    if (flag) {
                      if (type.equals("物料") || type.equals("外购商品")) {
                        String sql2 =
                            "insert into stock_pay_details(pay_ID,details_number,product_ID,product_name,type,list_price,list_price_subtotal,cost_price,subtotal,amount,unpay_amount,apply_manufacture_amount,apply_purchase_amount) values('"
                                + stock_pay_ID
                                + "','"
                                + i
                                + "','"
                                + product_ID
                                + "','"
                                + product_name
                                + "','"
                                + type
                                + "','"
                                + list_price
                                + "','"
                                + list_price_subtotal
                                + "','"
                                + cost_price
                                + "','"
                                + cost_price_subtotal
                                + "','"
                                + amount
                                + "','"
                                + amount
                                + "','0','"
                                + amount
                                + "')";
                        stock_db.executeUpdate(sql2);
                      } else if (type.equals("商品") || type.equals("部件") || type.equals("委外部件")) {
                        String sql2 =
                            "insert into stock_pay_details(pay_ID,details_number,product_ID,product_name,type,list_price,list_price_subtotal,cost_price,subtotal,amount,unpay_amount,apply_manufacture_amount,apply_purchase_amount) values('"
                                + stock_pay_ID
                                + "','"
                                + i
                                + "','"
                                + product_ID
                                + "','"
                                + product_name
                                + "','"
                                + type
                                + "','"
                                + list_price
                                + "','"
                                + list_price_subtotal
                                + "','"
                                + cost_price
                                + "','"
                                + cost_price_subtotal
                                + "','"
                                + amount
                                + "','"
                                + amount
                                + "','"
                                + amount
                                + "','0')";
                        stock_db.executeUpdate(sql2);
                      }

                      String sql97 =
                          "select * from crm_salecredit_balance_details where crediter_ID='"
                              + payer_ID
                              + "' and product_ID='"
                              + product_ID
                              + "'";
                      ResultSet rs97 = crm_db.executeQuery(sql97);
                      if (rs97.next()) {
                        double balance_amount =
                            rs97.getDouble("amount") + Double.parseDouble(amount);
                        double balance_cost_price_subtotal =
                            rs97.getDouble("subtotal") + cost_price_subtotal;
                        double balance_list_price_subtotal =
                            rs97.getDouble("list_price_subtotal") + list_price_subtotal;

                        String sql96 =
                            "update crm_salecredit_balance_details set amount='"
                                + balance_amount
                                + "',check_tag='1',subtotal='"
                                + balance_cost_price_subtotal
                                + "',list_price_subtotal='"
                                + balance_list_price_subtotal
                                + "' where crediter_ID='"
                                + payer_ID
                                + "' and product_ID='"
                                + product_ID
                                + "'";
                        crm_db.executeUpdate(sql96);
                      } else {
                        String[] aaa =
                            FileKind.getKind(
                                (String) dbSession.getAttribute("unit_db_name"),
                                "design_file",
                                "product_ID",
                                product_ID);
                        String sql95 =
                            "insert into crm_salecredit_balance_details(chain_ID,chain_name,crediter_chain_ID,crediter_chain_name,product_ID,product_name,list_price,list_price_subtotal,cost_price,subtotal,amount,crediter_ID,crediter_name) values('"
                                + aaa[0]
                                + "','"
                                + aaa[1]
                                + "','"
                                + aaa1[0]
                                + "','"
                                + aaa1[1]
                                + "','"
                                + product_ID
                                + "','"
                                + product_name
                                + "','"
                                + list_price
                                + "','"
                                + list_price_subtotal
                                + "','"
                                + cost_price
                                + "','"
                                + cost_price_subtotal
                                + "','"
                                + amount
                                + "','"
                                + payer_ID
                                + "','"
                                + payer_name
                                + "')";
                        crm_db.executeUpdate(sql95);
                      }
                    }
                  }
                  String[] cost_pricen = request.getParameterValues("cost_price");
                  String[] list_pricen = request.getParameterValues("list_price");
                  String[] product_namen = request.getParameterValues("product_name");
                  String[] product_describen = request.getParameterValues("product_describe");
                  String[] amount_unitn = request.getParameterValues("amount_unit");
                  String[] typen = request.getParameterValues("type");
                  for (int i = 1; i < product_IDn.length; i++) {
                    StringTokenizer tokenTO3 = new StringTokenizer(list_pricen[i], ",");
                    String list_price = "";
                    while (tokenTO3.hasMoreTokens()) {
                      String list_price1 = tokenTO3.nextToken();
                      list_price += list_price1;
                    }
                    if (!amountn[i].equals("") && Double.parseDouble(amountn[i]) != 0) {
                      double list_price_subtotal =
                          Double.parseDouble(list_price) * Double.parseDouble(amountn[i]);
                      list_price_sum += list_price_subtotal;
                      double subtotal =
                          Double.parseDouble(cost_pricen[i]) * Double.parseDouble(amountn[i]);
                      cost_price_sum += subtotal;
                      demand_amount += Double.parseDouble(amountn[i]);
                      num++;
                      String sql1 =
                          "insert into stock_apply_pay_details(payer_chain_ID,payer_chain_name,sales_ID,sales_name,payer_ID,payer_name,payer_type,pay_ID,details_number,product_ID,product_name,product_describe,amount,amount_unit,list_price,list_price_subtotal,cost_price,subtotal,type) values ('"
                              + aaa1[0]
                              + "','"
                              + aaa1[1]
                              + "','"
                              + sales_ID
                              + "','"
                              + sales_name
                              + "','"
                              + payer_ID
                              + "','"
                              + payer_name
                              + "','销售赊货','"
                              + pay_ID
                              + "','"
                              + num
                              + "','"
                              + product_IDn[i]
                              + "','"
                              + product_namen[i]
                              + "','"
                              + product_describen[i]
                              + "','"
                              + amountn[i]
                              + "','"
                              + amount_unitn[i]
                              + "','"
                              + list_price
                              + "','"
                              + list_price_subtotal
                              + "','"
                              + cost_pricen[i]
                              + "','"
                              + subtotal
                              + "','"
                              + typen[i]
                              + "')";
                      stock_db.executeUpdate(sql1);
                      // **********************
                      if (rsList.size() == 0) {
                        if (typen[i].equals("物料") || typen[i].equals("外购商品")) {
                          String sql2 =
                              "insert into stock_pay_details(pay_ID,details_number,product_ID,product_name,type,list_price,list_price_subtotal,cost_price,subtotal,amount,unpay_amount,apply_manufacture_amount,apply_purchase_amount) values('"
                                  + stock_pay_ID
                                  + "','"
                                  + num
                                  + "','"
                                  + product_IDn[i]
                                  + "','"
                                  + product_namen[i]
                                  + "','"
                                  + typen[i]
                                  + "','"
                                  + list_price
                                  + "','"
                                  + list_price_subtotal
                                  + "','"
                                  + cost_pricen[i]
                                  + "','"
                                  + subtotal
                                  + "','"
                                  + amountn[i]
                                  + "','"
                                  + amountn[i]
                                  + "','0','"
                                  + amountn[i]
                                  + "')";
                          stock_db.executeUpdate(sql2);
                        } else if (typen[i].equals("商品")
                            || typen[i].equals("部件")
                            || typen[i].equals("委外部件")) {
                          String sql2 =
                              "insert into stock_pay_details(pay_ID,details_number,product_ID,product_name,type,list_price,list_price_subtotal,cost_price,subtotal,amount,unpay_amount,apply_manufacture_amount,apply_purchase_amount) values('"
                                  + stock_pay_ID
                                  + "','"
                                  + num
                                  + "','"
                                  + product_IDn[i]
                                  + "','"
                                  + product_namen[i]
                                  + "','"
                                  + typen[i]
                                  + "','"
                                  + list_price
                                  + "','"
                                  + list_price_subtotal
                                  + "','"
                                  + cost_pricen[i]
                                  + "','"
                                  + subtotal
                                  + "','"
                                  + amountn[i]
                                  + "','"
                                  + amountn[i]
                                  + "','"
                                  + amountn[i]
                                  + "','0')";
                          stock_db.executeUpdate(sql2);
                        }

                        String sql97 =
                            "select * from crm_salecredit_balance_details where crediter_ID='"
                                + payer_ID
                                + "' and product_ID='"
                                + product_IDn[i]
                                + "'";
                        ResultSet rs97 = crm_db.executeQuery(sql97);
                        if (rs97.next()) {
                          double balance_amount =
                              rs97.getDouble("amount") + Double.parseDouble(amountn[i]);
                          double balance_cost_price_subtotal =
                              rs97.getDouble("subtotal") + subtotal;
                          double balance_list_price_subtotal =
                              rs97.getDouble("list_price_subtotal") + list_price_subtotal;

                          String sql96 =
                              "update crm_salecredit_balance_details set amount='"
                                  + balance_amount
                                  + "',check_tag='1',subtotal='"
                                  + balance_cost_price_subtotal
                                  + "',list_price_subtotal='"
                                  + balance_list_price_subtotal
                                  + "' where crediter_ID='"
                                  + payer_ID
                                  + "' and product_ID='"
                                  + product_IDn[i]
                                  + "'";
                          crm_db.executeUpdate(sql96);
                        } else {
                          String[] aaa =
                              FileKind.getKind(
                                  (String) dbSession.getAttribute("unit_db_name"),
                                  "design_file",
                                  "product_ID",
                                  product_IDn[i]);
                          String sql95 =
                              "insert into crm_salecredit_balance_details(chain_ID,chain_name,crediter_chain_ID,crediter_chain_name,product_ID,product_name,list_price,list_price_subtotal,cost_price,subtotal,amount,crediter_ID,crediter_name) values('"
                                  + aaa[0]
                                  + "','"
                                  + aaa[1]
                                  + "','"
                                  + aaa1[0]
                                  + "','"
                                  + aaa1[1]
                                  + "','"
                                  + product_IDn[i]
                                  + "','"
                                  + product_namen[i]
                                  + "','"
                                  + list_price
                                  + "','"
                                  + list_price_subtotal
                                  + "','"
                                  + cost_pricen[i]
                                  + "','"
                                  + subtotal
                                  + "','"
                                  + amountn[i]
                                  + "','"
                                  + payer_ID
                                  + "','"
                                  + payer_name
                                  + "')";
                          crm_db.executeUpdate(sql95);
                        }
                      }
                      // ***************************
                    }
                  }
                  String sql =
                      "update stock_apply_pay set reason='"
                          + reason
                          + "',register='"
                          + register
                          + "',register_time='"
                          + register_time
                          + "',demand_return_time='"
                          + demand_return_time
                          + "',register_time='"
                          + register_time
                          + "',register='"
                          + register
                          + "',remark='"
                          + remark
                          + "',demand_amount='"
                          + demand_amount
                          + "',list_price_sum='"
                          + list_price_sum
                          + "',cost_price_sum='"
                          + cost_price_sum
                          + "',not_return_tag='"
                          + not_return_tag
                          + "' where pay_ID='"
                          + pay_ID
                          + "'";
                  stock_db.executeUpdate(sql);
                  if (flag) {
                    sql = "update stock_apply_pay set check_tag='1' where pay_ID='" + pay_ID + "'";
                    stock_db.executeUpdate(sql);
                    if (!vr.validata(
                        (String) dbSession.getAttribute("unit_db_name"),
                        "stock_pay",
                        "reasonexact",
                        pay_ID)) {
                      String sql4 =
                          "insert into stock_pay(pay_ID,reason,reasonexact,reasonexact_details,demand_amount,list_price_sum,cost_price_sum,register,register_time) values('"
                              + stock_pay_ID
                              + "','"
                              + reason
                              + "','"
                              + pay_ID
                              + "','"
                              + payer_name
                              + "','"
                              + demand_amount
                              + "','"
                              + list_price_sum
                              + "','"
                              + cost_price_sum
                              + "','"
                              + register
                              + "','"
                              + register_time
                              + "')";
                      stock_db.executeUpdate(sql4);
                    }

                    String sql98 = "select * from crm_file where customer_ID='" + payer_ID + "'";
                    ResultSet rs98 = crm_db.executeQuery(sql98);
                    if (rs98.next()) {
                      double salecredit_list_price_sum =
                          rs98.getDouble("salecredit_list_price_sum") + list_price_sum;
                      double salecredit_cost_price_sum =
                          rs98.getDouble("salecredit_cost_price_sum") + cost_price_sum;

                      String sql99 =
                          "update crm_file set credit_yes_or_not_tag='1',salecredit_list_price_sum='"
                              + salecredit_list_price_sum
                              + "',salecredit_cost_price_sum='"
                              + salecredit_cost_price_sum
                              + "' where customer_ID='"
                              + payer_ID
                              + "' ";
                      crm_db.executeUpdate(sql99);
                    }
                  } else {
                    sql = "update stock_apply_pay set check_tag='0' where pay_ID='" + pay_ID + "'";
                    stock_db.executeUpdate(sql);
                    Iterator ite = rsList.iterator();
                    while (ite.hasNext()) {
                      elem = (String[]) ite.next();
                      sql =
                          "insert into crm_workflow(config_id,object_ID,describe1,describe2) values ('"
                              + elem[0]
                              + "','"
                              + pay_ID
                              + "','"
                              + elem[1]
                              + "','"
                              + elem[2]
                              + "')";
                      crm_db.executeUpdate(sql);
                    }
                  }

                  response.sendRedirect("draft/crm/credit_ok.jsp?finished_tag=8");
                } else {

                  response.sendRedirect(
                      "draft/crm/credit_ok.jsp?finished_tag=7&pay_ID=" + pay_ID + "");
                }
              } catch (Exception ex) {
                ex.printStackTrace();
              }
            } else {

              response.sendRedirect("draft/crm/credit_ok.jsp?finished_tag=6&pay_ID=" + pay_ID + "");
            }
          } else {

            response.sendRedirect("draft/crm/credit_ok.jsp?finished_tag=9");
          }
        }
        stock_db.commit();
        crm_db.commit();
        stock_db.close();
        crm_db.close();
      } else {
        response.sendRedirect("error_conn.htm");
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Exemple #22
0
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    request.setCharacterEncoding("gb2312");
    response.setContentType("text/html; charset=gb2312");
    out = response.getWriter();
    session = request.getSession();
    time = new Time();
    str = new Str();
    db = new Db();

    // 取得
    try {
      id = Integer.parseInt((String) request.getParameter("id"));
    } catch (Exception e) {
      id = 0;
    }
    password = request.getParameter("password");
    password = str.inStr(password);
    sqlsp = "SELECT * FROM password WHERE employeeid=" + id;
    sqlse = "SELECT employeeid FROM eminfo WHERE employeeid=" + id;
    sqlu =
        "UPDATE password SET time='"
            + time.getYMDHMS()
            + "',password='******' WHERE employeeid="
            + id;
    sqli =
        "INSERT INTO password(employeeid,password,time) VALUES("
            + id
            + ",'"
            + password
            + "','"
            + time.getYMDHMS()
            + "')";
    try {
      stmt = db.getStmtread();
      rs = stmt.executeQuery(sqlsp);
      // 不是第一次设置更新数据库
      if (rs.next()) {
        db.close();
        stmt = db.getStmt();
        temp = 0;
        temp = stmt.executeUpdate(sqlu);
        if (temp > 0) {
          request.setAttribute("msg", "设置成功");
        } else {
          request.setAttribute("msg", "设置失败");
        }
        db.close();
      } else {
        // 第一次设置
        db.close();
        temp = 0;
        stmt = db.getStmtread();
        rs = stmt.executeQuery(sqlse);
        if (rs.next()) {
          // id存在
          rs.close();
          stmt.close();
          temp = 0;
          stmt = db.getStmt();
          temp = stmt.executeUpdate(sqli);
          if (temp > 0) {
            request.setAttribute("msg", "设置成功");
          } else {
            request.setAttribute("msg", "设置失败");
          }
          db.close();
        } else {
          // id不存在
          db.close();
          request.setAttribute("msg", "员工序号不存在");
        }
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      RequestDispatcher dispatcher = request.getRequestDispatcher("set1.jsp");
      dispatcher.forward(request, response);
    }
  }
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html");

    HttpSession session = request.getSession(false);
    if (session == null) {
      session = request.getSession();
    }

    PrintWriter out = response.getWriter();
    Connection conn = null;
    Statement stmt = null;
    try {
      System.out.println("Enrollno: 130050131067");
      // STEP 2: Register JDBC driver
      Class.forName(JDBC_DRIVER);

      // STEP 3: Open a connection
      System.out.println("Connecting to a selected database...");
      conn = DriverManager.getConnection(DB_URL, USER, PASS);
      System.out.println("Connected database successfully...");

      stmt = conn.createStatement();

      // STEP 2: Executing query
      String name = "asdf";
      String rollno = "34";
      String branch = "CSE";
      String sql =
          "INSERT INTO student(rollno, name, branch) VALUES ('"
              + rollno
              + "', '"
              + name
              + "', '"
              + branch
              + "')";

      if (stmt.executeUpdate(sql) != 0) {
        out.println("Record has been inserted</br>");
      } else {
        out.println("Sorry! Failure</br>");
      }
    } catch (SQLException se) {
      // Handle errors for JDBC
      se.printStackTrace();
    } catch (Exception e) {
      // Handle errors for Class.forName
      e.printStackTrace();
    } finally {
      // finally block used to close resources
      try {
        if (stmt != null) conn.close();
      } catch (SQLException se) {
      } // do nothing
      try {
        if (conn != null) conn.close();
      } catch (SQLException se) {
        se.printStackTrace();
      } // end finally try
    } // end try
  }
Exemple #24
0
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    // Variable initializations.
    HttpSession session = request.getSession();
    FileItem image_file = null;
    int record_id = 0;
    int image_id;

    // Check if a record ID has been entered.
    if (request.getParameter("recordID") == null || request.getParameter("recordID").equals("")) {
      // If no ID has been entered, send message to jsp.
      response_message =
          "<p><font color=FF0000>No Record ID Detected, Please Enter One.</font></p>";
      session.setAttribute("msg", response_message);
      response.sendRedirect("UploadImage.jsp");
    }

    try {
      // Parse the HTTP request to get the image stream.
      DiskFileUpload fu = new DiskFileUpload();
      // Will get multiple image files if that happens and can be accessed through FileItems.
      List<FileItem> FileItems = fu.parseRequest(request);

      // Connect to the database and create a statement.
      conn = getConnected(drivername, dbstring, username, password);
      stmt = conn.createStatement();

      // Process the uploaded items, assuming only 1 image file uploaded.
      Iterator<FileItem> i = FileItems.iterator();

      while (i.hasNext()) {
        FileItem item = (FileItem) i.next();

        // Test if item is a form field and matches recordID.
        if (item.isFormField()) {
          if (item.getFieldName().equals("recordID")) {
            // Covert record id from string to integer.
            record_id = Integer.parseInt(item.getString());

            String sql = "select count(*) from radiology_record where record_id = " + record_id;
            int count = 0;

            try {
              rset = stmt.executeQuery(sql);

              while (rset != null && rset.next()) {
                count = (rset.getInt(1));
              }
            } catch (SQLException e) {
              response_message = e.getMessage();
            }

            // Check if recordID is in the database.
            if (count == 0) {
              // Invalid recordID, send message to jsp.
              response_message =
                  "<p><font color=FF0000>Record ID Does Not Exist In Database.</font></p>";
              session.setAttribute("msg", response_message);
              // Close connection.
              conn.close();
              response.sendRedirect("UploadImage.jsp");
            }
          }
        } else {
          image_file = item;

          if (image_file.getName().equals("")) {
            // No file, send message to jsp.
            response_message = "<p><font color=FF0000>No File Selected For Record ID.</font></p>";
            session.setAttribute("msg", response_message);
            // Close connection.
            conn.close();
            response.sendRedirect("UploadImage.jsp");
          }
        }
      }

      // Get the image stream.
      InputStream instream = image_file.getInputStream();

      BufferedImage full_image = ImageIO.read(instream);
      BufferedImage thumbnail = shrink(full_image, 10);
      BufferedImage regular_image = shrink(full_image, 5);

      // First, to generate a unique img_id using an SQL sequence.
      rset1 = stmt.executeQuery("SELECT image_id_sequence.nextval from dual");
      rset1.next();
      image_id = rset1.getInt(1);

      // Insert an empty blob into the table first. Note that you have to
      // use the Oracle specific function empty_blob() to create an empty blob.
      stmt.execute(
          "INSERT INTO pacs_images VALUES("
              + record_id
              + ","
              + image_id
              + ", empty_blob(), empty_blob(), empty_blob())");

      // to retrieve the lob_locator
      // Note that you must use "FOR UPDATE" in the select statement
      String cmd = "SELECT * FROM pacs_images WHERE image_id = " + image_id + " FOR UPDATE";
      rset = stmt.executeQuery(cmd);
      rset.next();
      BLOB myblobFull = ((OracleResultSet) rset).getBLOB(5);
      BLOB myblobThumb = ((OracleResultSet) rset).getBLOB(3);
      BLOB myblobRegular = ((OracleResultSet) rset).getBLOB(4);

      // Write the full size image to the blob object.
      OutputStream fullOutstream = myblobFull.getBinaryOutputStream();
      ImageIO.write(full_image, "jpg", fullOutstream);
      // Write the thumbnail size image to the blob object.
      OutputStream thumbOutstream = myblobThumb.getBinaryOutputStream();
      ImageIO.write(thumbnail, "jpg", thumbOutstream);
      // Write the regular size image to the blob object.
      OutputStream regularOutstream = myblobRegular.getBinaryOutputStream();
      ImageIO.write(regular_image, "jpg", regularOutstream);

      // Commit the changes to database.
      stmt.executeUpdate("commit");
      response_message = "<p><font color=00CC00>Upload Successful.</font></p>";
      session.setAttribute("msg", response_message);

      instream.close();
      fullOutstream.close();
      thumbOutstream.close();
      regularOutstream.close();

      // Close connection.
      conn.close();
      response.sendRedirect("UploadImage.jsp");

      instream.close();
      fullOutstream.close();
      thumbOutstream.close();
      regularOutstream.close();

      // Close connection.
      conn.close();
    } catch (Exception ex) {
      response_message = ex.getMessage();
    }
  }
  public void service(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();

    Connection con = null;

    String bnm[] = req.getParameterValues("Comics");

    String qty[] = new String[bnm.length];
    ArrayList al1 = new ArrayList();
    ArrayList al2 = new ArrayList();
    for (int i = 0; i < bnm.length; i++) {
      qty[i] = req.getParameter(bnm[i]);
      al1.add(bnm[i]);
      al2.add(qty[i]);
    }

    HttpSession HSession = req.getSession(true);

    ArrayList alo1 = (ArrayList) HSession.getValue("bNames");
    ArrayList alo2 = (ArrayList) HSession.getValue("bQty");

    al1.addAll(alo1);
    al2.addAll(alo2);

    HSession.putValue("bNames", al1);
    HSession.putValue("bQty", al2);

    out.println("<html>");
    out.println("<title>Categories..</title>");
    out.println("<body bgcolor=gold >");

    out.println("<b><font face=\"Papyrus\" size=36 color= #806F7E><center>");
    out.println("<big>Category</big></center>");

    out.println("<ul type=disc>");
    out.println("<font face=\"Maiandra GD\" color=black size=4>");
    out.println("<li type=square>Choose your category..");
    out.println("</li></font><br>");

    out.println(
        "<A href=\"FictionClick\"><font face=\"Mistral\" size=8 color=#208234><b>Fiction</b></A><br>");

    out.println(
        "<A href=\"NonFictionClick\"><font face=\"Mistral\" size=8 color=#208234><b>Non-Fiction</b></A><br>");

    out.println(
        "<A href=\"AutobiographyClick\"><font face=\"Mistral\" size=8 color=#208234><b>Autobiography</b></A><br>");

    out.println(
        "<A href=\"HistoryClick\"><font face=\"Mistral\" size=8 color=#208234><b>History</b></A><br>");

    out.println(
        "<A href=\"ComicsClick\"><font face=\"Mistral\" size=8 color=#208234><b>Comics</b></A></font><br><br>");

    out.println("<center><form action=\"http://localhost:8080/servlet/FinalList\">");
    out.println("<input type=submit value=\" Finalize List >>\"></form>");

    out.println("<font face=\"Maiandra GD\" color=black size=4>");
    out.println("Moves to final List..</center>");

    out.println("</font></body>");
    out.println("</html>");
  } // service
  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();

    try {
      // 实例化

      HttpSession session = request.getSession();
      ServletContext context = session.getServletContext();
      String path = context.getRealPath("/");
      counter count = new counter(dbApplication);
      SmartUpload mySmartUpload = new SmartUpload();
      mySmartUpload.setCharset("UTF-8");
      nseer_db_backup1 qcs_db = new nseer_db_backup1(dbApplication);

      if (qcs_db.conn((String) dbSession.getAttribute("unit_db_name"))) {

        mySmartUpload.initialize(pageContext);
        String file_type = getFileLength.getFileType((String) session.getAttribute("unit_db_name"));
        long d = getFileLength.getFileLength((String) session.getAttribute("unit_db_name"));
        mySmartUpload.setMaxFileSize(d);
        mySmartUpload.setAllowedFilesList(file_type);

        try {
          mySmartUpload.upload();
          String qcs_id = mySmartUpload.getRequest().getParameter("qcs_id");
          String config_id = mySmartUpload.getRequest().getParameter("config_id");

          String[] item = mySmartUpload.getRequest().getParameterValues("item");
          if (item != null) {
            String[] file_name = new String[mySmartUpload.getFiles().getCount()];
            String[] not_change = new String[mySmartUpload.getFiles().getCount()];
            java.util.Date now = new java.util.Date();
            SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
            String time = formatter.format(now);
            String standard_id = mySmartUpload.getRequest().getParameter("standard_id");
            String sqla =
                "select attachment1 from qcs_intrmanufacture where qcs_id='"
                    + qcs_id
                    + "' and (check_tag='5' or check_tag='9')";
            ResultSet rs = qcs_db.executeQuery(sqla);
            if (!rs.next()) {
              response.sendRedirect("draft/qcs/intrmanufacture_ok.jsp?finished_tag=1");
            } else {
              String[] attachment = mySmartUpload.getRequest().getParameterValues("attachment");
              String[] delete_file_name = new String[0];
              if (attachment != null) {
                delete_file_name = new String[attachment.length];
                for (int i = 0; i < attachment.length; i++) {
                  delete_file_name[i] = rs.getString(attachment[i]);
                }
              }
              for (int i = 0; i < mySmartUpload.getFiles().getCount(); i++) {
                com.jspsmart.upload.SmartFile file = mySmartUpload.getFiles().getFile(i);
                if (file.isMissing()) {
                  file_name[i] = "";
                  int q = i + 1;
                  String field_name = "attachment" + q;
                  if (!rs.getString(field_name).equals("")) not_change[i] = "yes";
                  continue;
                }
                int filenum =
                    count.read(
                        (String) dbSession.getAttribute("unit_db_name"), "qcsAttachmentcount");
                count.write(
                    (String) dbSession.getAttribute("unit_db_name"), "qcsAttachmentcount", filenum);
                file_name[i] = filenum + file.getFileName();
                file.saveAs(path + "qcs/file_attachments/" + filenum + file.getFileName());
              }
              String apply_id = mySmartUpload.getRequest().getParameter("apply_id");
              String product_id = mySmartUpload.getRequest().getParameter("product_id");
              String product_name = mySmartUpload.getRequest().getParameter("product_name");
              String qcs_amount = mySmartUpload.getRequest().getParameter("qcs_amount");
              String qcs_time = mySmartUpload.getRequest().getParameter("qcs_time");
              String quality_way = mySmartUpload.getRequest().getParameter("quality_way");
              String quality_solution = mySmartUpload.getRequest().getParameter("quality_solution");
              String sampling_standard =
                  mySmartUpload.getRequest().getParameter("sampling_standard");
              String sampling_amount = mySmartUpload.getRequest().getParameter("sampling_amount");
              String accept = mySmartUpload.getRequest().getParameter("accept");
              String reject = mySmartUpload.getRequest().getParameter("reject");
              String qualified = mySmartUpload.getRequest().getParameter("qualified");
              String unqualified = mySmartUpload.getRequest().getParameter("unqualified");
              String qcs_result = mySmartUpload.getRequest().getParameter("qcs_result");
              String checker = mySmartUpload.getRequest().getParameter("checker");
              String checker_id = mySmartUpload.getRequest().getParameter("checker_id");
              String check_time = mySmartUpload.getRequest().getParameter("check_time");
              String changer = mySmartUpload.getRequest().getParameter("changer");
              String changer_id = mySmartUpload.getRequest().getParameter("changer_id");
              String change_time = mySmartUpload.getRequest().getParameter("change_time");
              String bodyab =
                  new String(
                      mySmartUpload.getRequest().getParameter("remark").getBytes("UTF-8"), "UTF-8");
              String remark = exchange.toHtml(bodyab);

              sqla =
                  "update qcs_intrmanufacture set apply_id='"
                      + apply_id
                      + "',product_id='"
                      + product_id
                      + "',product_name='"
                      + product_name
                      + "',qcs_amount='"
                      + qcs_amount
                      + "',qcs_time='"
                      + qcs_time
                      + "',quality_way='"
                      + quality_way
                      + "',quality_solution='"
                      + quality_solution
                      + "',sampling_standard='"
                      + sampling_standard
                      + "',sampling_amount='"
                      + sampling_amount
                      + "',accept='"
                      + accept
                      + "',reject='"
                      + reject
                      + "',qualified='"
                      + qualified
                      + "',unqualified='"
                      + unqualified
                      + "',changer_id='"
                      + changer_id
                      + "',qcs_result='"
                      + qcs_result
                      + "',changer='"
                      + changer
                      + "',change_time='"
                      + change_time
                      + "',remark='"
                      + remark
                      + "',check_tag='5'";
              String sqlb = " where qcs_id='" + qcs_id + "'";
              if (attachment != null) {
                for (int i = 0; i < attachment.length; i++) {
                  sqla = sqla + "," + attachment[i] + "=''";
                  java.io.File file =
                      new java.io.File(path + "qcs/file_attachments/" + delete_file_name[i]);
                  file.delete();
                }
              }
              for (int i = 0; i < mySmartUpload.getFiles().getCount(); i++) {
                if (not_change[i] != null && not_change[i].equals("yes")) continue;
                int p = i + 1;
                sqla = sqla + ",attachment" + p + "='" + file_name[i] + "'";
              }
              String sql = sqla + sqlb;
              qcs_db.executeUpdate(sql);

              sql = "delete from qcs_intrmanufacture_details where qcs_id='" + qcs_id + "'";
              qcs_db.executeUpdate(sql);

              String[] default_basis =
                  mySmartUpload.getRequest().getParameterValues("default_basis");
              String[] ready_basis = mySmartUpload.getRequest().getParameterValues("ready_basis");
              String[] quality_method =
                  mySmartUpload.getRequest().getParameterValues("quality_method");
              String[] analyse_method =
                  mySmartUpload.getRequest().getParameterValues("analyse_method");
              String[] standard_value =
                  mySmartUpload.getRequest().getParameterValues("standard_value");
              String[] standard_max = mySmartUpload.getRequest().getParameterValues("standard_max");
              String[] standard_min = mySmartUpload.getRequest().getParameterValues("standard_min");
              String[] quality_value =
                  mySmartUpload.getRequest().getParameterValues("quality_value");
              String[] sampling_amount_d =
                  mySmartUpload.getRequest().getParameterValues("sampling_amount_d");
              String[] qualified_d = mySmartUpload.getRequest().getParameterValues("qualified_d");
              String[] unqualified_d =
                  mySmartUpload.getRequest().getParameterValues("unqualified_d");
              String[] quality_result =
                  mySmartUpload.getRequest().getParameterValues("quality_result");
              String[] unqualified_reason =
                  mySmartUpload.getRequest().getParameterValues("unqualified_reason");
              for (int i = 0; i < item.length; i++) {
                if (!item[i].equals("")) {
                  sql =
                      "insert into qcs_intrmanufacture_details(qcs_id,item,default_basis,ready_basis,quality_method,analyse_method,standard_value,standard_max,standard_min,quality_value,sampling_amount_d,qualified_d,unqualified_d,quality_result,unqualified_reason,details_number) values('"
                          + qcs_id
                          + "','"
                          + item[i]
                          + "','"
                          + default_basis[i]
                          + "','"
                          + ready_basis[i]
                          + "','"
                          + quality_method[i]
                          + "','"
                          + analyse_method[i]
                          + "','"
                          + standard_value[i]
                          + "','"
                          + standard_max[i]
                          + "','"
                          + standard_min[i]
                          + "','"
                          + quality_value[i]
                          + "','"
                          + sampling_amount_d[i]
                          + "','"
                          + qualified_d[i]
                          + "','"
                          + unqualified_d[i]
                          + "','"
                          + quality_result[i]
                          + "','"
                          + unqualified_reason[i]
                          + "','"
                          + i
                          + "')";
                  qcs_db.executeUpdate(sql);
                }
              }
              response.sendRedirect("draft/qcs/intrmanufacture_ok.jsp?finished_tag=0");
            }
            qcs_db.commit();
            qcs_db.close();
          } else {
            response.sendRedirect("draft/qcs/intrmanufacture_ok.jsp?finished_tag=7");
          }

        } catch (Exception ex) {
          response.sendRedirect("draft/qcs/intrmanufacture_ok.jsp?finished_tag=6");
        }

      } else {
        response.sendRedirect("error_conn.htm");
      }

    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    HttpSession session = request.getSession(true);

    try {
      Object accountObject = session.getValue(ACCOUNT);

      // If no account object was put in the session, or
      // if one exists but it is not a hashtable, then
      // redirect the user to the original login page

      if (accountObject == null)
        throw new RuntimeException("You need to log in to use this service!");

      if (!(accountObject instanceof Hashtable))
        throw new RuntimeException("You need to log in to use this service!");

      Hashtable account = (Hashtable) accountObject;

      String userName = (String) account.get("name");

      //////////////////////////////////////////////
      // Display Messages for the user who logged in
      //////////////////////////////////////////////
      out.println("<HTML>");
      out.println("<HEAD>");
      out.println("<TITLE>Contacts for " + userName + "</TITLE>");
      out.println("</HEAD>");
      out.println("<BODY BGCOLOR='#EFEFEF'>");
      out.println("<H3>Welcome " + userName + "</H3>");

      out.println("<CENTER>");

      Connection con = null;
      Statement stmt = null;
      ResultSet rs = null;
      try {
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        con =
            DriverManager.getConnection(
                "jdbc:mysql://localhost/contacts?user=kareena&password=kapoor");

        stmt = con.createStatement();
        rs =
            stmt.executeQuery(
                "SELECT * FROM contacts WHERE userName='******' ORDER BY contactID");

        out.println("<form name='deleteContactsForm' method='post' action='deleteContact'>");

        out.println("<TABLE BGCOLOR='#EFEFFF' CELLPADDING='2' CELLSPACING='4' BORDER='1'>");
        out.println("<TR BGCOLOR='#D6DFFF'>");
        out.println("<TD ALIGN='center'><B>Contact ID</B></TD>");
        out.println("<TD ALIGN='center'><B>Contact Name</B></TD>");
        out.println("<TD ALIGN='center'><B>Comment</B></TD>");
        out.println("<TD ALIGN='center'><B>Date</B></TD>");
        out.println("<TD ALIGN='center'><B>Delete Contacts</B></TD>");
        out.println("</TR>");

        int nRows = 0;
        while (rs.next()) {
          nRows++;
          String messageID = rs.getString("contactID");
          String fromUser = rs.getString("contactName");
          String message = rs.getString("comments");
          String messageDate = rs.getString("dateAdded");

          out.println("<TR>");
          out.println("<TD>" + messageID + "</TD>");
          out.println("<TD>" + fromUser + "</TD>");
          out.println("<TD>" + message + "</TD>");
          out.println("<TD>" + messageDate + "</TD>");
          out.println(
              "<TD><input type='checkbox' name='msgList' value='" + messageID + "'> Delete</TD>");
          out.println("</TR>");
        }

        out.println("<TR>");
        out.println(
            "<TD COLSPAN='6' ALIGN='center'><input type='submit' value='Delete Selected Contacts'></TD>");
        out.println("</TR>");

        out.println("</TABLE>");
        out.println("</FORM>");
      } catch (Exception e) {
        out.println("Could not connect to the users database.<P>");
        out.println("The error message was");
        out.println("<PRE>");
        out.println(e.getMessage());
        out.println("</PRE>");
      } finally {
        if (rs != null) {
          try {
            rs.close();
          } catch (SQLException ignore) {
          }
        }
        if (stmt != null) {
          try {
            stmt.close();
          } catch (SQLException ignore) {
          }
        }
        if (con != null) {
          try {
            con.close();
          } catch (SQLException ignore) {
          }
        }
      }

      out.println("</CENTER>");
      out.println("</BODY>");
      out.println("</HTML>");

    } catch (RuntimeException e) {
      out.println("<script language=\"javascript\">");
      out.println("alert(\"You need to log in to use this service!\");");
      out.println("</script>");

      out.println("<a href='index.html'>Click Here</a> to go to the main page.<br><br>");

      out.println(
          "Or Click on the button to exit<FORM><INPUT onClick=\"javascipt:window.close()\" TYPE=\"BUTTON\" VALUE=\"Close Browser\" TITLE=\"Click here to close window\" NAME=\"CloseWindow\" STYLE=\"font-family:Verdana, Arial, Helvetica; font-size:smaller; font-weight:bold\"></FORM>");

      log(e.getMessage());
      return;
    }
  }
Exemple #28
0
 public void doGet(HttpServletRequest request, HttpServletResponse response) {
   response.setContentType("text/html");
   PrintWriter webPageOutput = null;
   try {
     webPageOutput = response.getWriter();
   } catch (IOException error) {
     Routines.writeToLog(servletName, "getWriter error : " + error, false, context);
   }
   HttpSession session = request.getSession();
   session.setAttribute("redirect", request.getRequestURL() + "?" + request.getQueryString());
   Connection database = null;
   try {
     database = pool.getConnection(servletName);
   } catch (SQLException error) {
     Routines.writeToLog(servletName, "Unable to connect to database : " + error, false, context);
   }
   if (Routines.loginCheck(true, request, response, database, context)) {
     return;
   }
   String server = context.getInitParameter("server");
   boolean liveSever = false;
   if (server == null) {
     server = "";
   }
   if (server.equals("live")) {
     response.setHeader("Refresh", "60");
   }
   Routines.WriteHTMLHead(
       "View System Log", // title
       false, // showMenu
       13, // menuHighLight
       false, // seasonsMenu
       false, // weeksMenu
       false, // scores
       false, // standings
       false, // gameCenter
       false, // schedules
       false, // previews
       false, // teamCenter
       false, // draft
       database, // database
       request, // request
       response, // response
       webPageOutput, // webPageOutput
       context); // context
   webPageOutput.println("<CENTER>");
   webPageOutput.println(
       "<IMG SRC=\"../Images/Admin.gif\"" + " WIDTH='125' HEIGHT='115' ALT='Admin'>");
   webPageOutput.println("</CENTER>");
   pool.returnConnection(database);
   webPageOutput.println(Routines.spaceLines(1));
   Routines.tableStart(false, webPageOutput);
   Routines.tableHeader("System Log", 0, webPageOutput);
   Routines.tableDataStart(true, false, false, true, true, 0, 0, "scoresrow", webPageOutput);
   boolean firstLine = true;
   int numOfLines = 0;
   try {
     String file = context.getRealPath("/");
     FileReader logFile = new FileReader(file + "/Data/log.txt");
     BufferedReader logFileBuffer = new BufferedReader(logFile);
     boolean endOfFile = false;
     while (!endOfFile) {
       String logFileText = logFileBuffer.readLine();
       if (logFileText == null) {
         endOfFile = true;
       } else {
         if (firstLine) {
           firstLine = false;
         } else {
           webPageOutput.println(Routines.spaceLines(1));
         }
         numOfLines++;
         webPageOutput.println(logFileText);
       }
     }
     logFileBuffer.close();
   } catch (IOException error) {
     Routines.writeToLog(servletName, "Problem with log file : " + error, false, context);
   }
   Routines.tableDataEnd(false, true, true, webPageOutput);
   Routines.tableEnd(webPageOutput);
   if (numOfLines < 20) {
     webPageOutput.println(Routines.spaceLines(20 - numOfLines));
   }
   Routines.WriteHTMLTail(request, response, webPageOutput);
 }
 public void service(
     HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
     throws ServletException, IOException {
   String s = "";
   String s1 = "";
   String s2 = "";
   String s3 = "";
   String s4 = "";
   String s6 = "";
   String s7 = "";
   String s8 = "";
   String s9 = "";
   String s10 = "";
   String s11 = "";
   String s12 = "";
   String s13 = "";
   String s14 = "";
   String s16 = "";
   int i = 0;
   int j = 0;
   String s18 = "Level2";
   PrintWriter printwriter = httpservletresponse.getWriter();
   httpservletresponse.setContentType("text/html");
   HttpSession httpsession = httpservletrequest.getSession(true);
   String s17 = (String) httpsession.getValue("uid");
   String name = (String) httpsession.getValue("name");
   System.out.println("inside servicemethod");
   try {
     System.out.println("inside servicetry");
     rs =
         st.executeQuery(
             "select * from hdemp1 where levelname='"
                 + s18
                 + "'  and employeename='"
                 + name
                 + "'");
     if (rs.next()) {
       System.out.println("inside if");
       s = rs.getString(1);
       System.out.println("lnameis " + s);
       s1 = rs.getString(2);
       System.out.println("category id is " + s1);
       s2 = rs.getString(3);
       System.out.println("module id is " + s2);
       s3 = rs.getString(4);
       System.out.println("supportid is " + s3);
       String s5 = rs.getString(5);
       System.out.println("userid is " + s5);
       s6 = rs.getString(6);
       System.out.println("ename is:" + s6);
       s7 = rs.getString(7);
       System.out.println("address:" + s7);
       s8 = rs.getString(8);
       System.out.println("city is:" + s8);
       s9 = rs.getString(9);
       System.out.println("state is:" + s9);
       s10 = rs.getString(10);
       System.out.println("country is:" + s10);
       i = rs.getInt(11);
       System.out.println("zip is:" + i);
       j = rs.getInt(12);
       System.out.println("phone is:" + j);
       s11 = rs.getString(13);
       System.out.println("website is:" + s11);
       String s15 = rs.getString(14);
     }
     printwriter.println("<HTML>");
     printwriter.println("<HEAD>");
     printwriter.println("<TITLE></TITLE>");
     printwriter.println("</HEAD>");
     printwriter.println("<BODY>");
     printwriter.println("<form name=f action='./secondleveladminstrator.html'target='_parent'>");
     printwriter.println("<P align=center><FONT color=forestgreen ");
     printwriter.println(
         "size=6><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
     printwriter.println("&nbsp;&nbsp; ");
     printwriter.println("<U><strong>Profile</strong></U></STRONG></FONT></P>");
     printwriter.println("<TABLE border=0 align=center cellPadding=1 cellSpacing=1 width=75%>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>Level Name</strong></TD>");
     printwriter.println("<TD>" + s + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>Category Id</strong></TD>");
     printwriter.println("<TD>" + s1 + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>Module ID</strong></TD>");
     printwriter.println("<TD>" + s2 + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>Support Id</strong></TD>");
     printwriter.println("<TD>" + s3 + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>Employeename</strong></TD>");
     printwriter.println("<TD>" + s6 + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>Address</strong></TD>");
     printwriter.println("<TD>" + s7 + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>City</strong></TD>");
     printwriter.println("<TD>" + s8 + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>State</strong></TD>");
     printwriter.println(" <TD>" + s9 + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>Country</strong></TD>");
     printwriter.println(" <TD>" + s10 + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>Pincode</strong></TD>");
     printwriter.println(" <TD>" + i + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println("<TD><strong>Phone No</strong></TD>");
     printwriter.println("<TD>" + j + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println(" <TD><strong>Email ID</strong></TD>");
     printwriter.println(" <TD>" + s11 + "</TD></TR>");
     printwriter.println("<TR>");
     printwriter.println(
         "<TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
     printwriter.println(
         "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
     printwriter.println("&nbsp;&nbsp;");
     printwriter.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ");
     printwriter.println("<INPUT id=submit1 name=submit1 type=submit value=Ok></TD>");
     printwriter.println(" <TD></TD></TR></TABLE>");
     printwriter.println("</form>");
     printwriter.println("</BODY>");
     printwriter.println("</HTML>");
   } catch (Exception exception) {
     System.out.println(exception);
   }
 }
  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();
    try {
      HttpSession session = request.getSession();
      PrintWriter out = response.getWriter();
      nseer_db_backup1 fund_db = new nseer_db_backup1(dbApplication);
      nseer_db_backup1 fund_db1 = new nseer_db_backup1(dbApplication);
      if (fund_db.conn((String) dbSession.getAttribute("unit_db_name"))
          && fund_db1.conn((String) dbSession.getAttribute("unit_db_name"))) {
        counter count = new counter(dbApplication);
        ValidataRecordNumber vrn = new ValidataRecordNumber();
        ValidataTag vt = new ValidataTag();
        ValidataNumber validata = new ValidataNumber();
        try {
          String time = "";
          java.util.Date now = new java.util.Date();
          SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
          time = formatter.format(now);

          String apply_pay_ID = request.getParameter("apply_pay_ID");
          String register_time = request.getParameter("register_time");
          String register = request.getParameter("register");
          String register_ID = request.getParameter("register_ID");
          String bodyc = new String(request.getParameter("remark").getBytes("UTF-8"), "UTF-8");
          String remark = exchange.toHtml(bodyc);
          String amount = request.getParameter("amount");
          String[] file_kind = request.getParameterValues("file_kind");
          String[] cost_price_subtotal = request.getParameterValues("cost_price_subtotal");
          int p = 0;
          String file_kinda = ",";
          for (int j = 1; j < file_kind.length; j++) {
            file_kinda += file_kind[j] + ",";
            if (cost_price_subtotal[j].equals("")) cost_price_subtotal[j] = "0";
            StringTokenizer tokenTO4 = new StringTokenizer(cost_price_subtotal[j], ",");
            String cost_price_subtotal1 = "";
            while (tokenTO4.hasMoreTokens()) {
              cost_price_subtotal1 += tokenTO4.nextToken();
            }
            if (!validata.validata(cost_price_subtotal1)) {
              p++;
            }
          }
          int n = 0;
          for (int i = 1; i <= Integer.parseInt(amount); i++) {
            String tem_file_kind = "file_kind" + i;
            String file_kind2 = request.getParameter(tem_file_kind);
            if (file_kinda.indexOf(file_kind2) != -1) n++;
          }
          if (n == 0) {
            if (p == 0) {
              if (vt.validata(
                          (String) dbSession.getAttribute("unit_db_name"),
                          "fund_apply_pay",
                          "apply_pay_ID",
                          apply_pay_ID,
                          "check_tag")
                      .equals("5")
                  || vt.validata(
                          (String) dbSession.getAttribute("unit_db_name"),
                          "fund_apply_pay",
                          "apply_pay_ID",
                          apply_pay_ID,
                          "check_tag")
                      .equals("9")) {
                String currency_name = "";
                String personal_unit = "";
                String chain_ID = "";
                String chain_name = "";
                String funder = "";
                String funder_ID = "";
                String sql11 =
                    "select * from fund_apply_pay where apply_pay_ID='" + apply_pay_ID + "'";
                ResultSet rs11 = fund_db.executeQuery(sql11);
                while (rs11.next()) {
                  chain_ID = rs11.getString("chain_ID");
                  chain_name = rs11.getString("chain_name");
                  funder = rs11.getString("human_name");
                  funder_ID = rs11.getString("human_ID");
                  currency_name = rs11.getString("currency_name");
                  personal_unit = rs11.getString("personal_unit");
                }
                int expenses_amount = 0;
                String sql6 =
                    "select count(*) from fund_apply_pay_details where apply_pay_ID='"
                        + apply_pay_ID
                        + "'";
                ResultSet rs6 = fund_db.executeQuery(sql6);
                if (rs6.next()) {
                  expenses_amount = rs6.getInt("count(*)");
                }
                double demand_cost_price_sum = 0.0d;
                for (int i = 1; i <= expenses_amount; i++) {
                  String tem_cost_price_subtotal = "cost_price_subtotal" + i;
                  String cost_price_subtotal2 = request.getParameter(tem_cost_price_subtotal);
                  demand_cost_price_sum += Double.parseDouble(cost_price_subtotal2);
                  sql6 =
                      "update fund_apply_pay_details set cost_price_subtotal='"
                          + cost_price_subtotal2
                          + "' where apply_pay_ID='"
                          + apply_pay_ID
                          + "' and details_number='"
                          + i
                          + "'";
                  fund_db.executeUpdate(sql6);
                }
                for (int i = 1; i < file_kind.length; i++) {
                  StringTokenizer tokenTO1 = new StringTokenizer(file_kind[i], "/");
                  String file_chain_ID = "";
                  String file_chain_name = "";
                  while (tokenTO1.hasMoreTokens()) {
                    file_chain_ID = tokenTO1.nextToken();
                    file_chain_name = tokenTO1.nextToken();
                  }
                  StringTokenizer tokenTO4 = new StringTokenizer(cost_price_subtotal[i], ",");
                  String cost_price_subtotal1 = "";
                  while (tokenTO4.hasMoreTokens()) {
                    cost_price_subtotal1 += tokenTO4.nextToken();
                  }
                  demand_cost_price_sum += Double.parseDouble(cost_price_subtotal1);
                  expenses_amount++;
                  String sql1 =
                      "insert into fund_apply_pay_details(apply_pay_ID,details_number,file_chain_ID,file_chain_name,cost_price_subtotal) values ('"
                          + apply_pay_ID
                          + "','"
                          + expenses_amount
                          + "','"
                          + file_chain_ID
                          + "','"
                          + file_chain_name
                          + "','"
                          + cost_price_subtotal1
                          + "')";
                  fund_db.executeUpdate(sql1);
                }

                String sql =
                    "update fund_apply_pay set demand_cost_price_sum='"
                        + demand_cost_price_sum
                        + "',check_tag='2',register_time='"
                        + register_time
                        + "',register='"
                        + register
                        + "',remark='"
                        + remark
                        + "' where apply_pay_ID='"
                        + apply_pay_ID
                        + "'";
                fund_db.executeUpdate(sql);

                response.sendRedirect("draft/fund/applyPayExpenses_ok.jsp?finished_tag=2");
              } else {
                response.sendRedirect("draft/fund/applyPayExpenses_ok.jsp?finished_tag=3");
              }
            } else {
              response.sendRedirect("draft/fund/applyPayExpenses_ok.jsp?finished_tag=6");
            }
          } else {
            response.sendRedirect("draft/fund/applyPayExpenses_ok.jsp?finished_tag=7");
          }
        } catch (Exception ex) {
          ex.printStackTrace();
        }
        fund_db.commit();
        fund_db1.commit();
        fund_db.close();
        fund_db1.close();
      } else {
        response.sendRedirect("error_conn.htm");
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }