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

📄 aadminquestionlist.java

📁 在线模拟选课系统
💻 JAVA
字号:
/*
 * This product includes software developed by the
 * Apache Software Foundation (http://www.apache.org/).
 */
package ch07.action;

import java.io.*;
import java.util.*;

import javax.servlet.*;
import javax.servlet.http.*;

import ch07.*;
import ch07.object.unit.*;
import ch07.logic.*;
import ch07.global.*;
import ch07.database.*;

/**
 * 针对管理系统问题一览的Servlet
 * @author ShenYK
 * @version 1.0
 */
public class AAdminQuestionList
{
    //到首页
    public void doFirst( Hashtable inputData, 
                          Hashtable outputData,
                          HttpSession mySession )
        throws Exception
    {
        //首页的index一定为0
        outputData.put( "pageId", CommonConst.VIEWID_ADMIN_QUESTION_LIST);
        //往值域中设置当前题目及位置信息
        outputData.put( "pageIndex", new Integer(0) );
        return;
    }
    
    //到末页
    public void doLast( Hashtable inputData, 
                          Hashtable outputData,
                          HttpSession mySession )
        throws Exception
    {
        //首先获得全部问题,并计算出最后一页的位置
        Vector allQuestions = (Vector)mySession.getAttribute("adminQuestions");
        int iMax = allQuestions.size();
        int iMaxPage = (int)Math.ceil((double)iMax/20);
        int iIndex = (iMaxPage-1)*20;
        
        //首页的index一定为0
        outputData.put( "pageId", CommonConst.VIEWID_ADMIN_QUESTION_LIST);
        //往值域中设置当前题目及位置信息
        outputData.put( "pageIndex", new Integer(iIndex) );
        return;
    }
    
    //到前页
    public void doPrev( Hashtable inputData, 
                         Hashtable outputData,
                         HttpSession mySession )
        throws Exception
    {
        //首先获得当前页
        String sCurPage = (String)inputData.get("curPage");
        int iCurPage = (new Integer(sCurPage)).intValue();
        int iIndex = (iCurPage-2)*20;
        outputData.put( "pageId", CommonConst.VIEWID_ADMIN_QUESTION_LIST);
        //往值域中设置当前题目及位置信息
        outputData.put( "pageIndex", new Integer(iIndex) );
        return;
    }
    
    //到次页
    public void doNext( Hashtable inputData, 
                         Hashtable outputData,
                         HttpSession mySession )
        throws Exception
    {
        //首先获得当前页
        String sCurPage = (String)inputData.get("curPage");
        int iCurPage = (new Integer(sCurPage)).intValue();
        int iIndex = iCurPage*20;
        outputData.put( "pageId", CommonConst.VIEWID_ADMIN_QUESTION_LIST);
        //往值域中设置当前题目及位置信息
        outputData.put( "pageIndex", new Integer(iIndex) );
        return;
    }

    //删除某条试题
    public void doDelete( Hashtable inputData, 
                           Hashtable outputData,
                           HttpSession mySession )
        throws Exception
    {
        //首先获得要删除的问题ID
        String sQuestionId = (String)inputData.get("questionId");
        //取得当前的分类ID,删除以后需要根据它重新进行检索
        String sCategoryId = (String)mySession.getAttribute("selectCategory");
        
        //调用对应的logic类
        LQuestion lQuestion = (LQuestion)GlobalObjectProvider.getLogicService(CommonConst.LOGIC_KEY_QUESTION);
        //删除对应的记录
        lQuestion.deleteQuestionById( sQuestionId );
        //然后重新检索,并定位到第一页
        Vector vQuestions = lQuestion.getAllQuestionsByCategoryId( sCategoryId );
        
        //由于需要在页面迁移中使用题库,所以放到session中
        mySession.setAttribute( "adminQuestions", vQuestions );

        outputData.put( "pageId", CommonConst.VIEWID_ADMIN_QUESTION_LIST);
        //往值域中设置当前题目及位置信息
        outputData.put( "pageIndex", new Integer(0) );
        return;
    }
    
    //修改某条试题
    public void doModify( Hashtable inputData, 
                           Hashtable outputData,
                           HttpSession mySession )
        throws Exception
    {
        //首先获得要修改的问题ID
        String sQuestionId = (String)inputData.get("questionId");
        
        //获得对应的问题的详细信息,然后迁移到详细信息修改页面
        //调用对应的logic类
        LQuestion lQuestion = (LQuestion)GlobalObjectProvider.getLogicService(CommonConst.LOGIC_KEY_QUESTION);
        //删除对应的记录
        Question questionObj = lQuestion.getQuestionById( sQuestionId );
        
        //然后迁移到指定页面
        outputData.put( "pageId", CommonConst.VIEWID_ADMIN_QUESTION_MODIFY);
        //往值域中设置当前题目及位置信息
        outputData.put( "question", questionObj );
        return;
    }
    
    //添加一条新试题
    public void doAdd( Hashtable inputData, 
                        Hashtable outputData,
                        HttpSession mySession )
        throws Exception
    {
        //不用设置任何值域,直接迁移过去即可
        outputData.put( "pageId", CommonConst.VIEWID_ADMIN_QUESTION_ADD);
        return;
    }
    
}

⌨️ 快捷键说明

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