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

📄 questionpage.cs

📁 本在线考试系统采用了面向对象的分析和设计
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ExaminationSystem.BLL.Service;
using ExaminationSystem.BLL.Domain;
using ExaminationSystem.BLLException;

/// <summary>
/// QuestionPage 的摘要说明
/// </summary>
public abstract class QuestionPage:Page
{
    protected Chapter AddChapter
    {
        get
        {
            long chapterId = long.Parse(Request.QueryString["ChapterId"].ToString());
            return new ChapterService().GetById(chapterId);
        }
    }
    protected Hard AddHard
    {
        get {return  (Hard)int.Parse(Request.QueryString["hard"].ToString());}
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        string action = Request.QueryString["Action"].ToString();
        if (!IsPostBack)
        {
            switch (action)
            {
                case "Add":
                    InitAddView(AddChapter,AddHard);
                    break;
                case "Update":
                    InitUpdateView();
                    break;
                case "Delete":
                    InitDeleteView();
                    break;
                case "View":
                    InitViewView();
                    break;
            }
        }
    }
    protected abstract void InitAddView(Chapter chapter,Hard hard);
    protected abstract void InitUpdateView();
    protected abstract void InitDeleteView();
    protected abstract void InitViewView();

    public  bool AddQuestion(QuestionContent question)
    {
        question.Chapter = AddChapter;
        question.Hard = AddHard;
        try
        {
            new QuestionContentService().Save(question);
            return true;
        }
        catch
        {
            return false;
        }
    }
    protected QuestionContent GetUpdateQuestion()
    {
        long questionId = long.Parse(Request.QueryString["QuestionId"].ToString());
        return new QuestionContentService().GetById(questionId);
    }
    protected bool UpdateQuestion(QuestionContent question)
    {
        try
        {
            new QuestionContentService().Update(question);
            return true;
        }
        catch
        {
            return false;
        }
    }
    protected string  DeleteQuestion()
    {
        long questionId = long.Parse(Request.QueryString["QuestionId"].ToString());
        try
        {
            new QuestionContentService().DeleteById(questionId);
            return "删除成功!";
        }
        catch(DeleteException e)
        {
            return e.Message;
        }
    }
    protected string  GetViewQuestionHtml()
    {
        long questionId = long.Parse(Request.QueryString["QuestionId"].ToString());
        QuestionContent content=new  QuestionContentService().GetById(questionId);
        return PaperHelper.TranslateXmlToHtmlString(content.GetContentXML(), "~/XSLT/PreviewQuestion.xsl");
    }

}

⌨️ 快捷键说明

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