UserModAction.java~21~
上传用户:dlqqsh
上传日期:2021-11-13
资源大小:7840k
文件大小:2k
源码类别:

OA系统

开发平台:

Java

  1. package officeol.mc.actions;
  2. import org.apache.struts.action.ActionMapping;
  3. import org.apache.struts.action.ActionForm;
  4. import javax.servlet.http.HttpServletRequest;
  5. import javax.servlet.http.HttpServletResponse;
  6. import org.apache.struts.action.ActionForward;
  7. import org.apache.struts.action.Action;
  8. import officeol.mc.tools.*;
  9. public class UserModAction extends Action {
  10.     public ActionForward execute(ActionMapping mapping, ActionForm form,
  11.                                  HttpServletRequest request,
  12.                                  HttpServletResponse response) {
  13.         try{
  14.             request.setCharacterEncoding("GBK");
  15.             DBConn dbc = new DBConn();
  16.             Tool tl  = new Tool();
  17.             String unmd5 = request.getParameter("username");
  18.             if(unmd5==null){
  19.                 request.setAttribute("msg", "请选择用户!");
  20.                 return mapping.findForward("err");
  21.             }
  22.             String dep = request.getParameter("dep");
  23.             String un = request.getParameter("un");
  24.             String sql = "update [user] set deparment = '"+dep+"' where unmd5='"+unmd5+"'";
  25.             int i = dbc.executeUpdate(sql);
  26.             if(i!=0){
  27.                 request.setAttribute("msg", "用户 " + un + " 修改成功!");
  28.                 return mapping.findForward("succ");
  29.             }else{
  30.                 request.setAttribute("msg", "用户 " + un + " 修改出错,请重试!");
  31.                 return mapping.findForward("err");
  32.             }
  33.         }catch(Exception ex){
  34.             ex.printStackTrace();
  35.             request.setAttribute("msg","用户修改出现异常,请重试!");
  36.         }
  37.         return mapping.findForward("err");
  38.     }
  39. }