pa_employeecontractservlet.java

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

JAVA
488
字号
package com.galaxy.controller;

//import java.awt.List;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Date;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

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

import com.galaxy.dao.EContractDAO;
import com.galaxy.dao.UserInfoDAO;
import com.galaxy.upload.SmartFile;
import com.galaxy.upload.SmartRequest;
import com.galaxy.upload.SmartUpload;
import com.galaxy.upload.SmartUploadException;
import com.galaxy.util.PageHelp;
import com.galaxy.vo.DeptInfoVO;
import com.galaxy.vo.EContractVO;
import com.galaxy.vo.RoleInfoVO;
import com.galaxy.vo.UserInfoVO;
import com.galaxy.dao.*;
import com.galaxy.vo.*;




public class PA_EmployeeContractServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public PA_EmployeeContractServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request,response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 * @throws  
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		request.setCharacterEncoding("gb2312");
		String opflag="";
		opflag=request.getParameter("opflag");
		if("ContractSave".equals(opflag)){	 
		   
		}
		else if("query".equals(opflag)){
			try{
			DoMyQuery(request,response);
			}
			catch(SQLException e){
				e.printStackTrace();
			}
		

		}
		
		else if("contractadd".equals(opflag))
		{
			try{
				DoAddContract(request,response);
				}
				catch(SQLException e){
					e.printStackTrace();
				}
			
		}
		else if("contractdel".equals(opflag))
		{
			try{
				DoDelContract(request,response);
				}
				catch(SQLException e){
					e.printStackTrace();
				}
			
		}
		else if("contractchange".equals(opflag))
		{
			try{
				DoChangeContract(request,response);
				}
				catch(SQLException e){
					e.printStackTrace();
				}
			
		}
		else if("implementchange".equals(opflag))
		{
			try{
				DoImplementChange(request,response);
				}
				catch(SQLException e){
					e.printStackTrace();
				}
			
		}
		else if("ajax".equals(opflag))
		{			
			CheckPersonID(request, response);
		}
		else if("downloadfile".equals(opflag))
		{		
			try{
			DoDownLoad(request, response);
			}
			catch(SQLException e){
				e.printStackTrace();
			}
		}
		
			else{}
		
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occure
	 */
	public void init() throws ServletException {
		// Put your code here
	}

	public void DoMyQuery(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException, SQLException{
		int pageSize=5;//设置单页显示条数
		int currentPage=1;//当前显示的页面号
		String errmessage="";
		
		if(request.getParameter("errmessage")!=null&&!"".equals(request.getParameter("errmessage"))){
			errmessage=request.getParameter("errmessage");
		}
		DeptInfoDAO depdao=new DeptInfoDAO();
		
		ArrayList deplist=(ArrayList)depdao.queryByCondition("");
		String cond="";
		if(request.getParameter("currentPage")!=null&&!"".equals(request.getParameter("currentPage"))){
			currentPage=Integer.parseInt(request.getParameter("currentPage"));
		}
		PageHelp pagehelp=new PageHelp();//实例化PageHelp对象pageHelp
		EContractDAO contractdao=new EContractDAO();
		if(request.getParameter("selectdep")!=null&&!"".equals(request.getParameter("selectdep"))){
			cond+=" and di_id="+request.getParameter("selectdep");	
		}else{
		}
			if(request.getParameter("ui_name")!=null&&!"".equals(request.getParameter("ui_name"))){
				cond+=" and ui_realname like '%"+request.getParameter("ui_name")+"%'";
			
	
		}
		
		pagehelp=contractdao.getList(cond, pageSize, currentPage);
		request.setAttribute("errmessage", errmessage);
		request.setAttribute("deplist", deplist);
		request.setAttribute("pagehelp",pagehelp);
		request.getRequestDispatcher("./psl_archive/staff_contract/pa_bargainsearch1.jsp").forward(request,response);
	}
	public void DoAddContract(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException, SQLException{
		
		
		String contractpath1 = "";
		String contractpath2 = "";
		
		String errmessage="";
		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);
			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();
		UserInfoVO uservo=new UserInfoVO();
		uservo.setUiPersonid(Long.valueOf(smartRequest.getParameter("uiid")));
		String sql="select ui_id from user_info where ui_personid="+uservo.getUiPersonid();
		uservo.setUiId(contractdao.GetUIID(sql));
	    contractvo.setUserInfo(uservo);
	    contractvo.setEcStation(smartRequest.getParameter("addposition"));
	    contractvo.setEcContent(contractpath1);
	    contractvo.setEcProtocol(contractpath2);
	    

⌨️ 快捷键说明

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