📄 pa_rewardpunishmentservlet.java
字号:
package com.galaxy.controller;
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.*;
import com.galaxy.util.PageHelp;
import com.galaxy.vo.*;
public class PA_RewardPunishmentServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public PA_RewardPunishmentServlet() {
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
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("gb2312");
String opflag="";
opflag=request.getParameter("opflag");
if("RPSave".equals(opflag)){
}
else if("query".equals(opflag)){
try{
DoMyQuery(request,response);
}
catch(SQLException e){
e.printStackTrace();
}
}
else if("rpadd".equals(opflag))
{
try{
DoAddRP(request,response);
}
catch(SQLException e){
e.printStackTrace();
}
}
else if("RPdel".equals(opflag))
{
try{
DoDelRP(request,response);
}
catch(SQLException e){
e.printStackTrace();
}
}
else if("RPchange".equals(opflag))
{
try{
DoChangeRP(request,response);
}
catch(SQLException e){
e.printStackTrace();
}
}
else if("RPimplementchange".equals(opflag))
{
try{
DoImplementChange(request,response);
}
catch(SQLException e){
e.printStackTrace();
}
}
else if("particularrp".equals(opflag))
{
try{
DoParticularRP(request,response);
}
catch(SQLException e){
e.printStackTrace();
}
}
else if("ajax".equals(opflag))
{
CheckPersonID(request, response);
}
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"))){
currentPage=Integer.parseInt(request.getParameter("errmessage"));
}
DeptInfoDAO depdao=new DeptInfoDAO();
ArrayList deplist=(ArrayList)depdao.queryByCondition("");
RewardPunishDAO repdao=new RewardPunishDAO();
ArrayList replist=(ArrayList)repdao.queryByCondition("");
String cond="";
if(request.getParameter("currentPage")!=null&&!"".equals(request.getParameter("currentPage"))){
currentPage=Integer.parseInt(request.getParameter("currentPage"));
}
PageHelp pagehelp=new PageHelp();//实例化PageHelp对象pageHelp
RewardPunishDAO rpdao=new RewardPunishDAO();
if(request.getParameter("selectdept")!=null&&!"".equals(request.getParameter("selectdept"))){
cond+=" and di_id="+request.getParameter("selectdept");
}
if(request.getParameter("ui_name")!=null&&!"".equals(request.getParameter("ui_name"))){
cond+=" and ui_realname like '%"+request.getParameter("ui_name")+"%'";
}
if(request.getParameter("rddate")!=null&&!"".equals(request.getParameter("rddate"))){
cond+=" and rp_time =to_date( '"+request.getParameter("rddate")+"','yyyy-mm-dd')";
}
if(request.getParameter("selecttype")!=null&&!"".equals(request.getParameter("selecttype"))){
cond+=" and rp_class ='"+request.getParameter("selecttype")+"'";
}
pagehelp=rpdao.getList(cond, pageSize, currentPage);
request.setAttribute("errmessage", errmessage);
request.setAttribute("deplist", deplist);
request.setAttribute("replist", replist);
request.setAttribute("pagehelp",pagehelp);
request.getRequestDispatcher("./psl_archive/punish_manage/pa_punishment.jsp").forward(request,response);
}
public void DoAddRP(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, SQLException{
RewardPunishDAO rpdao=new RewardPunishDAO();
RewardPunishVO rpvo=new RewardPunishVO();
UserInfoVO uservo=new UserInfoVO();
uservo.setUiPersonid(Long.valueOf(request.getParameter("prid")));
String sql="select ui_id from user_info where ui_personid="+uservo.getUiPersonid();
uservo.setUiId(rpdao.GetUIID(sql));
rpvo.setUserInfo(uservo);
rpvo.setRpClass(request.getParameter("prradiobutton"));
rpvo.setRpContent(request.getParameter("prtcontent"));
rpvo.setRpTitle(request.getParameter("prtitle"));
rpvo.setRpTime(Date.valueOf(request.getParameter("prtime")));
int i=0;
i=rpdao.addObject(rpvo);
if(i!=0){
int pageSize=5;//设置单页显示条数
int currentPage=1;//当前显示的页面号
String cond="";
PageHelp pagehelp=rpdao.getList(cond, pageSize, currentPage);
request.setAttribute("pagehelp",pagehelp);
request.getRequestDispatcher("PA_RewardPunishmentServlet?opflag=query").forward(request,response);
}else{
int pageSize=5;//设置单页显示条数
int currentPage=1;//当前显示的页面号
String cond="";
PageHelp pagehelp=rpdao.getList(cond, pageSize, currentPage);
request.setAttribute("pagehelp",pagehelp);
request.getRequestDispatcher("PA_RewardPunishmentServlet?opflag=query&errmessage=1").forward(request,response);
}
}
public void DoDelRP(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, SQLException{
RewardPunishDAO rpdao=new RewardPunishDAO();
String pitch[]=request.getParameterValues("rpcheckbox");
String cond="";
if(pitch.length!=0)
{
for(int i=0;i<pitch.length;i++)
{
cond +=","+pitch[i];
}
}
int i=0;
i=rpdao.deleteObject(cond);
if(i==0){
int pageSize=5;//设置单页显示条数
int currentPage=1;//当前显示的页面号
cond="";
PageHelp pagehelp=rpdao.getList(cond, pageSize, currentPage);
request.setAttribute("pagehelp",pagehelp);
request.getRequestDispatcher("PA_RewardPunishmentServlet?opflag=query").forward(request,response);
}else{
int pageSize=5;//设置单页显示条数
int currentPage=1;//当前显示的页面号
cond="";
PageHelp pagehelp=rpdao.getList(cond, pageSize, currentPage);
request.setAttribute("pagehelp",pagehelp);
request.getRequestDispatcher("PA_RewardPunishmentServlet?opflag=query&errmesage=3").forward(request,response);
}
}
public void DoChangeRP(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, SQLException{
RewardPunishDAO rpdao=new RewardPunishDAO();
RewardPunishVO rpvo=new RewardPunishVO();
String rpid=request.getParameter("changeid");
String sql="select * from user_info u join reward_punish c on u.ui_id=c.ui_id where rp_id="+rpid;
rpvo=(RewardPunishVO)rpdao.readObject(sql);
rpvo.setRpId(Long.valueOf(rpid));
request.setAttribute("rpvo",rpvo);
request.getRequestDispatcher("./psl_archive/punish_manage/pa_changepr.jsp").forward(request,response);
}
public void DoImplementChange(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, SQLException{
RewardPunishDAO rpdao=new RewardPunishDAO();
RewardPunishVO rpvo=new RewardPunishVO();
String rpid=request.getParameter("rpid");
rpvo.setRpId(Long.valueOf(request.getParameter("rpid")));
rpvo.setRpClass(request.getParameter("rpradiobutton"));
rpvo.setRpContent(request.getParameter("rpcontent"));
rpvo.setRpTime(Date.valueOf(request.getParameter("rpdate")));
rpvo.setRpTitle(request.getParameter("rptitle"));
String sql="update reward_punish set rp_class='"+rpvo.getRpClass()+
"',rp_title='"+rpvo.getRpTitle()+"',rp_time=to_date('"+request.getParameter("rpdate")+
"','yyyy-mm-dd'),rp_content='"+rpvo.getRpContent()+
"' where rp_id="+rpid;
int i=rpdao.updateObject(sql);
if(i!=0){
int pageSize=5;//设置单页显示条数
int currentPage=1;//当前显示的页面号
String cond="";
PageHelp pagehelp=rpdao.getList(cond, pageSize, currentPage);
request.setAttribute("pagehelp",pagehelp);
request.getRequestDispatcher("PA_RewardPunishmentServlet?opflag=query").forward(request,response);
}
else
{
int pageSize=5;//设置单页显示条数
int currentPage=1;//当前显示的页面号
String cond="";
PageHelp pagehelp=rpdao.getList(cond, pageSize, currentPage);
request.setAttribute("pagehelp",pagehelp);
request.getRequestDispatcher("PA_RewardPunishmentServlet?opflag=query&errmessage=2").forward(request,response);
}
}
public void DoParticularRP(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, SQLException{
int pageSize=5;//设置单页显示条数
int currentPage=1;//当前显示的页面号
String cond=" and u.ui_id="+request.getParameter("puiid");
PageHelp pagehelp=new PageHelp();//实例化PageHelp对象pageHelp
RewardPunishDAO rpdao=new RewardPunishDAO();
pagehelp=rpdao.getList(cond, pageSize, currentPage);
request.setAttribute("pagehelp",pagehelp);
request.getRequestDispatcher("./psl_archive/punish_manage/pa_prsingle.jsp").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();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -