/** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    // TODO Auto-generated method stub
    Order details = new Order();
    // details.setCustomerID();

    HttpSession session = request.getSession(true);
    // String ID = (String) session.getAttribute("key");
    String pID = request.getParameter("ProductIdE").toString();
    details.setCustomerID(request.getParameter("CustomerIdE"));
    details.setProductID((request.getParameter("ProductIdE")));

    int price = StoreDAO.getPrice(pID);
    details.setPrice(price);
    System.out.println("PRICDE" + price);

    //  details.setOrderID((request.getParameter("OrderID")));
    // Date dt = new Date();
    Calendar c = new GregorianCalendar();
    c.set(Calendar.HOUR_OF_DAY, 0); // anything 0 - 23
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    Date d1 = c.getTime();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
    String s = sdf.format(d1);
    Date date = null;
    try {
      date = new SimpleDateFormat("yyyy/MM/dd", Locale.ENGLISH).parse(s);
    } catch (ParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    details.setTodayDate(new java.sql.Date(new java.util.Date().getTime()));

    //  System.out.println("CUSTOMER ID PRINTED FRM ORDER"+ ID);
    // details.setCustomerPassword((request.getParameter("CustomerPassword")));
    details = StoreDAO.insertOrder(details);

    if (details.isValid()) {

      session.setAttribute("currentSession", details);
      int totalPrice = 0;
      if (session.getAttribute("Price") != null)
        totalPrice = ((Integer) session.getAttribute("Price"));
      totalPrice = totalPrice + price;
      session.setAttribute("Price", totalPrice);
      PrintWriter out = response.getWriter();
      response.setContentType("text/html");
      out.println("<script type=\"text/javascript\">");
      out.println("alert('Added this product into database');" + price);
      out.println("</script>");

      response.sendRedirect("SalesEmployeeOrder.jsp"); // logged-in page      	
    } else response.sendRedirect("invalidLogin.jsp"); // error page
  }
Exemplo n.º 2
0
 /** @inheritdoc */
 @Override
 public void readEntity(Cursor cursor, Order entity, int offset) {
   entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
   entity.setType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
   entity.setTopic(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
   entity.setStartTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
   entity.setEndTime(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
   entity.setPrice(cursor.isNull(offset + 5) ? null : cursor.getDouble(offset + 5));
   entity.setRealtime(cursor.isNull(offset + 6) ? null : cursor.getShort(offset + 6) != 0);
   entity.setContactName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
   entity.setContactGender(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
   entity.setContactPhone(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
   entity.setExpertId(cursor.isNull(offset + 10) ? null : cursor.getLong(offset + 10));
   entity.setUserId(cursor.isNull(offset + 11) ? null : cursor.getLong(offset + 11));
 }