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

📄 showcomputeraction.java

📁 用于银行全面掌控公司及各个部门的员工信息与设备资料
💻 JAVA
字号:
package com.bank.struts.action;

import java.sql.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

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.bank.hibernate.dao.QueryDAO;
import com.bank.struts.form.AddComputerForm;


public class ShowComputerAction extends Action {
	
	int buyfrom2,buyto2,usefrom2,useto2;
	
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		AddComputerForm addComputerForm = (AddComputerForm) form;// TODO Auto-generated method stub
		
		String number = addComputerForm.getComNumber();
		String type = addComputerForm.getComType();
		String ip = addComputerForm.getComIpaddress();
		String name = addComputerForm.getComUserName();
		
		if(request.getParameter("buyfrom")!=null && request.getParameter("buyfrom").length()!=0){
			Date buyfrom = Date.valueOf(request.getParameter("buyfrom"));
			
			String buyfrom1 = String.valueOf(buyfrom);
			String s1 = buyfrom1.substring(0, 4)+buyfrom1.substring(5, 7)+buyfrom1.substring(8, 10);
			
			buyfrom2 = Integer.parseInt(s1);
		}if(request.getParameter("buyto")!=null && request.getParameter("buyto").length()!=0){
			Date buyto = Date.valueOf(request.getParameter("buyto"));
			
			String buyto1 = String.valueOf(buyto);
			String s2 = buyto1.substring(0, 4)+buyto1.substring(5, 7)+buyto1.substring(8, 10);
			
			buyto2 = Integer.parseInt(s2);
		
		}if(request.getParameter("usefrom")!=null && request.getParameter("usefrom").length()!=0){
			Date usefrom =Date.valueOf(request.getParameter("usefrom"));
			
			String usefrom1 = String.valueOf(usefrom);
			String s3 = usefrom1.substring(0, 4)+usefrom1.substring(5, 7)+usefrom1.substring(8, 10);
			
			usefrom2 = Integer.parseInt(s3);
		}if(request.getParameter("useto")!=null && request.getParameter("useto").length()!=0 ){
			Date useto = Date.valueOf(request.getParameter("useto"));
			
			String userto1 = String.valueOf(useto);
			String s4 = userto1.substring(0, 4)+userto1.substring(5, 7)+userto1.substring(8, 10);
			
			useto2 = Integer.parseInt(s4);
		}
		
		String sql = "from Computer where 1=1";
		
		if(number!=null && number.length()>0)
	    	sql += " and comNumber like '%"+name+"%'";
	    if(type!=null && type.length()>0)
	    	sql += " and comType like '%"+type+"%'";
	    if(ip!=null && ip.length()>0)
	    	sql += " and comIpaddress like '%"+ip+"%'";
	    if(name!=null && name.length()>0)
	    	sql +=" and comUserName like '%"+name+"%'";
	    if(buyfrom2!=0 && buyto2!=0){
	    	
	    	sql +=" and comBuyTime >"+buyfrom2+" and comBuyTime <"+buyto2;
	    }
	    if(usefrom2!=0 && useto2!=0){
	    	
	    	sql +=" and comUseTime >"+usefrom2+" and comUseTime <"+useto2;
	    }
	   
	    QueryDAO dao = new QueryDAO();
	    List list = dao.queryProperties(sql);
		
		request.setAttribute("list", list);
		
		return mapping.findForward("showComputer");
	}
}

⌨️ 快捷键说明

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