scheduleoperatoraction.java

来自「培训考试系统代码」· Java 代码 · 共 656 行 · 第 1/2 页

JAVA
656
字号
package com.huawei.icd30.agt.schedule;

import org.apache.struts.action.*;
import javax.servlet.http.*;
import com.huawei.icd30.agt.*;
import com.huawei.icd30.agt.util.*;
import com.huawei.icd30.common.db.*;
import com.huawei.icd30.agt.util.*;
import java.util.Date;
import com.huawei.icd30.common.systemconfig.*;




/**
 *
 * <p> 本类的功能描述信息</p>
 * <p> (这家伙很懒,什么都没有写)</p>
 * <p> </p>
 * <p> </p>
 * @author unascribed
 * @version 1.0
 */
public final class ScheduleOperatorAction  extends Action
{

    /**
     *
     * @param mapping
     * @param actionForm
     * @param request
     * @param response
     * @return
     */

    public ActionForward perform(ActionMapping mapping, ActionForm actionForm,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
    {

        ScheduleOperatorForm form = (ScheduleOperatorForm) actionForm;
        String operatorFlag = form.getOperatorFlag();
        operatorFlag = operatorFlag == null
                     ?request.getParameter("operatorFlag") : operatorFlag;

        if (operatorFlag.equals(OperatorFlagCode.SCHEDULE_ADD))
        {
            return addSchedule(mapping, form, request);
        }
        else if (operatorFlag.equals(OperatorFlagCode.SCHEDULE_MYSCHEDULE))
        {
            return myScheduleList(mapping, form, request);
        }
        else if (operatorFlag.equals(OperatorFlagCode.SCHEDULE_MOD))
        {
            return modify(mapping, form, request);
        }
        else if (operatorFlag.equals(OperatorFlagCode.SCHEDULE_SAVE))
        {
            return save(mapping, form, request);
        }
        else if (operatorFlag.equals(OperatorFlagCode.SCHEDULE_DELET))
       {
           return delete(mapping, form, request);
        }
        else if (operatorFlag.equals(OperatorFlagCode.SCHEDULE_VIEW)||
            operatorFlag.equals(OperatorFlagCode.SCHEDULE_MYVIEW))
        {
            return view(mapping, form, request);
        }
        //
        else if (operatorFlag.equals(OperatorFlagCode.SCHEDULE_SEARCH))
        {
            return getSearchSchedule(mapping, form, request);
        }
        else if (operatorFlag.equals("SCHEDULE_DELET"))
        {
            request.getSession().setAttribute("scheduleids", form.getScheduleIDs());
            return delete(mapping ,form,request);
        }
        else if (operatorFlag.equals("SCHEDULE_SETREMIND"))
        {
            return setRemind(mapping, form, request);
        }

        else if (operatorFlag.equals("SCHEDULE_CANCELREMIND"))
        {
            return cancelRemind(mapping, form, request);
        }
        else
        {
            request.setAttribute("errorid", "");
            return mapping.findForward("error");
        }
    }



    /**
     * 获得一条日程信息
     * @param mapping
     * @param form
     * @param request
     * @return
     */
    private void getDetail(SysDbConn con,
                           ScheduleOperatorForm    form,
                           HttpServletRequest req) throws SysDbException ,
    java.sql.SQLException
    {
        con.preparedSP();
        con.setString(1,form.getScheduleID()[0]);
        SysResultSet res = new ResUtil(con.csCommonSP("p_agt_scheduledetail").getResultSet());
        req.setAttribute("schedule_detail",res);
    }

    /**
     * 获得日程列表
     * @param mapping
     * @param form
     * @param request
     * @return
     */
    private ActionForward getSearchSchedule(ActionMapping mapping,
            ScheduleOperatorForm form,
            HttpServletRequest request)
    {
/*
        SysConnPool cspool = null;
        SysDbConn con = null;
        String sqlQuery = null;
*/
        SysDbConn aplcoms = null ;
        try {
          aplcoms = SysConnPool.getInstance().getAplComs();
          aplcoms.preparedSP();

           //获得输入参数
           aplcoms.setString(1,form.getScheduleName());
           aplcoms.setString(2,form.getNote());
           aplcoms.setString(3,form.getBeginFromTime());
           aplcoms.setString(4,form.getBeginToTime());
           aplcoms.setString(5,form.getEndFromTime());
           aplcoms.setString(6,form.getEndToTime());
           aplcoms.setString(7,form.getDoRemind());
           aplcoms.setString(8,form.getRemindFromTime());
           aplcoms.setString(9,form.getRemindToTime());
           aplcoms.setString(10,form.getMakeFromTime());
           aplcoms.setString(11,form.getMakeToTime());
           aplcoms.setString(12,form.getRecieverString());
           aplcoms.setString(13,(String)request.getSession().getAttribute("staffno"));
           aplcoms.setString(14,form.getRecieverName());
           //调用P_Agt_ScheduleSearch查询,得到数据集rs1
           SysResultSet rs1 = aplcoms.csCommonSP("P_Agt_ScheduleSearch").getResultSet();
           rs1.next();
           aplcoms.preparedQuery(rs1.getString(1));
           SysResultSet rs2 = aplcoms.csCommonQuery("SELFSQL","1","-1").getResultSet();
           //if (rs 不为空)
           if (rs2 != null)
           {
            //按ID排序
            rs2.sort(0,true);
            //将结果集放到session中 PLANMNG-LIST
            request.getSession().setAttribute("SCHEDULE_SEARCH_RES", new ResUtil(rs2));
          }
          else  return(mapping.findForward("error"));


/*
            cspool = SysConnPool.getInstance();
            con = cspool.getAplComs();
            log(form.getSearchSQL()+"sql");
            con.preparedQuery(form.getSearchSQL());
            SysResultSet res = con.csCommonQuery("SEL_AGT_SQL", "1", "-1").getResultSet();
            request.getSession().setAttribute("SCHEDULE_SEARCH_RES", res);
*/
        }
        catch (SysDbException e)
        {
            request.setAttribute("errorId", ErrorCode.COMMONSERVICE_ERROR);
            return mapping.findForward("error");
        }
        catch (java.sql.SQLException e)
        {
            request.setAttribute("errorId", ErrorCode.DATABASE_ERROR);
            return mapping.findForward("error");
        }
        finally
        {
          if(aplcoms != null)
          {
             aplcoms.close();
          }
        }
        return mapping.findForward("searchlist");
    }

    /**
     * 搜索
     * @param mapping
     * @param form
     * @param request
     * @return
     */
    private ActionForward getScheduleList(ActionMapping mapping,
            ScheduleOperatorForm form,
            HttpServletRequest request)
    {
        SysConnPool cspool = null;
        SysDbConn con = null;
        try
        {
            cspool = SysConnPool.getInstance();
            con = cspool.getAplComs();
            con.preparedQuery("");
            con.setString(1, (String) request.getSession().getAttribute(
                    "clsmngselect"));
            SysResultSet res = con.csCommonQuery(
                    "SQL_AGT_CLSMNGGETALL", "1", "-1").getResultSet();
            request.getSession().setAttribute("CLSMNG_SELECTTYPE", res);
            } catch (SysDbException e)
            {
                request.setAttribute("errorId", ErrorCode.COMMONSERVICE_ERROR);
                return mapping.findForward("error");
            }
            catch (java.sql.SQLException e)
            {
                request.setAttribute("errorId", ErrorCode.DATABASE_ERROR);
                return mapping.findForward("error");
            }
            finally
            {
                con.close();
            }
            return mapping.findForward("operator");
    }

    /**
     * 我的日程列表页面
     * @param mapping
     * @param form
     * @param request
     * @return
     */
    private ActionForward myScheduleList(ActionMapping mapping,
            ScheduleOperatorForm form,
            HttpServletRequest request)
    {
        SysConnPool cspool = null;
        SysDbConn con = null;
        try
        {
            cspool = SysConnPool.getInstance();
            con = cspool.getAplComs();
            con.preparedQuery("");
            con.setString(1, (String) request.getSession().getAttribute("staffno"));
            SysResultSet res = new ResUtil(con.csCommonQuery(
                    "SQL_AGT_MYSCHEDULE", "1", "-1").getResultSet());
            request.getSession().setAttribute("schedule_myres", res);
        }
        catch (SysDbException e)
        {
            request.setAttribute("errorId", ErrorCode.COMMONSERVICE_ERROR);
            return mapping.findForward("error");
        }
        catch (java.sql.SQLException e)
        {
            request.setAttribute("errorId", ErrorCode.DATABASE_ERROR);
            return mapping.findForward("error");
        }
        finally
        {
            con.close();
        }
        return mapping.findForward("myshedule");
    }

    /**
     * 删除日程
     * @param mapping
     * @param form
     * @param request
     * @return
     */
    private ActionForward delete(ActionMapping mapping,
                                 ScheduleOperatorForm form,
                                 HttpServletRequest request)
    {
        SysConnPool cspool = null;
        SysDbConn con = null;
        String ids[] = form.getScheduleID();
        String lessonid ="";
        for( int i=0; i<ids.length -1 ; i++)
        {
            lessonid += ids[i] +"~";
        }
        lessonid = lessonid + ids[ids.length -1];

        try
        {
            cspool = SysConnPool.getInstance();
            con = cspool.getAplComs();
            con.preparedSP();
            con.setString(1,lessonid);
            SysRecord res  = con.csCommonSP("p_agt_scheduledel").getParamSet();
            if( res.getInt(0) !=0)
            {
                request.setAttribute("errorId", ErrorCode.SCHEDULE_DEL);
                return mapping.findForward("error");
            }
        }
        catch (SysDbException e)
        {
            request.setAttribute("errorId", ErrorCode.COMMONSERVICE_ERROR);
            return mapping.findForward("error");
        }
        catch (java.sql.SQLException e)
        {
            request.setAttribute("errorId", ErrorCode.DATABASE_ERROR);
            return mapping.findForward("error");
        }
        finally
        {
            con.close();
        }
        return getSearchSchedule(mapping,form,request);
    }

⌨️ 快捷键说明

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