UserPopeAddAction.java
上传用户: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 UserPopeAddAction extends Action {
  10.     public ActionForward execute(ActionMapping mapping, ActionForm form,
  11.                                  HttpServletRequest request,
  12.                                  HttpServletResponse response) {
  13.         try{
  14.             request.setCharacterEncoding("GBK");
  15.             String ug = request.getParameter("ug");
  16.             String pg = request.getParameter("pg");
  17.             String sm = request.getParameter("sm");
  18.             Tool tl = new Tool();
  19.             String ugmd5 = tl.hash(ug);
  20.             String isql = "insert into groupmanage (usergroup,popegroup,shuoming,ugmd5) values('"+
  21.                           ug+"','"+pg+"','"+sm+"','"+ugmd5+"')";
  22.             DBConn dbc = new DBConn();
  23.             String csql = "select * from groupmanage where usergroup='"+
  24.                           ug+"'";
  25.             //System.out.println(csql);
  26.             if(dbc.getArray(csql)==null){
  27.                 //System.out.println(isql);
  28.                 dbc.executeUpdate(isql);
  29.                 request.setAttribute("msg", "添加成功!");
  30.             }else{
  31.                 request.setAttribute("msg","该用户组已经有权限,不需要再添加!");
  32.             }
  33.         }catch(Exception ex){
  34.             ex.printStackTrace();
  35.             request.setAttribute("msg","添加出现异常,请重试!");
  36.         }
  37.         return mapping.findForward("succ");
  38.     }
  39. }