PopegroupAddAction.java~32~
资源名称: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 java.io.UnsupportedEncodingException;
- import officeol.mc.tools.*;
- public class PopegroupAddAction extends Action {
- public ActionForward execute(ActionMapping mapping, ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) {
- try {
- request.setCharacterEncoding("GBK");
- } catch (UnsupportedEncodingException ex) {
- ex.printStackTrace();
- }
- try{
- String num = request.getParameter("num");
- String[] ids = new String[Integer.parseInt(num)];
- String pgname = request.getParameter("pgname");
- //System.out.println("pgname "+pgname);
- String[] sql = new String[Integer.parseInt(num)];
- DBConn dbc = new DBConn();
- if(!pgname.equals("")){
- String[][] chcek = dbc.getArray("SELECT * FROM popedomgroup WHERE popegroup='"+pgname+"'");
- if(chcek!=null){
- request.setAttribute("msg","用户组"+pgname+"已经存在,请重新输入新的用户组名!");
- request.setAttribute("info", "用户组"+pgname+"已经存在,请重新输入新的用户组名!");
- System.out.println("用户组"+pgname+"已经存在,请重新输入新的用户组名!");
- return mapping.findForward("err");
- }
- for (int i = 0; i < ids.length; i++) {
- ids[i] = request.getParameter("id" + i);
- if (ids[i] != null) {
- sql[i] =
- "insert into popedomgroup (popeid,popegroup) values(" +
- ids[i] + ",'" + pgname + "')";
- //System.out.println(sql[i]);
- dbc.executeUpdate(sql[i]);
- }
- System.out.print("添加新用户"+pgname+"组成功!");
- request.setAttribute("info","添加新用户"+pgname+"组成功!");
- return mapping.findForward("succ");
- }
- }else{
- request.setAttribute("info","paname is null");
- System.out.println("pgname is null");
- }
- }catch(Exception ex){
- ex.printStackTrace();
- }
- return mapping.findForward("err");
- }
- }