📄 elecdev_chk.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 ElecDev_Chk extends HttpServlet {
/**
* 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("getElecDev_Chk")) {
this.getElecInfo(request, response);
}else if(pattern.equals("modify")) {
this.modify(request, response);
}else if(pattern.equals("delete")) {
this.delete(request, response);
}
}
/**
*
* 这个方法向表“ElecDev_Chk”中插入数据
*
* @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 insert(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException{
boolean flag = false;
ElecDev_ChkTO elecDev_Chk = new ElecDev_ChkTO();
elecDev_Chk.setChkDevType(Integer.parseInt(request.getParameter("ChkDevType").trim()));
elecDev_Chk.setUserId(request.getParameter("UserId").trim());
elecDev_Chk.setElecDevRepFlag(Integer.parseInt(request.getParameter("ElecDevRepFlag").trim()));
elecDev_Chk.setElecDevChkStaff(request.getParameter("ElecDevChkStaff").trim());
elecDev_Chk.setElecDevChkContent(request.getParameter("ElecDevChkContent").trim());
elecDev_Chk.setElecDevChkDate(request.getParameter("ElecDevChkDate").trim());
//elecDev_Chk.setReMark(Integer.parseInt(request.getParameter("ReMark").trim()));
elecDev_Chk.setReMark(0);
elecDev_Chk.setMemo(request.getParameter("Memo").trim());
ElecDev_ChkDAOImpl elecDev_ChkDAO = (ElecDev_ChkDAOImpl) DAOFactory.getInstance().getElecDev_ChkDAO();
try {
flag = elecDev_ChkDAO.insertElec_Chk(elecDev_Chk);
} 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);
}
}
/**
*
* 这个方法向表“ElecDev_Chk”中查找数据
*
* @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();
try {
ElecDev_ChkTO elecDev_Chk = new ElecDev_ChkTO();
if(!request.getParameter("ElecDevChkId").equals("")){
elecDev_Chk.setElecDevChkId(Integer.parseInt(request.getParameter("ElecDevChkId").trim()));
}
else{
elecDev_Chk.setElecDevChkId(-1);
}
if(!request.getParameter("ChkDevType").equals("")){
elecDev_Chk.setChkDevType(Integer.parseInt(request.getParameter("ChkDevType").trim()));
}
else{
elecDev_Chk.setChkDevType(-1);
}
elecDev_Chk.setUserId(request.getParameter("UserId").trim());
elecDev_Chk.setElecDevRepFlag(0);
elecDev_Chk.setElecDevChkStaff("");
elecDev_Chk.setElecDevChkContent("");
elecDev_Chk.setElecDevChkDate(request.getParameter("ElecDevChkDate").trim());
elecDev_Chk.setReMark(0);
elecDev_Chk.setMemo("");
ElecDev_ChkDAOImpl elecDev_ChkDAO = (ElecDev_ChkDAOImpl) DAOFactory.getInstance().getElecDev_ChkDAO();
list = elecDev_ChkDAO.searchElec_Chk(elecDev_Chk,request.getParameter("EndDate"));
//list=elecDev_ChkDAO.searchall();
} catch (Exception e) {
e.printStackTrace();
}
request.getSession().setAttribute("ElecDev_ChkList", list);
request.getRequestDispatcher("../imis_elec/elecDev_Chk_bysearch.jsp").forward(request, response);
}
/**
*
* 这个方法向表“ElecDev_Chk”中得到信息,这个方法会被修改和删除页面调用,根据参数“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{
ElecDev_ChkTO elecDev_ChkTO = null;
int ElecDevChkId = Integer.parseInt(request.getParameter("ElecDevChkId").trim());
ElecDev_ChkDAOImpl elecDev_ChkDAO = (ElecDev_ChkDAOImpl) DAOFactory.getInstance().getElecDev_ChkDAO();
try {
elecDev_ChkTO = elecDev_ChkDAO.getElec_Chk(ElecDevChkId);
} catch (Exception e) {
e.printStackTrace();
}
if(elecDev_ChkTO != null) {
request.setAttribute("ElecDev_Chk", elecDev_ChkTO);
} else {
request.setAttribute("ElecDevChkIdUnexisted", "检查派单ID" +
"不存在!");
}
if(request.getParameter("page").equals("modify")) {
request.getRequestDispatcher("../imis_elec/elecDev_Chk_modify.jsp").forward(request, response);
} else if(request.getParameter("page").equals("delete")) {
request.getRequestDispatcher("../imis_elec/elecDev_Chk_delete.jsp").forward(request, response);
}
}
/**
*
* 这个方法向表“ElecDev_Chk”中修改数据
*
* @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;
ElecDev_ChkTO elecDev_Chk = new ElecDev_ChkTO();
elecDev_Chk.setElecDevChkId(Integer.parseInt(request.getParameter("ElecDevChkId").trim()));
elecDev_Chk.setChkDevType(Integer.parseInt(request.getParameter("ChkDevType").trim()));
elecDev_Chk.setUserId(request.getParameter("UserId").trim());
elecDev_Chk.setElecDevRepFlag(Integer.parseInt(request.getParameter("ElecDevRepFlag").trim()));
elecDev_Chk.setElecDevChkStaff(request.getParameter("ElecDevChkStaff").trim());
elecDev_Chk.setElecDevChkContent(request.getParameter("ElecDevChkContent").trim());
elecDev_Chk.setElecDevChkDate(request.getParameter("ElecDevChkDate").trim());
elecDev_Chk.setReMark(0);
elecDev_Chk.setMemo(request.getParameter("Memo").trim());
ElecDev_ChkDAOImpl elecDev_ChkDAO = (ElecDev_ChkDAOImpl) DAOFactory.getInstance().getElecDev_ChkDAO();
try {
flag = elecDev_ChkDAO.updateElec_Chk(elecDev_Chk);
} 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);
}
}
/**
*
* 这个方法向表“ElecDev_Chk”中删除数据
*
* @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 delete(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException{
boolean flag = false;
int elecDevChkId = Integer.parseInt(request.getParameter("ElecDevChkId").trim());
ElecDev_ChkDAOImpl elecDev_ChkDAO = (ElecDev_ChkDAOImpl) DAOFactory.getInstance().getElecDev_ChkDAO();
try {
flag = elecDev_ChkDAO.deleteElec_Chk(elecDevChkId);
} 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);
}
}
/**
* 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 + -