⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 searchaction.java

📁 1 系统简介 1.1 系统名称:bugtrail 1.2 适用范围:大型或小型公司 1.3 用途:在项目周期内进行项目管理
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package bugtrail.action;

import java.sql.ResultSet;
import java.util.Vector;

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 bugtrail.basic.Bug;
import bugtrail.basic.Role;
import bugtrail.basic.Staff;
import bugtrail.form.SearchForm;
import bugtrail.util.CharsetProcess;
import bugtrail.util.SqlHelper;

/**
 * MyEclipse Struts Creation date: 01-03-2007
 * 
 * XDoclet definition:
 * 
 * @struts.action path="/search" name="searchForm" input="/search.jsp"
 *                scope="request" validate="true"
 */
public class SearchAction extends Action {
	/*
	 * Generated Methods
	 */

	/**
	 * Method execute
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		SearchForm searchForm = (SearchForm) form;// TODO Auto-generated
		// method stub
		HttpSession session = request.getSession();
		String action = request.getParameter("action");
		session.setAttribute("type", searchForm.getType());
		if (action == null) {
			return mapping.findForward("high");
		} else {
			String sql = null;
			SqlHelper helper = new SqlHelper();
			Vector searchList = null;
			ResultSet rs;
			if (searchForm.getType().equals("bug")) {
				int state = searchForm.getState();
				String title = searchForm.getTitle();
				String priority = searchForm.getPriority();
				int owner = searchForm.getOwner();
				if (sql==null&&owner != -1) {
					sql = " where owner='" + owner + "'";
				}
				if (sql == null && state != -1) {
					sql = " where state='" + state + "'";
				} else if (sql != null && state != -1) {
					sql += " and " + "state='" + state + "'";
				}
				if (sql == null && !title.equals("")) {
					sql = " where  title like '%" + CharsetProcess.U2C(title) + "%'";
				} else if (sql != null && !title.equals("")) {
					sql += " and " + "title like '%" + CharsetProcess.U2C(title)
							+ "%'";
				}
				if (sql == null && !priority.equals("-1")) {
					sql = " where priority='" + CharsetProcess.U2C(priority) + "'";
				} else if (sql != null && !priority.equals("-1")) {
					sql += " and " + "priority='"
							+ CharsetProcess.U2C(priority) + "'";
				}
				sql = "select * from bug " + sql;
				searchList = new Vector<Bug>();
				rs = helper.executeHelper(sql);
				while (rs.next()) {
					Bug temp = new Bug();
					temp.setBugID(rs.getInt("bugID"));
					temp.setTitle(rs.getString("title"));
					temp.setState(rs.getInt("state"));
					temp.setPriority(rs.getString("priority"));
					temp.setDescription(rs.getString("description"));
					temp.setEstablishTime(rs.getDate("establishTime"));
					temp.setLastEdit(rs.getInt("lastEdit"));
					temp.setFinder(rs.getInt("finder"));
					temp.setOwner(rs.getInt("owner"));
					temp.setValidater(rs.getInt("validater"));
					temp.setProject(rs.getInt("project"));
					searchList.add(temp);
				}
			
			}
			if (searchForm.getType().equals("user")) {
				String name = searchForm.getName();
				int department = searchForm.getDepartment();
				int role = searchForm.getRole();
				if (role != -1) {
					sql = "where role='" + role + "'";
				}
				if (sql == null && department != -1) {
					sql = "where department='" + department + "'";
				} else if (sql != null && department != -1) {
					sql += " and " + "department='" + department + "'";
				}
				if (sql == null && !name.equals("")) {
					sql = "where name like '%" + CharsetProcess.U2C(name) + "%'";
				} else if (sql != null && !name.equals("")) {
					sql += " and " + "name like '%" + CharsetProcess.U2C(name) + "%'";
				}
				sql = "select * from staff " + sql;
				searchList = new Vector<Staff>();
				rs = helper.executeHelper(sql);
				while (rs.next()) {
					Staff temp = new Staff();
					temp.setStaffID(rs.getInt("staffID"));
					temp.setName(rs.getString("name"));
					temp.setPassword(rs.getString("password"));
					temp.setEmail(rs.getString("email"));
					temp.setRole(rs.getInt("role"));
					temp.setDepartment(rs.getInt("department"));
					temp.setPswQuestion(rs.getString("pswQuestion"));
					temp.setPswAnswer(rs.getString("pswAnswer"));
					temp.setAddress(rs.getString("address"));
					temp.setRemark(rs.getString("remark"));
					temp.setPhone(rs.getInt("phone"));
					searchList.add(temp);
				}
			}
			session.setAttribute("action", "action");
			helper.closeAll();
			session.setAttribute("searchList", searchList);
			return mapping.findForward("high");
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -