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

📄 elec_fee_info.java

📁 JSP移动商品管理平台源代码.........
💻 JAVA
字号:
package imis_elec;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

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



public class Elec_Fee_info extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public Elec_Fee_info() {
		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 {

		this.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
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {


		String pattern = request.getParameter("pattern");

		if(pattern.equals("insert")) {
			//this.insert(request, response);
		}
		else if(pattern.equals("search")) {
			this.search(request, response);
		}else if(pattern.equals("getElec_Fee_info")) {
			this.getElecInfo(request, response);
		}else if(pattern.equals("modify")) {
			this.modify(request, response);
		}else if(pattern.equals("delete")) {
			//this.delete(request, response); 
		}
	}
	
	/**
	 *
	 * 这个方法向表“Elec_Fee_info”中得到信息,这个方法会被修改和删除页面调用,根据参数“page”来判断
	 * 是哪个页面。
	 * 
	 * @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 getElecInfo(HttpServletRequest request, HttpServletResponse response) 
		throws ServletException, IOException{
		Elec_Fee_infoTO elec_Fee_infoTO = null;
		int  elecUseType  = Integer.parseInt(request.getParameter("elecUseType"));
		
		Elec_Fee_infoDAOImpl elec_Fee_infoDAO = (Elec_Fee_infoDAOImpl) DAOFactory.getInstance().getElec_Fee_info();
		try {
			elec_Fee_infoTO = elec_Fee_infoDAO.getElec_Fee_info(elecUseType);
		} catch (Exception e) {
			e.printStackTrace();
		}			
		
		if(elec_Fee_infoTO != null) {
			request.setAttribute("Elec_Fee_info", elec_Fee_infoTO);
		} else {
			request.setAttribute("ElecUseTypeUnexisted", "用电类型" +
					"不存在!");
		}
		
		if(request.getParameter("page").equals("modify")) {
			request.getRequestDispatcher("../imis_elec/elec_Fee_info_modify.jsp").forward(request, response);
		} else if(request.getParameter("page").equals("delete")) {
			request.getRequestDispatcher("../imis_elec/elec_Fee_info_delete.jsp").forward(request, response);
		}
	}
	
	/**
	 *
	 * 这个方法向表“Elec_Fee_info”中修改数据
	 * 
	 * @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 modify(HttpServletRequest request, HttpServletResponse response) 
		throws ServletException, IOException{
				
		boolean flag = false;
		
		Elec_Fee_infoTO elec_Fee_info = new Elec_Fee_infoTO();
		
		elec_Fee_info.setFeeId(Integer.parseInt(request.getParameter("FeeId").trim()));
		elec_Fee_info.setElecUseType(Integer.parseInt(request.getParameter("ElecUseType").trim()));
		elec_Fee_info.setPriceUnit(Double.parseDouble(request.getParameter("PriceUnit").trim()));
		elec_Fee_info.setMemo(request.getParameter("Memo").trim());
		
		Elec_Fee_infoDAOImpl elec_Fee_infoDAO = (Elec_Fee_infoDAOImpl) DAOFactory.getInstance().getElec_Fee_info();
		try {
			flag = elec_Fee_infoDAO.updateElec_Fee_info(elec_Fee_info);
		} catch (Exception e) {
			e.printStackTrace();
		}			
		
		if(flag == true) {
			request.setAttribute("success", "您已成功修改信息!");
			request.getRequestDispatcher("../imis_elec/successful.jsp").forward(request, response);
		} else {
			request.setAttribute("fail", "您的修改失败了!");
			request.getRequestDispatcher("../imis_elec/fail.jsp").forward(request, response);
		}
	}
	
	/**
	 *
	 * 这个方法向表“Elec_Fee_info”中查找数据
	 * 
	 * @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 search(HttpServletRequest request, HttpServletResponse response) 
	throws ServletException, IOException{
	
	ArrayList list = new ArrayList();
	
	Elec_Fee_infoTO elec_Fee_info = new Elec_Fee_infoTO();
	if(!request.getParameter("elecUseType").equals("")){
		elec_Fee_info.setElecUseType(Integer.parseInt(request.getParameter("elecUseType").trim()));
	}
	else{
		elec_Fee_info.setElecUseType(-1);
	}
	elec_Fee_info.setFeeId(-1);
	elec_Fee_info.setPriceUnit(0);
	elec_Fee_info.setMemo("");
	
	Elec_Fee_infoDAOImpl elec_Fee_infoDAO = (Elec_Fee_infoDAOImpl) DAOFactory.getInstance().getElec_Fee_info();
	try {
		list = elec_Fee_infoDAO.searchElecDev_Type(elec_Fee_info);
		
	} catch (Exception e) {
		e.printStackTrace();
	}			
	
	request.getSession().setAttribute("Elec_Fee_infoList", list);
	request.getRequestDispatcher("../imis_elec/elec_Fee_info_search.jsp").forward(request, response);
}
	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occure
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}

⌨️ 快捷键说明

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