UsergroupAddAction.java~39~
资源名称:bangong.rar [点击查看]
上传用户:dlqqsh
上传日期:2021-11-13
资源大小:7840k
文件大小:3k
源码类别:
OA系统
开发平台:
Java
- package officeol.mc.actions;
- import org.apache.struts.action.ActionMapping;
- import org.apache.struts.action.ActionForm;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.apache.struts.action.ActionForward;
- import org.apache.struts.action.Action;
- import officeol.mc.tools.*;
- public class UsergroupAddAction extends Action {
- public ActionForward execute(ActionMapping mapping, ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) {
- try {
- request.setCharacterEncoding("GBK");
- String ugname = request.getParameter("ugname");
- String dep = request.getParameter("dep");
- int ulen = Integer.parseInt(request.getParameter("ulen"));
- String[] uid = new String[ulen];
- String a = "a";
- for (int i = 0; i < ulen; i++) {
- uid[i] = request.getParameter("user" + i);
- if(uid[i]!=null){
- a = "b";
- }
- }
- DBConn dbc = new DBConn();
- Tool tl = new Tool();
- if (ugname != null && !ugname.equals("")) {
- String ugcheck =
- "select usergroup from usergroup where usergroup='" +
- ugname + "'";
- String[][] ugc = dbc.getArray(ugcheck);
- String ugmd5 = tl.hash(ugname);
- if (ugc == null) {
- if (a.equals("b")) {
- for (int i = 0; i < ulen; i++) {
- if (uid[i] != null) {
- String asql =
- "insert into usergroup (usergroup,userid,depid,ugmd5) values('" +
- ugname + "'," + uid[i] + ",'" + dep +
- "','" + ugmd5 + "')";
- System.out.println(asql);
- dbc.executeUpdate(asql);
- }
- }
- request.setAttribute("msg", "用户组" + ugname + "添加成功!");
- return mapping.findForward("succ");
- } else {
- System.out.println("uid is null");
- request.setAttribute("msg", "没有选择需要添加的用户!");
- return mapping.findForward("err");
- }
- } else {
- request.setAttribute("msg", "用户名已经存在!");
- return mapping.findForward("err");
- }
- } else {
- request.setAttribute("msg", "用户组名不能为空!");
- return mapping.findForward("err");
- }
- } catch (Exception ex) {
- request.setAttribute("msg", "用户组添加出现异常,请重试!");
- }
- return mapping.findForward("err");
- }
- }