⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 affairtypeaction.java

📁 基于J2EE的办公自动化系统。实现流程定义流程办理等。运用了hibernate+struts+spring框架综合运用的系统。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			}				}		public ActionForward editedtype(			ActionMapping mapping,			ActionForm form,			HttpServletRequest request,			HttpServletResponse response) throws IllegalAccessException, InvocationTargetException{			AffairTypeForm affairTypeForm = (AffairTypeForm) form;					System.out.println("edited");			String transID = request.getParameter("rtid");			String filename = System.currentTimeMillis() + ".xml";						String dir = servlet.getServletContext().getRealPath("upload")+ "\\affairXml";			affairTypeForm.setTxmlpath(filename);			affairTypeForm.setRtid(Integer.parseInt(transID));						//先删除后再重新添加			boolean isdel = false;			boolean flag0 = affairdao.deltyperole(transID);			if(flag0){				isdel = affairdao.delaffair(transID,dir);							}									if(isdel){				String date = ToolUtil.getDate();				affairTypeForm.setTtime(date);				HttpSession httpsession  = request.getSession();				Tuser user = (Tuser)httpsession.getAttribute("user");					affairTypeForm.setUno(user.getUno());				String tstep = request.getParameter("tstep");				int count = 0;				if(tstep!=null){					 count = Integer.parseInt(tstep);				}				Transtype type = new Transtype();				type.setTrid(request.getParameter("transroleid0"));						BeanUtils.copyProperties(type, affairTypeForm);				for (int i = 0; i < count; i++) {									Transpower power = new Transpower();								power.setTranstype(type);					power.setTpid(i+1);					power.setRqid(request.getParameter("roleid"+i));					power.setUno(request.getParameter("userid"+i));					type.getTranspower().add(power);							}				boolean flag = this.affairdao.addAffairType(type,request);					String[] transroleid = request.getParameter("transroleid0").split(",");									this.affairdao.addtyperole(type.getRtid(),transroleid);				if (flag == true) {				    //把事务环节写到XML文件							Document doc = new Document();					Element root = new Element("steps");					int stepCount = Integer.valueOf(request.getParameter("tstep")).intValue();					for (int i = 0; i < stepCount; i++) {						Element step = new Element("step");						Element id = new Element("id");						id.setText("" + (i + 1));						Element userid = new Element("userid");						userid.setText(request.getParameter("userid" + i));						Element roleid = new Element("roleid");						roleid.setText(request.getParameter("roleid" + i));						step.addContent(id);						step.addContent(userid);						step.addContent(roleid);						root.addContent(step);					}					doc.addContent(root);					Format format = Format.getCompactFormat();					format.setIndent("  ");					format.setEncoding("gb2312");					XMLOutputter out = new XMLOutputter(format);					OutputStream fileout = null;					String path = servlet.getServletContext().getRealPath("upload")+"\\affairXml" + File.separator + filename;					try {						fileout = new FileOutputStream(path);						out.output(doc, fileout);						response.getWriter().println("<script>alert('修改成功');");						response.getWriter().println("</script>");						affairTypeForm.setTask("getlist");						return mapping.findForward("query");					} catch (FileNotFoundException e) {												try {							response.getWriter().print("<script>alert('修改失败');window.history.back();</script>");						} catch (IOException e1) {							// TODO 自动生成 catch 块							e1.printStackTrace();						}						// TODO 自动生成 catch 块						e.printStackTrace();					} catch (IOException e) {						// TODO 自动生成 catch 块						e.printStackTrace();					}				}			}						return null;				}		public ActionForward deltype(			ActionMapping mapping,			ActionForm form,			HttpServletRequest request,			HttpServletResponse response) throws IllegalAccessException, InvocationTargetException{			AffairTypeForm affairTypeForm = (AffairTypeForm) form;			System.out.println("deltype");			String transID = request.getParameter("rtid");				String dir = servlet.getServletContext().getRealPath("upload")+ "/affairXml";			affairTypeForm.setRtid(Integer.parseInt(transID));			try {				boolean isdel =  false;				boolean flag0 = affairdao.deltyperole(transID);				if(flag0){					isdel = affairdao.delaffair(transID,dir);								}							if(isdel){											response.getWriter().println("<script>alert('删除成功');");						response.getWriter().println("</script>");						affairTypeForm.setTask("getlist");						return mapping.findForward("query");														}else{					response.getWriter().print("<script>alert('删除失败');window.history.back();</script>");				}			}catch (IOException e) {				try {					response.getWriter().print("<script>alert('删除失败');window.history.back();</script>");				} catch (IOException e1) {					// TODO 自动生成 catch 块					e1.printStackTrace();				}				// TODO 自动生成 catch 块				e.printStackTrace();			}			return null;				}	public ActionForward getUserRole(			ActionMapping mapping,			ActionForm form,			HttpServletRequest request,			HttpServletResponse response) throws UnsupportedEncodingException {			request.setCharacterEncoding("GBK");			response.setCharacterEncoding("GBK");			AffairTypeForm affairTypeForm = (AffairTypeForm) form;			List list = null;			String type = request.getParameter("type");			String name = request.getParameter("name");			if (type.equals("user")) {				list = this.userdao.getuser();			} else {				list = this.roledao.getrole();			}			request.setAttribute("list", list);			request.setAttribute("type", type);			request.setAttribute("id", name);			return new ActionForward("/Jsp_file/affair/roleuser.jsp");		}				public ActionForward checkname(			ActionMapping mapping,			ActionForm form,			HttpServletRequest request,			HttpServletResponse response) throws UnsupportedEncodingException {			request.setCharacterEncoding("GBK");			response.setCharacterEncoding("GBK");					AffairTypeForm affairTypeForm = (AffairTypeForm) form;						try {				PrintWriter out = response.getWriter();				String type = request.getParameter("type");								String message = null;				boolean flag = true;				flag = this.affairdao.checkName(affairTypeForm);								if(type!=null){					if(type.equals("add")){						if(flag){							message ="<a style='color: red' >名称被使用了</a>";						} else {							message = "<a style='color: #00cc00' >名称可以使用</a>";						}					}else if(type.equals("edit")){							String rtid = request.getParameter("rtid");						Map bean  = affairdao.getaffair(rtid);						String oldname = (String) bean.get("tname");						System.out.println(oldname);						if(affairTypeForm.getTname().equals(oldname)){							message = "<a style='color: #00cc00' >名称可以修改</a>";						}else{							if(flag){								message ="<a style='color: red' >名称被使用了</a>";							} else {								message = "<a style='color: #00cc00' >名称可以使用</a>";							}						}					}					out.print(message);					out.flush();					out.close();									}											} catch (IOException e) {				// TODO 自动生成 catch 块				e.printStackTrace();			}			return null;		}				public IAffair getAffairdao() {		return affairdao;	}	public void setAffairdao(IAffair affairdao) {		this.affairdao = affairdao;	}	public UserDAO getUserdao() {		return userdao;	}	public void setUserdao(UserDAO userdao) {		this.userdao = userdao;	}	public RoleDAO getRoledao() {		return roledao;	}	public void setRoledao(RoleDAO roledao) {		this.roledao = roledao;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -