Ejemplo n.º 1
0
    //添加填空题确认事件
    protected void btFillConfirm_Click(object sender, EventArgs e)
    {
        QuestionsManagement questionsManagement = new QuestionsManagement();
        QuestionInfo newQuestion = new QuestionInfo();

        int QuestionTypeID = Convert.ToInt32(this.ddlQuestionType.SelectedItem.Value);
        int SectionId = Convert.ToInt32(this.ddlSectionNO.SelectedItem.Value);
        if (QuestionTypeID != 0 && SectionId != 0)
        {
            //设置添加的填空题题目信息
            newQuestion.IQuestionTypeID = Convert.ToInt32(this.ddlQuestionType.SelectedItem.Value);
            newQuestion.ISectionId = Convert.ToInt32(this.ddlSectionNO.SelectedItem.Value);
            newQuestion.StrQuestionBody = this.txbFill.Text;
            newQuestion.StrAnswer = this.txbFillAnswer.Text;

            //将该题目添加到数据库
            if (questionsManagement.AddQuestion(newQuestion))
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                    "<script>alert('添加成功!')</script>");
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                    "<script>alert('添加失败!')</script>");
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                    "<script>alert('章节或题目类型为空!')</script>");
        }
    }
Ejemplo n.º 2
0
    //添加是非题确认事件
    protected void btJudgeConfirm_Click(object sender, EventArgs e)
    {
        QuestionsManagement questionsManagement = new QuestionsManagement();
        QuestionInfo newQuestion = new QuestionInfo();
        string answer = null;

        //获得是非题答案
        if (RadioButton1.Checked)
        {
            answer = "是";
        }
        if(RadioButton2.Checked)
        {
            answer = "非";
        }

        int QuestionTypeID = Convert.ToInt32(this.ddlQuestionType.SelectedItem.Value);
        int SectionId = Convert.ToInt32(this.ddlSectionNO.SelectedItem.Value);
        if (QuestionTypeID != 0 && SectionId != 0 && answer != null)
        {
            //设置添加的是非题题目信息
            newQuestion.IQuestionTypeID = QuestionTypeID;
            newQuestion.ISectionId = SectionId;
            newQuestion.StrQuestionBody = this.txbJudge.Text;
            newQuestion.StrAnswer = answer;

            //将该题目添加到数据库
            if (questionsManagement.AddQuestion(newQuestion))
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                    "<script>alert('添加成功!')</script>");
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                    "<script>alert('添加失败!')</script>");
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                    "<script>alert('章节,题目类型或题目答案为空!')</script>");
        }
    }