examaction.java

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

JAVA
1,685
字号
       //查询的状态
       int state = 0;

       //定义连接的实例
       SysDbConn aplcoms = null;
       try
       {
           //得到一个连接的实例
           aplcoms = SysConnPool.getInstance().getAplComs();

           if(opeType.equalsIgnoreCase(OperatorFlagCode.EXAM_QUERY_DRAFT))
           {
               //设置查询条件中状态值为0;
               state = 0;
           }
           else if(opeType.equalsIgnoreCase(OperatorFlagCode.EXAM_QUERY_CHECK))
           {
               //设置查询条件中状态值为1;
                state = 1;
           }
           else
           {
               //设置查询条件中状态值为2;
               state = 3;
           }

            //根据查询条件,从数据库中获取试卷记录
            aplcoms.preparedSP();

            aplcoms.setInt(1,state);
            aplcoms.setString(2,staffNo);
            SysResultSet rs1 = aplcoms.csCommonSP("P_Agt_ExamOpeBoxQuery").getResultSet();
            rs1.next();
            aplcoms.preparedQuery(rs1.getString(1));

            SysResultSet rs2 = aplcoms.csCommonQuery("SELFSQL","1","-1").getResultSet();

            //定向到列表显示页面
            if(opeType.equalsIgnoreCase(OperatorFlagCode.EXAM_QUERY_DRAFT))
            {   //把结果集存放到session中
                req.getSession().setAttribute("EXAM-QUERY-DRAFTLIST",rs2);
                return (mapping.findForward("draftlist"));
            }
            else if(opeType.equalsIgnoreCase(OperatorFlagCode.EXAM_QUERY_CHECK))
            {   //把结果集存放到session中

                req.getSession().setAttribute("EXAM-QUERY-CHECKLIST",rs2);
                return (mapping.findForward("checklist"));
            }
            else
            {   //把结果集存放到session中
                req.getSession().setAttribute("EXAM-QUERY-APPROVELIST",rs2);
                return (mapping.findForward("approvelist"));
            }
       }
       catch (SysDbException aple)
       {//捕获CommonService系统异常,定向到出错页面
           //输出异常信息
           aple.printStackTrace();
           req.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
           return (mapping.findForward("error"));
       }
       catch(java.sql.SQLException sqle)
       {//捕获调用aplcoms异常,定向到出错页面
           // 输出异常信息
           sqle.printStackTrace();
           req.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
           return (mapping.findForward("error"));
       }
       catch(Exception e)
       {//捕获未知异常,定向到出错页面
           //输出异常信息
           e.printStackTrace();
           req.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
           return (mapping.findForward("error"));
       }
       finally
       {//关闭连接实例
           if(aplcoms != null)
           {
              aplcoms.close();
           }
       }
    }

    /**
     * 修改考试安排操作
     */
    private ActionForward modifyExam(ActionMapping mapping,
           ActionForm form, HttpServletRequest req,
           HttpServletResponse res)
    {
       //从ExamFrom中获取数据
       String title = ((ExamForm)form).getTitle();
       String subject = ((ExamForm)form).getSubject();
       String paperId = ((ExamForm)form).getPaperId();
       String cityId = ((ExamForm)form).getCityId();
       String classId = ((ExamForm)form).getClassId();
       int examTime = ((ExamForm)form).getExamTime();
       int maxCount = ((ExamForm)form).getMaxCount();
       int passScore = ((ExamForm)form).getPassScore();
       String teacherId = ((ExamForm)form).getTeacherId();
       String startTime = ((ExamForm)form).getStartTime();
       String endTime = ((ExamForm)form).getEndTime();
       int scope = ((ExamForm)form).getScope();
       String examId = ((ExamForm)form).getExamId();
       int state = ((ExamForm)form).getState();
       String checkHander = ((ExamForm)form).getCheckHandler();
       String staffIds = ((ExamForm)form).getStaffIds();
       String groupIds= ((ExamForm)form).getGroupIds();
       int publicResult = ((ExamForm)form).getPublicResult();

       //定义连接的实例
       SysDbConn aplcoms = null;
       try
       {
           //得到一个连接的实例
           aplcoms = SysConnPool.getInstance().getAplComs();

           //调用存储过程P_Agt_ExamMod完成考试安排的修改
           aplcoms.preparedSP();

           aplcoms.setString(1 ,title);
           aplcoms.setString(2 ,subject);
           aplcoms.setString(3 ,paperId);
           aplcoms.setString(4 ,cityId);
           aplcoms.setString(5 ,classId);
           aplcoms.setInt(6 ,examTime);
           aplcoms.setInt(7 ,maxCount);
           aplcoms.setInt(8 ,passScore);
           aplcoms.setString(9 ,teacherId);
           aplcoms.setString(10 ,startTime);
           aplcoms.setString(11 ,endTime);
           aplcoms.setInt(12 ,scope);
           aplcoms.setString(13 ,examId);
           aplcoms.setInt(14 ,state);
           aplcoms.setString(15 ,checkHander);
           aplcoms.setString(16 ,staffIds);
           aplcoms.setString(17 ,groupIds);
           aplcoms.setInt(18 ,publicResult);

           SysDataSet ds = aplcoms.csCommonSP("P_Agt_ExamMod");
           SysRecord rc = ds.getParamSet() ;
           if(rc==null || rc.getInt(0) == OperatorFlagCode.OPERATOR_EORROR)
           {//修改考试安排失败
               //定向到错误页面,错误号为EXAM_MOD_ERROR;
               req.setAttribute("errorId",ErrorCode.EXAM_MOD_ERROR);
               return (mapping.findForward("error"));
           }

           //修改考试安排成功
           //调用getOpeBoxList函数进行重新查询后返回到草稿箱列表页面
           ((ExamForm)form).setOpeType(OperatorFlagCode.EXAM_QUERY_DRAFT);
           return getOpeBoxList(mapping,form,req,res);
       }
       catch (SysDbException aple)
       {//捕获CommonService系统异常,定向到出错页面
           //输出异常信息
           aple.printStackTrace();
           req.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
           return (mapping.findForward("error"));
       }
       catch(java.sql.SQLException sqle)
       {//捕获调用aplcoms异常,定向到出错页面
           // 输出异常信息
           sqle.printStackTrace();
           req.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
           return (mapping.findForward("error"));
       }
       catch(Exception e)
       {//捕获未知异常,定向到出错页面
           //输出异常信息
           e.printStackTrace();
           req.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
           return (mapping.findForward("error"));
       }
       finally
       {//关闭连接实例
           if(aplcoms != null)
           {
              aplcoms.close();
           }
       }
    }


   /**
     * 修改考试安排操作
     */
    private ActionForward modifyExamByClass(ActionMapping mapping,
           ActionForm form, HttpServletRequest req,
           HttpServletResponse res)
    {
      //从ExamFrom中获取数据
       String title = ((ExamForm)form).getTitle();
       String subject = ((ExamForm)form).getSubject();
       String cityId = ((ExamForm)form).getCityId();
       String classId = ((ExamForm)form).getClassId();
       int examTime = ((ExamForm)form).getExamTime();
       int maxCount = ((ExamForm)form).getMaxCount();
       int passScore = ((ExamForm)form).getPassScore();
       String teacherId = ((ExamForm)form).getTeacherId();
       String startTime = ((ExamForm)form).getStartTime();
       String endTime = ((ExamForm)form).getEndTime();
       int state = ((ExamForm)form).getState();
       String checkHander = ((ExamForm)form).getCheckHandler();
       int publicResult = ((ExamForm)form).getPublicResult();
       String examClassId = req.getParameter("examClassId");
       String paperId1 = req.getParameter("paperId1");
       String paperId2 = req.getParameter("paperId2");
       String paperId3 = req.getParameter("paperId3");
       String paperId4 = req.getParameter("paperId4");
       String examId = ((ExamForm)form).getExamId();
       //定义连接的实例
       SysDbConn aplcoms = null;
       try
       {
           //得到一个连接的实例
           aplcoms = SysConnPool.getInstance().getAplComs();

           //调用存储过程P_Agt_ExamMod完成考试安排的修改
           aplcoms.preparedSP();

           aplcoms.setString(1 ,title);
           aplcoms.setString(2 ,subject);
           aplcoms.setString(3 ,cityId);
           aplcoms.setString(4 ,classId);
           aplcoms.setInt(5 ,examTime);
           aplcoms.setInt(6 ,maxCount);
           aplcoms.setInt(7 ,passScore);
           aplcoms.setString(8 ,teacherId);
           aplcoms.setString(9 ,startTime);
           aplcoms.setString(10 ,endTime);
           aplcoms.setInt(11 ,3);
           aplcoms.setString(12 ,examId);
           aplcoms.setInt(13 ,state);
           aplcoms.setString(14 ,checkHander);
           aplcoms.setInt(15 ,publicResult);
           aplcoms.setString(16 ,examClassId);
           aplcoms.setString(17 ,paperId1);
           aplcoms.setString(18 ,paperId2);
           aplcoms.setString(19 ,paperId3);
           aplcoms.setString(20 ,paperId4);

           SysDataSet ds = aplcoms.csCommonSP("P_Agt_ExamModByClass");
           SysRecord rc = ds.getParamSet();
           if(rc==null || rc.getInt(0) == OperatorFlagCode.OPERATOR_EORROR)
           {//修改考试安排失败
               //定向到错误页面,错误号为EXAM_MOD_ERROR;
               req.setAttribute("errorId",ErrorCode.EXAM_MOD_ERROR);
               return (mapping.findForward("error"));
           }

           //修改考试安排成功
           //调用getOpeBoxList函数进行重新查询后返回到草稿箱列表页面
           ((ExamForm)form).setOpeType(OperatorFlagCode.EXAM_QUERY_DRAFT);
           return getOpeBoxList(mapping,form,req,res);
       }
       catch (SysDbException aple)
       {//捕获CommonService系统异常,定向到出错页面
           //输出异常信息
           aple.printStackTrace();
           req.setAttribute("errorId",ErrorCode.COMMONSERVICE_ERROR);
           return (mapping.findForward("error"));
       }
       catch(java.sql.SQLException sqle)
       {//捕获调用aplcoms异常,定向到出错页面
           // 输出异常信息
           sqle.printStackTrace();
           req.setAttribute("errorId",ErrorCode.DATABASE_ERROR);
           return (mapping.findForward("error"));
       }
       catch(Exception e)
       {//捕获未知异常,定向到出错页面
           //输出异常信息
           e.printStackTrace();
           req.setAttribute("errorId",ErrorCode.UNKNOW_ERROR);
           return (mapping.findForward("error"));
       }
       finally
       {//关闭连接实例
           if(aplcoms != null)
           {
              aplcoms.close();
           }
       }
    }


    /**
     * 删除考试安排操作
     */
    private ActionForward deleteExam(ActionMapping mapping,
           ActionForm form, HttpServletRequest req,
           HttpServletResponse res)
    {

       //从ExamForm中获取考试安排ID号
       String[] examIds = ((ExamForm)form).getExamIds();

       //以"#"号组合所要删除的考试安排,之间以"#"号分割
       String examIdSet = Tools.getStringSet(examIds);

       //定义连接的实例
       SysDbConn aplcoms = null;
       try
       {
           //得到一个连接的实例
           aplcoms = SysConnPool.getInstance().getAplComs();

           //调用存储过程 P_Agt_ExamDel完成考试安排的删除
           aplcoms.preparedSP();
           aplcoms.setString(1 ,examIdSet);
           SysDataSet ds1 = aplcoms.csCommonSP("P_Agt_ExamDel");
           SysRecord rc1 = ds1.getParamSet() ;
           if(rc1==null || rc1.getInt(0) == OperatorFlagCode.OPERATOR_EORROR)
           {//定向到错误页面,错误号为EXAM_DELETE_ERROR;
               req.setAttribute("errorId",ErrorCode.EXAM_DELETE_ERROR);
               return (mapping.findForward("error"));
           }

           //删除考试部分失败
           if(rc1.getString(1) != null && rc1.getString(1).length()>10)
           {
                req.setAttribute("errorId",ErrorCode.EXAM_PARTDELERROR);
                req.setAttribute("errorMes",rc1.getString(1));
                return (mapping.findForward("error"));
           }

           if("1".equalsIgnoreCase(req.getParameter("byQListDel")))
           {
              //调用queryExam函数进行重新查询后返回到列表页面
              return queryExam(mapping,form,req,res);
           }

           //调用getOpeBoxList函数进行重新查询后返回到草稿箱列表页面
           ((ExamForm)form).setOpeType(OperatorFlagCode.EXAM_QUERY_DRAFT);

⌨️ 快捷键说明

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