pa_employeecontractservlet.java

来自「J2ee开发的 人事管理系统 使用oracle数据库 myeclips平台开」· Java 代码 · 共 488 行 · 第 1/2 页

JAVA
488
字号
	   
	    contractvo.setStartTime(Date.valueOf(smartRequest.getParameter("start_date")));
	    contractvo.setEndTime(Date.valueOf(smartRequest.getParameter("end_date")));
		int i=0;
		 i=contractdao.addObject(contractvo);
		if(i!=0){
			int pageSize=5;//设置单页显示条数
			int currentPage=1;//当前显示的页面号
			String cond="";
			PageHelp pagehelp=contractdao.getList(cond, pageSize, currentPage);
			request.setAttribute("pagehelp",pagehelp);
			request.getRequestDispatcher("PA_EmployeeContractServlet?opflag=query").forward(request,response);
		}else{
			int pageSize=5;//设置单页显示条数
			int currentPage=1;//当前显示的页面号
			String cond="";
			PageHelp pagehelp=contractdao.getList(cond, pageSize, currentPage);
			request.setAttribute("pagehelp",pagehelp);
			request.getRequestDispatcher("PA_EmployeeContractServlet?opflag=query&errmessage=1").forward(request,response);
		}
	}
	
	public void DoDelContract(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException, SQLException{
		EContractDAO contractdao=new EContractDAO();
		
		
		//SmartUpload su = new SmartUpload();
		//su.initialize(this.getServletConfig(), request, response);
		//SmartRequest smartRequest = su.getRequest();
		String pitch[]=request.getParameterValues("contractcheckbox");
		String cond="";
		if(pitch.length!=0)
		{
			for(int i=0;i<pitch.length;i++)
			{
				cond +=","+pitch[i];
			}
		}
		int i=0;
		System.out.println(cond);
		i=contractdao.deleteObject(cond);
		if(i!=0){
		int pageSize=5;//设置单页显示条数
		int currentPage=1;//当前显示的页面号
		cond="";
		PageHelp pagehelp=contractdao.getList(cond, pageSize, currentPage);
		request.setAttribute("pagehelp",pagehelp);
		request.getRequestDispatcher("PA_EmployeeContractServlet?opflag=query").forward(request,response);
		}
		else{
			int pageSize=5;//设置单页显示条数
			int currentPage=1;//当前显示的页面号
			cond="";
			PageHelp pagehelp=contractdao.getList(cond, pageSize, currentPage);
			request.setAttribute("pagehelp",pagehelp);
			request.getRequestDispatcher("PA_EmployeeContractServlet?opflag=query&errmessage=3").forward(request,response);
		}
		
	}
	
	public void DoChangeContract(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException, SQLException{
		EContractDAO contractdao=new EContractDAO();
		EContractVO contractvo=new EContractVO();
		String ecid=request.getParameter("changeid");
		String sql="select * from user_info u join  e_contract c on u.ui_id=c.ui_id where c.ec_id="+ecid;
		
		contractvo=(EContractVO)contractdao.readObject(sql);
		contractvo.setEcId(Long.valueOf(ecid));
		request.setAttribute("contractvo",contractvo);
		request.getRequestDispatcher("./psl_archive/staff_contract/pa_changebargain.jsp").forward(request,response);
	}
	
	public void DoImplementChange(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException, SQLException{
		
		
		String contractpath1 = "";
		String contractpath2 = "";
		String judgepath1="";
		String judgepath2="";
		
		SmartUpload su = new SmartUpload();
		try {
			su.initialize(this.getServletConfig(), request, response);
			su.setMaxFileSize(10000000L);
			su.setTotalMaxFileSize(100000000L);
			su.setAllowedFilesList("txt,doc,TXT,DOC");
			su.setDeniedFilesList("exe,bat,com,dll,jar,rar,zip,iso");
			
			su.upload();
			su.save("/upload_StaffContract/", su.SAVE_VIRTUAL);
			
			SmartFile sf = su.getFiles().getFile(0);
			SmartFile sf2 = su.getFiles().getFile(1);
			
			judgepath1=sf.getFileName();
			judgepath2=sf2.getFileName();
			contractpath1 = "upload_StaffContract/" + sf.getFileName();
			contractpath2 = "upload_StaffContract/" + sf2.getFileName();
		} catch (ServletException e1) {			
			e1.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (SmartUploadException e) {
			e.printStackTrace();
		}
				
		SmartRequest smartRequest = su.getRequest();
		
		
		EContractDAO contractdao=new EContractDAO();
		EContractVO contractvo=new EContractVO();
		String ecid=request.getParameter("ecid");
		contractvo.setEcId(Long.valueOf(request.getParameter("ecid")));
		contractvo.setEcStation(smartRequest.getParameter("ecposition"));
		contractvo.setEcContent(contractpath1);
	    contractvo.setEcProtocol(contractpath2);
		contractvo.setEcExtend("\"\"");
		contractvo.setStartTime(Date.valueOf(smartRequest.getParameter("startdate")));
		contractvo.setEndTime(Date.valueOf(smartRequest.getParameter("enddate")));
		
		String sql="";
		if(judgepath1!=null&&!"".equals(judgepath1)&&judgepath2!=null&&!"".equals(judgepath2)){
			sql="update e_contract set ec_station='"+contractvo.getEcStation()+
			"',ec_content='"+contractvo.getEcContent()+"',start_time=to_date('"+smartRequest.getParameter("startdate")+
			"','yyyy-mm-dd'),end_time=to_date('"+smartRequest.getParameter("enddate")+"','yyyy-mm-dd'),ec_protocol='"+contractvo.getEcProtocol()+
			"' where ec_id="+ecid;
		}
		else if(judgepath1!=null&&!"".equals(judgepath1))
		{
			sql="update e_contract set ec_station='"+contractvo.getEcStation()+
			"',ec_content='"+contractvo.getEcContent()+"',start_time=to_date('"+smartRequest.getParameter("startdate")+
			"','yyyy-mm-dd'),end_time=to_date('"+smartRequest.getParameter("enddate")+"','yyyy-mm-dd')"+
			" where ec_id="+ecid;
		}
		else if(judgepath2!=null&&!"".equals(judgepath2)){
			sql="update e_contract set ec_station='"+contractvo.getEcStation()+
			"',ec_protocol='"+contractvo.getEcProtocol()+"',start_time=to_date('"+smartRequest.getParameter("startdate")+
			"','yyyy-mm-dd'),end_time=to_date('"+smartRequest.getParameter("enddate")+"','yyyy-mm-dd')"+
			" where ec_id="+ecid;
		}
		else
		{
			sql="update e_contract set ec_station='"+contractvo.getEcStation()+
			"',start_time=to_date('"+smartRequest.getParameter("startdate")+
			"','yyyy-mm-dd'),end_time=to_date('"+smartRequest.getParameter("enddate")+"','yyyy-mm-dd')"+
			" where ec_id="+ecid;
		}
		
		int i=contractdao.updateObject(sql);
		
		if(i!=0){
		int pageSize=5;//设置单页显示条数
		int currentPage=1;//当前显示的页面号
		String cond="";
		PageHelp pagehelp=contractdao.getList(cond, pageSize, currentPage);
		request.setAttribute("pagehelp",pagehelp);
		request.getRequestDispatcher("PA_EmployeeContractServlet?opflag=query").forward(request,response);
		}
		else
		{
			int pageSize=5;//设置单页显示条数
			int currentPage=1;//当前显示的页面号
			String cond="";
			PageHelp pagehelp=contractdao.getList(cond, pageSize, currentPage);
			request.setAttribute("pagehelp",pagehelp);
			request.getRequestDispatcher("PA_EmployeeContractServlet?opflag=query&errmessage=2").forward(request,response);
		}
	}
	
	public void CheckPersonID(HttpServletRequest request, HttpServletResponse response)
	{
		String rspResult = "0";
		
		String personID = request.getParameter("personID");
		UserInfoDAO userdao = new UserInfoDAO();
		
		if(personID != null && !personID.equals("") )
		{
			String cond = " and ui_personid='" + personID + "'";
			List userlist = new ArrayList();
			userlist = userdao.queryByCondition(cond);
			if(userlist != null && userlist.size() != 0)
			{
				rspResult = "1";
			}
		}
		
		try {
			PrintWriter out = response.getWriter();
			out.write(rspResult);
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	
	public void DoDownLoad(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException, SQLException{
		
		String filename="";
		
		SmartUpload su = new SmartUpload();
		
		SmartRequest smartRequest = su.getRequest();
		String ecid=request.getParameter("ecid");
		System.out.println(ecid);
		String downloadflag=request.getParameter("downloadflag");
		EContractDAO contractdao=new EContractDAO();
		EContractVO contractvo=new EContractVO();
		String sql="select * from user_info u join  e_contract c on u.ui_id=c.ui_id where c.ec_id="+ecid;
		contractvo=(EContractVO)contractdao.readObject(sql);
		if("content".equals(downloadflag))
			filename=contractvo.getEcContent();
		else
			filename=contractvo.getEcProtocol();
		
		System.out.println(filename);
		try {
			su.initialize(this.getServletConfig(), request, response);
			su.setMaxFileSize(10000000L);
			su.setTotalMaxFileSize(100000000L);
			su.setContentDisposition(null);
			su.downloadFile(filename);
					
		} catch (ServletException e1) {			
			e1.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		 catch (SmartUploadException e) {
			e.printStackTrace();
		}
		
			
	}
	
}

⌨️ 快捷键说明

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