コード例 #1
0
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    // Extract attributes we will need
    Logger log = Logger.getLogger(ReceiptDialogAction.class.getName());
    Locale locale = getLocale(request);
    MessageResources messages = getResources();
    String action = request.getParameter("FormAction");
    HttpSession session = request.getSession();
    List pageNumberList = new ArrayList();
    PageBean pageBean = new PageBean();

    String customerId = (String) request.getSession().getAttribute("BillAddressForReceipt");
    String filter = request.getParameter("custFilter");

    String pageNumber = request.getParameter("pageNumber");
    if (pageNumber == null) pageNumber = "";
    if (!pageNumber.equals("")) {
      pageBean = (PageBean) session.getAttribute("UserPageBean");
      pageBean.setCurrentPage(new Integer(pageNumber).intValue());
      pageNumberList = getPageNumberList(pageBean);
    } else {
      try {
        net.sf.hibernate.Session hs = Hibernate2Session.currentSession();
        String receiptNo = request.getParameter("ReceiptNo");
        String receiptCustomer = request.getParameter("ReceiptCustomer");

        if (receiptNo == null) receiptNo = "";
        if (receiptCustomer == null) receiptCustomer = "";

        String QryStr = "select p from ProjectReceiptMaster as p inner join p.customerId as c ";
        QryStr = QryStr + " where p.receiptNo like '%" + receiptNo + "%'";
        QryStr =
            QryStr
                + " and ( c.partyId like '%"
                + receiptCustomer
                + "%' or c.description like '%"
                + receiptCustomer
                + "%')";
        QryStr = QryStr + " and p.receiptStatus <> '" + Constants.RECEIPT_STATUS_COMPLETED + "'";

        String QryStr2 = QryStr + " and p.customerId = '" + customerId + "'";
        List result = null;
        if (filter != null && filter.equals("1")) {
          result = hs.createQuery(QryStr).list();
        } else result = hs.createQuery(QryStr2).list();

        pageBean.setItemList(result);
        int recCount = result.size();
        pageBean.setPage(MAXPAGE, recCount);
        pageNumberList = getPageNumberList(pageBean);
      } catch (Exception e) {
        e.printStackTrace();
      }
      Hibernate2Session.closeSession();
    }
    session.setAttribute("UserPageBean", pageBean);
    request.setAttribute("PageNumberList", pageNumberList);
    return (mapping.findForward("success"));
  }
コード例 #2
0
  public ActionForward perform(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    // Extract attributes we will need
    Logger log = Logger.getLogger(PRMUserListAction.class.getName());
    Locale locale = getLocale(request);
    MessageResources messages = getResources();
    String action = request.getParameter("FormAction");
    DynaValidatorForm actionForm = (DynaValidatorForm) form;
    HttpSession session = request.getSession();
    List projectSelectArr = new ArrayList();
    List result = new ArrayList();
    List pageNumberList = new ArrayList();
    PageBean pageBean = new PageBean();

    String pageNumber = request.getParameter("pageNumber");
    if (pageNumber == null) pageNumber = "";
    if (!pageNumber.equals("")) {
      pageBean = (PageBean) session.getAttribute("UserPageBean");
      pageBean.setCurrentPage(new Integer(pageNumber).intValue());
      pageNumberList = getPageNumberList(pageBean);
    } else {
      // init display
      try {
        net.sf.hibernate.Session hs = Hibernate2Session.currentSession();
        Transaction tx = null;
        String PartyId = request.getParameter("partyId");
        String lStrOpt = request.getParameter("rad");
        String srchStaff = request.getParameter("srchStaff");
        String srchDep = request.getParameter("srchDep");

        if (PartyId == null) PartyId = "";
        if (lStrOpt == null) lStrOpt = "2";
        if (srchStaff == null) srchStaff = "";
        if (srchDep == null) srchDep = "";

        String ChildPartyString = "'" + PartyId + "'";
        String QryStr = "";

        /** 获得指定机构的下级机构列表 */
        Party party = (Party) hs.load(Party.class, PartyId);
        PartyHelper ph = new PartyHelper();

        List pList = ph.getAllSubPartysByPartyId(hs, PartyId);
        if (pList != null) {
          Iterator pIt = pList.iterator();
          while (pIt.hasNext()) {
            Party p = (Party) pIt.next();
            ChildPartyString = ChildPartyString + ",'" + p.getPartyId() + "'";
          }
        }

        QryStr =
            "select ul from UserLogin as ul inner join ul.party as p where p.partyId in ("
                + ChildPartyString
                + ")";
        if (!srchStaff.equals("")) {
          if (lStrOpt.equals("2")) {
            QryStr =
                QryStr
                    + " and (ul.userLoginId like '%"
                    + srchStaff
                    + "%' or ul.name like '%"
                    + srchStaff
                    + "%')";
          } else {
            QryStr =
                QryStr
                    + " and (ul.userLoginId = '"
                    + srchStaff
                    + "' or ul.name = '"
                    + srchStaff
                    + "')";
          }
        }
        if (!srchDep.equals("")) {
          if (lStrOpt.equals("2")) {
            QryStr =
                QryStr
                    + " and (p.partyId like '%"
                    + srchDep
                    + "%' or p.description like '%"
                    + srchDep
                    + "%')";
          } else {
            QryStr =
                QryStr
                    + " and (p.partyId = '"
                    + srchDep
                    + "' or p.description = '"
                    + srchDep
                    + "')";
          }
        }

        Query q = hs.createQuery(QryStr);
        result = q.list();
        pageBean.setItemList(result);
        int recCount = result.size();
        pageBean.setPage(MAXPAGE, recCount);
        pageNumberList = ProjectListAction.getPageNumberList(pageBean);

      } catch (Exception e) {
        e.printStackTrace();
        log.error(e.getMessage());
        return (mapping.findForward("success"));
      } finally {
        try {
          Hibernate2Session.closeSession();
        } catch (HibernateException e1) {
          log.error(e1.getMessage());
          e1.printStackTrace();
        } catch (SQLException e1) {
          log.error(e1.getMessage());
          e1.printStackTrace();
        }
      }
    }

    session.setAttribute("UserPageBean", pageBean);
    request.setAttribute("pageName", "FindPRMPage");
    request.setAttribute("PageNumberList", pageNumberList);

    return (mapping.findForward("success"));
  }