📄 admincardsearchaction.java
字号:
/*
* 作者:管磊
* 功能:会员卡的多种条件查询
* 时间: 12-26-2007
*/
package com.mole.struts.action;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.mole.struts.bean.Page;
import com.mole.struts.dao.MerchantCardDAO;
/**
* MyEclipse Struts Creation date: 12-26-2007
*
* XDoclet definition:
*
* @struts.action validate="true"
*/
public class AdminCardSearchAction extends Action {
/*
* Generated Methods
*/
MerchantCardDAO dao;
/**
* Method execute
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String citylist = request.getParameter("citylist");
String endtime = request.getParameter("endtime");
String starttime = request.getParameter("starttime");
String scid = request.getParameter("scid");
if (dao == null)
dao = new MerchantCardDAO();
String where = null;
if (citylist != null && !"".equals(citylist))// 如果没有城市限制
where = "cityid='" + citylist + "'";
if (scid != null && !"".equals(scid))// 没有商家限制
{
if (where != null)
where = where + "and storeid=" + scid;
else
where = " storeid=" + scid;
}
if (starttime != null && !"".equals(starttime)
&& (endtime == null || "".equals(endtime)))// 有发行开始时间限制
{
if (where == null) {
where = " grantdate>" + starttime;
} else
where = where + " and grantdate>'" + starttime + "'";
}
if (endtime != null && !"".equals(endtime)
&& (starttime == null || "".equals(starttime)))// 有截至时间限制的
{
if (where == null) {
where = " grantdate<" + endtime;
} else
where = where + " and grantdate<'" + endtime + "'";
}
if (endtime != null && starttime != null)// 有两个时间限制都有的。
{
if (where == null)
where = " grantdate<'" + endtime + "' and grantdate>'"
+ starttime + "'";
else
where = where + " and grantdate<'" + endtime
+ "' and grantdate>'" + starttime + "'";
}
if (where != null)
where = " where " + where;
ArrayList al = null;
// a.[ID],a.[CustomerID],a.[OriginID],a.[State],CONVERT(char(20),a.[GrantDate],120)
String sql = "SELECT a.[cardID],a.[ID],a.[OriginID],a.[customerState],CONVERT(char(20),a.[GrantDate],120) "
+ "FROM v_customercard a " + where;
// 分页查询的操作
Page page = new Page();
String action = request.getParameter("action");
int pageSize = (request.getParameter("pageSizeSelect") == null ? 10
: Integer.parseInt(request.getParameter("pageSizeSelect")));
int currentPage = (request.getParameter("page") == null ? 1 : Integer
.parseInt(request.getParameter("page")));
if (null == action) {
int count = dao.getPageInfoByWhere(where);
page.setPageSize(pageSize);
page.setRecordCount(count);
page.setPageCount((count + pageSize - 1) / pageSize);
page.setCurrentPage(currentPage);
try {
al = dao.getCards(pageSize, currentPage, where);// DAO操作,查询数据库中的卡的信息
request.setAttribute("Page", page);
} catch (Exception e) {
e.printStackTrace();
HttpSession session = request.getSession();
session.setAttribute("title", "错误信息");
session.setAttribute("message", "用户名或密码错误,请重新登陆!");
session.setAttribute("returnUrl", "show.do?action=goLogin");
return mapping.findForward("goMessage");
}
}
request.setAttribute("MerchantCardView", al);// 传到表现层的卡的集合
return new ActionForward("/adminCardsView.jsp");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -