scheduleoperatoraction.java

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

JAVA
656
字号
    /**
     * 取消提醒
     * @param mapping
     * @param form
     * @param request
     * @return
     */
    private ActionForward cancelRemind(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(
                    "schedulename"));
            SysResultSet res = con.csCommonQuery(
                    "SQL_AGT_CLSMNGGETALL", "1", "-1").getResultSet();
        } 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 setRemind(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(
                    "scheduleid"));
            SysResultSet res = con.csCommonQuery(
                    "SQL_AGT_CLSMNGGETALL", "1", "-1").getResultSet();
        } 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 form1
     * @param request
     * @return
     */
    private ActionForward addSchedule(ActionMapping mapping,
                                      ScheduleOperatorForm form,
                                      HttpServletRequest request
                                      )
    {
      String staffIds = form.getStaffIds();
      if (staffIds != null)
      {
          staffIds = staffIds.replaceAll(",","#");
      }
        SysDbConn con = null;
/*
        java.text.SimpleDateFormat date = new java.text.SimpleDateFormat("yyyy-MM-dd");
        Date endtime   = null;
        Date begintime   = null;
        Date remindtime     = null;
        try
        {
            endtime  = date.parse(((ScheduleOperatorForm)form).getEndTime().trim());
            begintime  = date.parse(((ScheduleOperatorForm)form).getBeginTime().trim());
            if( ((ScheduleOperatorForm)form).getRemindTime()!= null)
                remindtime = date.parse(((ScheduleOperatorForm)form).getRemindTime());
        System.out.print(((ScheduleOperatorForm)form).getEndTime());
        System.out.print(((ScheduleOperatorForm)form).getBeginTime());
        System.out.print(((ScheduleOperatorForm)form).getRemindTime());}
        catch(Exception e)
        {

            e.printStackTrace();
            request.setAttribute("errorId",ErrorCode.DATAFORMAT_ERROR);
            return mapping.findForward("error");
        }
        */
        try
        {
            con = SysConnPool.getInstance().getAplComs();
            con.preparedSP();
            con.setString(1, form.getScheduleName());
            con.setString(2, form.getNote());
            con.setString(3, form.getBeginTime());
            con.setString(4, form.getEndTime());
            con.setString(5, form.getDoRemind());
            con.setString(6, form.getRemindTime());
            con.setString(7, (String)request.getSession().getAttribute("staffno"));
            con.setString(8, staffIds);
            con.setInt(9, Initor.systemConfig.getInt("agt/calendarNotify",4));
            SysRecord res  = con.csCommonSP("p_agt_scheduleadd").getParamSet();

            if( res.getInt(0) != 0)
            {
                request.setAttribute("errorId", ErrorCode.SCHEDULE_ADD);
                return mapping.findForward("error");
            }
            else
            {
                request.setAttribute("successId",SuccessCode.SCHEDULE_ADD);
                request.setAttribute("backURL","agt/schedule/scheduleAdd.jsp?firID=M04&secNo=1&thrNo=1&secCount=10&thrCount=2");
                return mapping.findForward("success");
            }
        }
      catch (SysDbException aple)
      {
        //捕获CommonService系统异常,定向到出错页面,错误码为ErrorCode.COMMONSERVICE_ERROR
          aple.printStackTrace();
          request.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
          return (mapping.findForward("error"));
       }
      catch(java.sql.SQLException sqle)
      {
        //捕获调用aplcoms异常,定向到出错页面,错误码为ErrorCode.DATABASE_ERROR
          sqle.printStackTrace();
          request.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
          return (mapping.findForward("error"));
       }
      catch(Exception e)
      {
        //捕获未知异常,定向到出错页面,错误码为ErrorCode.UNKNOW_ERROR

          request.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
          return (mapping.findForward("error"));
       }
        finally
        {
            con.close();
        }
    }

    /**
     *
     * @param mapping
     * @param form1
     * @param request
     * @return
     */
    private ActionForward save(ActionMapping mapping,
                               ScheduleOperatorForm    form,
                               HttpServletRequest request
                               )
    {
       String staffIds = form.getStaffIds();
      if (staffIds != null)
      {
          staffIds = staffIds.replaceAll(",","#");
      }
        SysDbConn con = null;
        try
        {
            con = SysConnPool.getInstance().getAplComs();
            con.preparedSP();
            con.setString(1, form.getScheduleName());
            con.setString(2, form.getNote());
            con.setString(3, form.getBeginTime());
            con.setString(4, form.getEndTime());
            con.setString(5, form.getDoRemind());
            con.setString(6, form.getRemindTime());
            con.setString(7, staffIds);
            con.setString(8, form.getScheduleID()[0]);
            con.setInt(9, Initor.systemConfig.getInt("agt/calendarNotify",3));

            SysRecord res  = con.csCommonSP("p_agt_schedulemod").getParamSet();
            if( res.getInt(0) != 0)
            {
                request.setAttribute("errorId", ErrorCode.SCHEDULE_MOD);
                return mapping.findForward("error");
            }
            else
            {
                request.setAttribute("successId",SuccessCode.SCHEDULE_MOD);
                
                return mapping.findForward("success");
            }
        }
      catch (SysDbException aple)
      {
        //捕获CommonService系统异常,定向到出错页面,错误码为ErrorCode.COMMONSERVICE_ERROR
          aple.printStackTrace();
          request.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
          return (mapping.findForward("error"));
       }
      catch(java.sql.SQLException sqle)
      {
        //捕获调用aplcoms异常,定向到出错页面,错误码为ErrorCode.DATABASE_ERROR
          sqle.printStackTrace();
          request.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
          return (mapping.findForward("error"));
       }
      catch(Exception e)
      {
        //捕获未知异常,定向到出错页面,错误码为ErrorCode.UNKNOW_ERROR

          request.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
          return (mapping.findForward("error"));
       }
        finally
        {
          if(con != null)
          {
            con.close();
          }
        }
    }

    /**
     * 进入修改日程页面
     * @param mapping
     * @param form1
     * @param request
     * @return
     */
    private ActionForward modify(ActionMapping mapping,
                                 ScheduleOperatorForm    form,
                                 HttpServletRequest request
                                 )
    {
        SysConnPool cspool = null;
        SysDbConn con = null;
        try
        {
            cspool = SysConnPool.getInstance();
            con = cspool.getAplComs();
            getDetail(con,form,request);
        }
        catch(SysDbException e)
        {
            e.printStackTrace();
            request.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
            return mapping.findForward("error");
        }
        catch(java.sql.SQLException e)
        {
            e.printStackTrace();
            request.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
            return mapping.findForward("error");
        }
        finally
        {
            con.close();
        }
        return mapping.findForward("modify");
    }


    /**
     * 进入view页面
     * @param mapping
     * @param form
     * @param request
     * @return
     */
    private ActionForward view(ActionMapping mapping,
                                     ScheduleOperatorForm    form,
                                     HttpServletRequest request
                                     )
        {
            SysConnPool cspool = null;
            SysDbConn con = null;
            try
            {
                cspool = SysConnPool.getInstance();
                con = cspool.getAplComs();
                getDetail(con,form,request);
            }
            catch(SysDbException e)
            {
                e.printStackTrace();
                request.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
                return mapping.findForward("error");
            }
            catch(java.sql.SQLException e)
            {
                e.printStackTrace();
                request.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
                return mapping.findForward("error");
            }
            finally
            {
                con.close();
            }
            if (form.getOperatorFlag().equalsIgnoreCase(OperatorFlagCode.SCHEDULE_MYVIEW))
            {
                return mapping.findForward("myview");
            }
            else
            {
                return mapping.findForward("view");
            }
    }
    /**
     * 测试方法,最后屏蔽输出就可以
     * @param mes
     */

    private void log(String mes)
    {
        System.out.println(mes);
    }
}

⌨️ 快捷键说明

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