Пример #1
0
  public void ajaxDocument(HttpServletRequest request, HttpServletResponse response)
      throws ProductDaoException, SupplierDaoException, IOException {

    String prsNumber = request.getParameter("key1");
    String itemCode = request.getParameter("key2");
    String supplierCode = request.getParameter("key3");

    /* get assigned supplier */
    ProductDao productDao = DaoFactory.createProductDao();
    SupplierDao supplierDao = DaoFactory.createSupplierDao();
    AssignCanvassingDao assignCanvassingDao = DaoFactory.createAssignCanvassingDao();
    List<AssignCanvassing> acs =
        assignCanvassingDao.findByPrsNumberItemCodeSupplierCode(prsNumber, itemCode, supplierCode);
    String out = "[";
    for (AssignCanvassing x : acs) {
      if (!out.equals("[")) {
        out += ",";
      }

      Product p = productDao.findWhereProductCodeEquals(x.getProductCode()).get(0);
      Supplier s = supplierDao.findWhereSupplierCodeEquals(x.getSupplierCode()).get(0);

      out +=
          "{\"prsNo\": \""
              + x.getPrsNumber()
              + "\", "
              + "\"assignDate\": \""
              + new SimpleDateFormat("dd/MM/yyyy").format(x.getCreateDate())
              + "\", "
              + "\"itemCode\": \""
              + x.getProductCode()
              + "\", "
              + "\"itemName\": \""
              + p.getProductName()
              + "\", "
              + "\"supplierCode\": \""
              + x.getSupplierCode()
              + "\", "
              + "\"supplierName\": \""
              + s.getSupplierName()
              + "\", "
              + "\"unitPrice\": \""
              + x.getUnitPrice()
              + "\", "
              + "\"top\": \""
              + x.getTop()
              + "\", "
              + "\"topDesc\": \""
              + x.getTopDesc()
              + "\", "
              + "\"tod\": \""
              + x.getTod()
              + "\", "
              + "\"warranty\": \""
              + x.getWp()
              + "\"}";
    }
    out += "]";
    response.getWriter().print(out);
  }
Пример #2
0
  public void ajaxSearch(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ProductDaoException, SupplierDaoException {
    Boolean b = Boolean.FALSE;
    PrintWriter pw = response.getWriter();
    LoginUser lu = (LoginUser) request.getSession().getAttribute("user");
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");

    ProductDao productDao = DaoFactory.createProductDao();
    SupplierDao supplierDao = DaoFactory.createSupplierDao();
    AssignCanvassingDao assignCanvassingDao = DaoFactory.createAssignCanvassingDao();
    pw.print(
        "{\"maxpage\": "
            + assignCanvassingDao.ajaxMaxPagePA(
                request.getParameter("where"),
                new BigDecimal(request.getParameter("show")),
                lu.getUserId())
            + ",\"data\": [");
    List<AssignCanvassing> acs =
        assignCanvassingDao.ajaxSearchPA(
            request.getParameter("where"),
            request.getParameter("order"),
            Integer.parseInt(request.getParameter("page"), 10),
            Integer.parseInt(request.getParameter("show")),
            lu.getUserId());
    for (AssignCanvassing x : acs) {
      Product p = productDao.findWhereProductCodeEquals(x.getProductCode()).get(0);
      Supplier s = supplierDao.findWhereSupplierCodeEquals(x.getSupplierCode()).get(0);
      if (b) pw.print(",");
      pw.print("{\"1\": \"" + x.getId() + "\", ");
      pw.print("\"2\": \"" + x.getPrsNumber() + "\", ");
      pw.print("\"3\": \"" + x.getSupplierCode() + "\", ");
      pw.print("\"4\": \"" + s.getSupplierName() + "\", ");
      pw.print(
          "\"5\": \""
              + (x.getUpdatedDate() == null ? "" : sdf.format(x.getUpdatedDate()))
              + "\", ");
      pw.print("\"6\": \"" + x.getProductCode() + "\", ");
      pw.print("\"7\": \"" + p.getProductName() + "\"}");
      b = Boolean.TRUE;
    }
    pw.print("]}");
  }
Пример #3
0
  public ModelAndView getSupplier(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ProductDaoException, SupplierDaoException {

    String supplierCode = request.getParameter("key");
    LoginUser lu = (LoginUser) request.getSession().getAttribute("user");

    /* get assigned supplier */
    ProductDao productDao = DaoFactory.createProductDao();
    SupplierDao supplierDao = DaoFactory.createSupplierDao();
    PrsDetailDao prsDetailDao = DaoFactory.createPrsDetailDao();
    AssignCanvassingDao assignCanvassingDao = DaoFactory.createAssignCanvassingDao();
    List<AssignCanvassing> acs =
        assignCanvassingDao.findForPriceAssign(supplierCode, lu.getUserId());

    Map<String, Object> json = new HashMap<String, Object>();
    List<Map<String, Object>> rows = new ArrayList<Map<String, Object>>();
    for (AssignCanvassing x : acs) {

      Product p = productDao.findWhereProductCodeEquals(x.getProductCode()).get(0);
      Supplier s = supplierDao.findWhereSupplierCodeEquals(x.getSupplierCode()).get(0);
      PrsDetail pd = prsDetailDao.findByPrsProduct(x.getPrsNumber(), x.getProductCode());

      Map<String, Object> row = new HashMap<String, Object>();
      row.put("0", x.getId());
      row.put("1", x.getPrsNumber());
      row.put("2", new SimpleDateFormat("dd/MM/yyyy").format(x.getCreateDate()));
      row.put("3", x.getProductCode());
      row.put("4", p.getProductName());
      row.put("5", pd.getQty());
      row.put("6", x.getSupplierCode());
      row.put("7", s.getSupplierName());

      rows.add(row);
    }
    json.put("rows", rows);

    return new ModelAndView("jsonView", json);
  }