SystemAction.java
资源名称:(J2EE)oa.rar [点击查看]
上传用户:lm2018
上传日期:2015-12-12
资源大小:30449k
文件大小:6k
源码类别:
Jsp/Servlet
开发平台:
Java
- //Created by MyEclipse Struts
- // XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.1.0/xslt/JavaClass.xsl
- package com.oa.module.system;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.util.List;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.apache.struts.action.ActionForm;
- import org.apache.struts.action.ActionForward;
- import org.apache.struts.action.ActionMapping;
- import org.apache.struts.actions.DispatchAction;
- import com.oa.module.system.SystemForm;
- /**
- * MyEclipse Struts
- * Creation date: 01-20-2008
- *
- * XDoclet definition:
- * @struts.action path="/system" name="systemForm" parameter="task" scope="request" validate="true"
- */
- public class SystemAction extends DispatchAction {
- // --------------------------------------------------------- Instance Variables
- public SystemDAO systemdao;
- // --------------------------------------------------------- Methods
- public SystemDAO getSystemdao() {
- return systemdao;
- }
- public void setSystemdao(SystemDAO systemdao) {
- this.systemdao = systemdao;
- }
- /**
- * Method execute
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return ActionForward
- */
- //更新页面
- public ActionForward query(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- SystemForm systemForm = (SystemForm) form;
- List typelist = null;
- List paramlist = null;
- typelist = systemdao.gettype();
- paramlist = systemdao.getparam();
- request.setAttribute("typelist", typelist);
- request.setAttribute("paramlist", paramlist);
- return mapping.findForward("list");
- }
- //添加类别
- public ActionForward savetype(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- SystemForm systemForm = (SystemForm) form;
- String tname = systemForm.getTname();
- String tmemo = systemForm.getTmemo();
- //验证类别是否存在
- boolean check=systemdao.checktype(tname);
- if(check){
- request.setAttribute("msg","类别名已存在");
- return mapping.findForward("query");
- }else{
- boolean flag = systemdao.addtype(tname, tmemo);
- if (flag) {
- request.setAttribute("msg", "添加参数类别成功");
- return mapping.findForward("query");
- } else {
- request.setAttribute("msg", "添加参数类别失败");
- return mapping.findForward("query");
- }
- }
- }
- //添加参数
- public ActionForward saveparam(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response){
- SystemForm systemForm = (SystemForm) form;
- long tid = systemForm.getTid();
- System.out.println(systemForm.getTid());
- String pname = systemForm.getPname();
- String pmemo = systemForm.getPmemo();
- //验证参数是否存在
- boolean check=systemdao.checkparam(pname);
- if(check){
- request.setAttribute("msg","参数名已存在");
- return mapping.findForward("query");
- }else{
- boolean flag = systemdao.addparam(tid, pname, pmemo);
- if (flag) {
- request.setAttribute("msg", "添加参数成功");
- return mapping.findForward("query");
- } else {
- request.setAttribute("msg", "添加参数失败");
- return mapping.findForward("query");
- }
- }
- }
- //删除参数类别
- public ActionForward deltype(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- SystemForm systemForm = (SystemForm) form;
- long tid = systemForm.getTid();
- System.out.println(systemForm.getTid());
- boolean flag = systemdao.deltype(tid);
- if (flag) {
- request.setAttribute("msg", "删除参数类别成功");
- return mapping.findForward("query");
- } else {
- request.setAttribute("msg", "删除参数类别失败");
- return mapping.findForward("query");
- }
- }
- //删除参数
- public ActionForward delparam(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- SystemForm systemForm = (SystemForm) form;
- long pid = systemForm.getPid();
- boolean flag = systemdao.delparam(pid);
- if (flag) {
- request.setAttribute("msg", "删除参数成功");
- return mapping.findForward("query");
- } else {
- request.setAttribute("msg", "删除参数失败");
- return mapping.findForward("query");
- }
- }
- //修改参数类别
- public ActionForward edittype(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- SystemForm systemForm = (SystemForm) form;
- long tid=systemForm.getTid();
- System.out.println(tid);
- String tname=systemForm.getTname();
- System.out.println(tname);
- String tmemo=systemForm.getTmemo();
- System.out.println(tmemo);
- //验证类别是否存在
- boolean check=systemdao.checktype(tname);
- if(check){
- request.setAttribute("msg","类别名已存在");
- return mapping.findForward("query");
- }else{
- boolean flag =systemdao.edittype(tid,tname,tmemo);
- if (flag) {
- request.setAttribute("msg", "修改参数类别成功");
- return mapping.findForward("query");
- } else {
- request.setAttribute("msg", "修改参数类别失败");
- return mapping.findForward("query");
- }
- }
- }
- //修改参数
- public ActionForward editparam(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- SystemForm systemForm = (SystemForm) form;
- long tid=systemForm.getTid();
- long pid = systemForm.getPid();
- String pname=systemForm.getPname();
- String pmemo=systemForm.getPmemo();
- //验证参数是否存在
- boolean check=systemdao.checkparam(pname);
- if(check){
- request.setAttribute("msg","参数名已存在");
- return mapping.findForward("query");
- }else{
- boolean flag = systemdao.editparam(tid,pid,pname,pmemo);
- if (flag) {
- request.setAttribute("msg", "修改参数成功");
- return mapping.findForward("query");
- } else {
- request.setAttribute("msg", "修改参数失败");
- return mapping.findForward("query");
- }
- }
- }
- }