package com.creditratingmodule.servlet;
import com.creditratingmodule.bean.TbCreditRating;
import com.creditratingmodule.dao.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import util.*;
public class TbCreditRatingServlet extends HttpServlet{
public void processRequest(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
String method = request.getParameter("method")==null?"":request.getParameter("method");
if("add".equals(method)){
int creditRatingTypeId=Integer.parseInt(request.getParameter("creditRatingTypeId"));
double creditRatingScore=Double.valueOf(request.getParameter("creditRatingScore"));
if(new TbCreditRatingDAO().add(new TbCreditRating(creditRatingTypeId,creditRatingScore,new UtilDAO().decodeDate()))){
request.getSession().setAttribute("result", "添加成功");
}else{
request.getSession().setAttribute("result", "添加失败");
}
request.getSession(true).setAttribute("tbCreditRatingList",new TbCreditRatingDAO().getTbCreditRatingAll());
response.sendRedirect("CreditratingModule/TbCreditRatingList.jsp");
}
if("del".equals(method)){
if(UtilDAO.delin("Tb_CreditRating", "CreditRatingId", request.getParameter("delIds"))){
request.getSession().setAttribute("result", "删除成功");
}else{
request.getSession().setAttribute("result", "删除失败");
}
request.getSession(true).setAttribute("tbCreditRatingList",new TbCreditRatingDAO().getTbCreditRatingAll());
response.sendRedirect("CreditratingModule/TbCreditRatingList.jsp");
}
if("edit".equals(method)){
int creditRatingId=Integer.parseInt(request.getParameter("creditRatingId"));
int creditRatingTypeId=Integer.parseInt(request.getParameter("creditRatingTypeId"));
double creditRatingScore=Double.valueOf(request.getParameter("creditRatingScore"));
if(new TbCreditRatingDAO().edit(new TbCreditRating(creditRatingId,creditRatingTypeId,creditRatingScore,new UtilDAO().decodeDate()))){
request.getSession().setAttribute("result", "修改成功");
}else{
request.getSession().setAttribute("result", "修改失败");
}
request.getSession(true).setAttribute("tbCreditRatingList",new TbCreditRatingDAO().getTbCreditRatingAll());
response.sendRedirect("CreditratingModule/TbCreditRatingList.jsp");
}
if ("list".equals(method)) {
request.getSession(true).setAttribute("tbCreditRatingList",new TbCreditRatingDAO().getTbCreditRatingAll());
response.sendRedirect("CreditratingModule/TbCreditRatingList.jsp");
}
if ("listById".equals(method)) {
request.getSession(true).setAttribute("tbCreditRating",new TbCreditRatingDAO().getTbCreditRatingByCreditRatingId(Integer.parseInt(request.getParameter("creditRatingId"))));
response.sendRedirect("CreditratingModule/TbCreditRatingOperate.jsp");
}
if("showadd".equals(method)){
response.sendRedirect("CreditratingModule/TbCreditRatingOperate.jsp");
}
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.processRequest(request, response);
}// end method doGet
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.processRequest(request, response);
}// end method doPost
}