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