package zr.zrpower.web.servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import zr.zrpower.web.bean.MessageBox;
import zr.zrpower.entity.sys.BPIP_USER_REMOVE;
import zr.zrpower.ejb.sys.UserRemoveService;
import zr.zrpower.common.util.FunctionMessage;

public class ActionUserRemove
    extends MessageBox {

  //Initialize global variables
  public void init() throws ServletException {
  }

  //Process the HTTP Get request
  public void doGet(HttpServletRequest request, HttpServletResponse response) throws
      ServletException, IOException {
    request.setCharacterEncoding("GBK");
    response.setContentType("text/html; charset=GBK");
    String strAction = request.getParameter("Act");
    if (!strAction.equals(null)) {


      if (strAction.equals("add")) {
        AddUserRemove(request, response);
      }
    }
  }

  //Process the HTTP Post request
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws
      ServletException, IOException {
    doGet(request, response);
  }

  //Clean up resources
  public void destroy() {
  }
 //添加调动
  private void AddUserRemove(HttpServletRequest request, HttpServletResponse response) throws
      IOException {
    FunctionMessage fm = new FunctionMessage(1);
    BPIP_USER_REMOVE ID = new BPIP_USER_REMOVE();
    String unitid = request.getParameter("AFTERUNIT");
    try {
      UserRemoveService UserRemove = new UserRemoveService();
      ID.fullDataFromRequest(request);

      fm = UserRemove.AddID(ID);
      if (fm.getResult()) {
        ID = null;
        UserRemove = null;
        response.sendRedirect("zrsysmanage/UserList.jsp?nodeId="+unitid);
       }
      else {
        this.Msg = fm.getMessage();
        this.isOk = fm.getResult();
      }
    }
    catch (Exception ex2) {
      this.Msg = "连接客户端文件中间件服务失败！<br>详细错误信息：<br>   " + ex2.toString();
    }

    this.out = response.getWriter();
    this.returnPath = "zrsysmanage/UserList.jsp?unitid="+unitid;
    //this.GetBox();

  }


}

