UserModAction.java~17~
上传用户: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.             DBConn dbc = new DBConn();
  15.             Tool tl  = new Tool();
  16.             String un = request.getParameter("username");
  17.             if(un==null){
  18.                 request.setAttribute("msg", "请选择用户!");
  19.                 return mapping.findForward("err");
  20.             }
  21.             String dep = request.getParameter("dep");
  22.             String sql = "update [user] set deparment = '"+dep+"' where unmd5='"+un+"'";
  23.             int i = dbc.executeUpdate(sql);
  24.             if(i!=0){
  25.                 request.setAttribute("msg", "用户 " + un + " 修改成功!");
  26.                 return mapping.findForward("succ");
  27.             }else{
  28.                 request.setAttribute("msg", "用户 " + un + " 修改出错,请重试!");
  29.                 return mapping.findForward("succ");
  30.             }
  31.         }catch(Exception ex){
  32.             ex.printStackTrace();
  33.             request.setAttribute("msg","用户修改出现异常,请重试!");
  34.         }
  35.         return mapping.findForward("err");
  36.     }
  37. }