コード例 #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>");
        }
    }
コード例 #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>");
        }
    }
コード例 #3
0
    //编辑是非题确认事件
    protected void btEJudgeConfirm_Click(object sender, EventArgs e)
    {
        QuestionsManagement questionsManagement = new QuestionsManagement();
        QuestionInfo newQuestion = new QuestionInfo();
        string answer = null;

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

        if (answer != null)
        {
            //设置编辑后的是非题信息
            newQuestion.IQuestionId = Convert.ToInt32(Session["Questionid"].ToString());
            newQuestion.ISectionId = Convert.ToInt32(Session["Sectionid"].ToString());
            newQuestion.StrQuestionBody = this.txbJudge.Text;
            newQuestion.StrAnswer = answer;

            //保存结果到数据库
            if (questionsManagement.EditQuestion(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>");
        }
    }
コード例 #4
0
    //编辑填空题确认事件
    protected void btEFillConfirm_Click(object sender, EventArgs e)
    {
        QuestionsManagement questionsManagement = new QuestionsManagement();
        QuestionInfo newQuestion = new QuestionInfo();

        //设置修改后的填空题信息
        newQuestion.IQuestionId = Convert.ToInt32(Session["Questionid"].ToString());
        newQuestion.ISectionId = Convert.ToInt32(Session["Sectionid"].ToString());
        newQuestion.StrQuestionBody = this.txbFill.Text;
        newQuestion.StrAnswer = this.txbFillAnswer.Text;

        //保存结果到数据库
        if (questionsManagement.EditQuestion(newQuestion))
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                 "<script>alert('修改成功!')</script>");
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                    "<script>alert('修改失败!')</script>");
        }
    }
コード例 #5
0
    //用下拉列表绑定题目类型
    private void ddlQuestionTypeBind()
    {
        QuestionsManagement questionsManagement = new QuestionsManagement();
        DataTable myDatatable = questionsManagement.GetAllQuestionType();

        //将题目类型绑定在下拉列表中
        this.ddlQuestionType.DataSource = myDatatable.DefaultView;
        ddlQuestionType.DataTextField = "typeName";
        ddlQuestionType.DataValueField = "ID";
        this.ddlQuestionType.DataBind();
        this.ddlQuestionType.Items.Insert(0, "请选择列表项");
        this.ddlQuestionType.Items[0].Value = "0";
    }
コード例 #6
0
    //用下拉列表绑定章号
    private void ddlChapterNOBind()
    {
        QuestionsManagement questionsManagement = new QuestionsManagement();
        DataTable myDatatable = questionsManagement.GetAllChapters();

        //将章号绑定在下拉列表中
        this.ddlChapterNO.DataSource = myDatatable.DefaultView;
        ddlChapterNO.DataTextField = "ChapterNO";
        ddlChapterNO.DataValueField = "ID";
        this.ddlChapterNO.DataBind();
        this.ddlChapterNO.Items.Insert(0, "请选择列表项");
        this.ddlChapterNO.Items[0].Value = "0";
    }
コード例 #7
0
 protected void setSectionKnowledge(string selectedChapterText, string selectedSectionText)
 {
     KnowledgeCollection.Value = "";
     if (selectedChapterText != null && selectedSectionText != null && selectedSectionText != "" && selectedChapterText != "")
     {
         int SecID = new QuestionsManagement().getsectionIDbyCNOSNO(selectedChapterText, selectedSectionText, courseName); ;
         if (SecID > 0)
         {
             DataTable dt = GetData.getSectionKnowledge(SecID, courseName);
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 KnowledgeCollection.Value += dt.Rows[i]["Name"] + "##";
             }
         }
     }
 }
コード例 #8
0
 protected void setChapterKnowledge(string selectedText)
 {
     KnowledgeCollection.Value = "";
     if (selectedText != null && selectedText != "")
     {
         int ChapID = new QuestionsManagement().GetChapterIDBYChapterNO(selectedText, courseName);
         if (ChapID > 0)
         {
             DataTable dt = GetData.getChapterKnowledge(ChapID, courseName);
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 KnowledgeCollection.Value += dt.Rows[i]["Name"] + "##";
             }
         }
     }
 }
コード例 #9
0
    /// <summary>
    /// 修改节描述
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ModifySection_Click(object sender, EventArgs e)
    {
        //章节NO由dropList的值获取,页面绑定数据
        string cNO = this.DropDownList5.Text;
        string sNO = this.DropDownList6.Text;
        //输入框的值
        string checkstring=this.TextBox4.Text;
        //将空格去掉
        string dsp = checkstring.Replace(" ", "");
        //new一个QuestionsManagement对象
        QuestionsManagement editsection = new QuestionsManagement();
        // 输入的节名为空
        if ("-1" != cNO)
        {
            if ("" != sNO)
            {
                //根据章NO和节NO获取ID
                int ID = editsection.getsectionIDbyCNOSNO(cNO, sNO, courseName);
                //根据ID获取节描述
                string check = DropDownList6.SelectedItem.Text;
                //输入的节名和数据库中的节名不相同
                if (dsp != check)
                {
                    //new一个SectionInfo对象并初始化
                    SectionInfo section = new SectionInfo();
                    section.ISectionId = ID;
                    if (dsp != "")
                        section.StrDescription = dsp;
                    else
                        section.StrDescription = check;
                    //修改节
                    editsection.EditSection(section);

                    try
                    {
                        File.Move(Server.MapPath("~/Text/") + courseName + @"/ClassTeach/TeachPlan/" + DropDownList5.SelectedItem.Text + @"/" + DropDownList6.SelectedItem.Text + ".txt", Server.MapPath("~/Text/") + courseName + @"/ClassTeach/TeachPlan/" + DropDownList5.SelectedItem.Text + @"/" + checkstring + ".txt");
                    }
                    catch { }

                    /*添加知识点*/
                    ProcessKnowledge(SECTION, ID);
                    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>");
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                              "<script>alert('请选择需修改的章!')</script>");
        }

        //刷新viewtree
        TreeView1.Nodes.Clear();
        this.TreeDataBind();
        TreeView1.ShowLines = true;//显示连接父节点与子节点间的线条
        TreeView1.ExpandDepth = 1;//控件显示时所展开的层数

        for (int k = 0; k < TreeView1.Nodes[0].ChildNodes.Count; k++)
        {
            if (TreeView1.Nodes[0].ChildNodes[k].Text.Substring(TreeView1.Nodes[0].ChildNodes[k].Text.IndexOf('.') + 1) == DropDownList5.SelectedItem.Text)
            {
                TreeView1.Nodes[0].ChildNodes[k].Expand();
            }
        }

        this.DropDownList5.Text = null;
        this.DropDownList6.Text = null;
        this.TextBox4 = null;
    }
コード例 #10
0
    //页面加载时根据传过来的题目ID将相应的章号、节号和题目类型显示出来
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserName"] == null)
        {
            System.Web.HttpContext.Current.Response.Write("<script>alert('请先登录');window.location.href='../Default.aspx'</script>");
            return;
        }
        if (Session["Type"].ToString() == "Student")
        {
            System.Web.HttpContext.Current.Response.Write("<script>window.location.href='../WarningPage.aspx'</script>");
            return;
        }
        if (Session["Type"].ToString() == "Teacher" && Session["UserState"].ToString() != "Active")
        {
            System.Web.HttpContext.Current.Response.Write("<script>alert('帐号未激活,请激活后重试');window.location.href='../Activate.aspx'</script>");
            return;
        }

        if (!IsPostBack)
        {
            //数字的正则检查
            string urlPattern = @"^\d{1,}$";

            if (Request.QueryString["id"] != null)
            {
                if (Regex.IsMatch(Request.QueryString["id"], urlPattern) == true)
                {
                    int QuestionID = Convert.ToInt32(Request.QueryString["id"]);
                    if (QuestionID < 1)
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                                 "<script>alert('不存在可以编辑的题!')</script>");
                    }
                    else
                    {
                        //保存从其它页面传过来的题目ID
                        Session["Questionid"] = QuestionID.ToString();

                        QuestionsManagement questionsManagement = new QuestionsManagement();
                        DataTable myDatatable = questionsManagement.GetQuestionAllInfoByQuesID(QuestionID);

                        if (myDatatable != null && myDatatable.Rows.Count > 0)
                        {
                            foreach (DataRow dr in myDatatable.Rows)
                            {
                                this.txbChapterNO.Text = dr["chapterNO"].ToString();
                                this.txbSectionNO.Text = dr["sectionNO"].ToString();
                                this.txbQuesType.Text = dr["typeName"].ToString();
                                Session["Sectionid"] = dr["sectionID"].ToString();
                                string typeName = dr["typeName"].ToString();
                                if (typeName.Equals("选择题"))
                                {
                                    this.txbMultiple.Text = dr["quesBody"].ToString();
                                    //看选择题答案是否包含A、B、C、D
                                    string answer = dr["answer"].ToString();
                                    if (answer.IndexOf("A") >= 0)
                                    {
                                        CheckBoxA.Checked = true;
                                    }
                                    if (answer.IndexOf("B") >= 0)
                                    {
                                        CheckBoxB.Checked = true;
                                    }
                                    if (answer.IndexOf("C") >= 0)
                                    {
                                        CheckBoxC.Checked = true;
                                    }
                                    if (answer.IndexOf("D") >= 0)
                                    {
                                        CheckBoxD.Checked = true;
                                    }

                                    this.Panel1.Visible = true;

                                }
                                else if (typeName.Equals("是非题"))
                                {
                                    this.txbJudge.Text = dr["quesBody"].ToString();
                                    string answer = dr["answer"].ToString();
                                    //看是非题的答案是或非
                                    if (answer.Equals("是"))
                                    {
                                        RadioButton1.Checked = true;
                                    }
                                    else if(answer.Equals("非"))
                                    {
                                        RadioButton2.Checked = true;
                                    }

                                    this.Panel2.Visible = true;
                                }
                                else if (typeName.Equals("填空题"))
                                {
                                    this.txbFill.Text = dr["quesBody"].ToString();
                                    this.txbFillAnswer.Text = dr["answer"].ToString();

                                    this.Panel3.Visible = true;
                                }
                                else if (typeName.Equals("问答题"))
                                {
                                    this.txbQA.Text = dr["quesBody"].ToString();
                                    this.txbQAAnswer.Text = dr["answer"].ToString();

                                    this.Panel4.Visible = true;
                                }
                            }
                        }
                    }
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                           "<script>alert('不存在可以编辑的题!')</script>");
                }
            }

        }
    }
コード例 #11
0
    /// <summary>
    /// 删除节
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void deleteSection_Click(object sender, EventArgs e)
    {
        //从DropList获取章节NO
        string cNO = this.DropDownList8.Text;
        string sNO = this.DropDownList9.Text;
        //new 一个QuestionsManagement对象
        QuestionsManagement dSection = new QuestionsManagement();
        //数据库中存在选择的节
        if ("-1" != cNO)
        {
            if ("" != sNO)
            {
                //根据cNO和sNO获取记录
                bool row = dSection.GetRowByChapterNOAndSectionNo(cNO, sNO, courseName);
                if (true == row)
                {
                    //获取节ID
                    int ID = dSection.getsectionIDbyCNOSNO(cNO, sNO, courseName);
                    //删除节
                    if (dSection.DeleteSection(ID, Server.MapPath("~/")))
                    {
                        try
                        {
                            File.Delete(Server.MapPath("~/Text/") + courseName + @"/ClassTeach/TeachPlan/" + DropDownList8.SelectedItem.Text + @"/" + DropDownList9.SelectedItem.Text + ".txt");
                            Command.Knowledge.saveKnowledge(SECTION, ID, null, courseName);
                        }
                        catch { }
                        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>");
                }
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                              "<script>alert('请选择要删去的节!')</script>");
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                              "<script>alert('请选择要删去的章!')</script>");
        }
        //刷新viewtree
        TreeView1.Nodes.Clear();
        this.TreeDataBind();
        TreeView1.ShowLines = true;//显示连接父节点与子节点间的线条
        TreeView1.ExpandDepth = 1;//控件显示时所展开的层数

        for (int k = 0; k < TreeView1.Nodes[0].ChildNodes.Count; k++)
        {
            if (TreeView1.Nodes[0].ChildNodes[k].Text.Substring(TreeView1.Nodes[0].ChildNodes[k].Text.IndexOf('.') + 1) == DropDownList8.SelectedItem.Text)
            {
                TreeView1.Nodes[0].ChildNodes[k].Expand();
            }
        }

        this.DropDownList8.Text = null;
        this.DropDownList9.Text = null;
    }
コード例 #12
0
    /// <summary>
    /// 删除章
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void deleteChapter_Click(object sender, EventArgs e)
    {
        //获取章NO
        string cNO = this.DropDownList7.Text;
        //new一个QuestionsManagement对象
        QuestionsManagement dChapter = new QuestionsManagement();
        //dChapter.DeleteChapter(2);
        int ID = dChapter.GetChapterIDBYChapterNO(cNO, courseName);
        bool row = dChapter.GetRowChapterNO(cNO, courseName);
        //如果数据库中存在选择的章,则删除
        if (true == row)
        {
            dChapter.DeleteChapter(ID, Server.MapPath("~/"));
            //根据选择的章NO查找改章
            bool row2 = dChapter.GetRowChapterNO(cNO, courseName);
            //删除后查找不到
            if (false == row2)
            {
                try
                {
                    Directory.Delete(Server.MapPath("~/Text/") + courseName + @"/ClassTeach/TeachPlan/" + DropDownList7.SelectedItem.Text, true);
                    Command.Knowledge.saveKnowledge(CHAPTER, ID, null, courseName);
                }
                catch { }
                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>");
        }

        //刷新viewtree
        TreeView1.Nodes.Clear();
        this.TreeDataBind();
        TreeView1.ShowLines = true;//显示连接父节点与子节点间的线条
        TreeView1.ExpandDepth = 1;//控件显示时所展开的层数
        this.DropDownList7.Text = null;

        DropDownList2.Items.Clear();
        DropDownList4.Items.Clear();
        DropDownList5.Items.Clear();
        DropDownList7.Items.Clear();
        DropDownList8.Items.Clear();
        DropDownList2.DataBind();
        DropDownList4.DataBind();
        DropDownList5.DataBind();
        DropDownList7.DataBind();
        DropDownList8.DataBind();
    }
コード例 #13
0
    /// <summary>
    /// 添加节
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void AddSection_Click(object sender, EventArgs e)
    {
        //n = 1;
        //章节的相关信息
        string chapterNO=this.DropDownList2.Text;
        string sectionNO=this.DropDownList3.Text;
        string sdp=this.TextBox2.Text;
        string sectiondscrip = sdp.Replace(" ", "");
        //new一个QuestionsManagement对象
        QuestionsManagement addsection = new QuestionsManagement();
        //根据章节NO查找数据库中的章
        bool row = addsection.GetRowByChapterNOAndSectionNo(chapterNO, sectionNO, courseName);
        //根据章NO获取章ID
        int i = addsection.GetChapterIDBYChapterNO(chapterNO, courseName);
        //new一个SectionInfo对象并初始化
        SectionInfo section = new SectionInfo();
        section.IChapterId = i;
        section.StrSectionNO = sectionNO;
        section.StrDescription = sectiondscrip;

        //章序号不为空
        if ("-1" != chapterNO)
        {
            if ("-1" != sectionNO)
            {
                //数据库中不存在相同的章节NO
                if (false == row)
                {
                    //节描述不为空
                    if ("" != sectiondscrip)
                    {
                        //此处检查是有存在相同的节名,如果存在则不允许该节名的添加,因为不能让不同序号的节有相同的节名
                        //个人理解是这样子的,如果不做此处理那么整本书的所哟章所有节将可能出现相同节名的情况
                        //需求没有明确提到是否应该存在相同节名这一情况,所以存在不确定情况
                        bool repeat1 = addsection.GetSectionBydescriptions(sectiondscrip, i);
                        //  数据库中不存在相同的节的描述
                        if (false == repeat1)
                        {
                            addsection.AddSection(section);
                            int ID = addsection.getsectionIDbyCNOSNO(chapterNO, sectionNO, courseName);
                            //数据库中存在刚刚添加的节
                            if (ID > 0)
                            {
                                File.CreateText(Server.MapPath("~/Text/") + courseName + @"/ClassTeach/TeachPlan/" + DropDownList2.SelectedItem.Text + @"/" + sectiondscrip + ".txt");

                                /*添加知识点*/
                                ProcessKnowledge(SECTION, ID);

                                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>");
                        }
                    }
                    //节名为空
                    else
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                           "<script>alert('节名为空,请重新添加!')</script>");
                    }
                }
                //数据库中存在节NO
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                          "<script>alert('该节已经存在无需添加!')</script>");

                }
            }
            //节NO为空
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                          "<script>alert('请选择节!')</script>");
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                      "<script>alert('请选择章!')</script>");
        }

          //刷新树
        //该函数先去掉树的nodes
        TreeView1.Nodes.Clear();
        this.TreeDataBind();
        TreeView1.ShowLines = true;//显示连接父节点与子节点间的线条
        TreeView1.ExpandDepth = 1;//控件显示时所展开的层数

        for (int k = 0; k < TreeView1.Nodes[0].ChildNodes.Count; k++)
        {
            if (TreeView1.Nodes[0].ChildNodes[k].Text.Substring(TreeView1.Nodes[0].ChildNodes[k].Text.IndexOf('.')+1) == DropDownList2.SelectedItem.Text)
            {
                TreeView1.Nodes[0].ChildNodes[k].Expand();
            }
        }

        this.DropDownList2.Text = null;
        this.DropDownList3.Text = null;
        this.TextBox2.Text = null;
        KnowledgeCollection.Value = "";
    }
コード例 #14
0
    /// <summary>
    /// 添加章
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void AddChapter_Click(object sender, EventArgs e)
    {
        //n = 0;

        QuestionsManagement addchapter = new QuestionsManagement();

        //得到章NO
        bool row = addchapter.GetRowChapterNO(this.DropDownList1.Text, courseName);
        string cNO = this.DropDownList1.Text;
        string ds = this.TextBox1.Text;
        string cds = ds.Replace(" ","");
        ChapterInfo chapter = new ChapterInfo();
        chapter.StrChapterNO = cNO;
        chapter.StrDescription = cds;
        //章的描述不为空
        if ("" != cds)
        {
                //章序号不为-1
                if ("-1" != cNO)
                {
                    //要添加的章NO在数据库中不存在
                    if (false == row)
                    {
                        bool repeat1 = addchapter.GetChapterbyDescriptions(cds, courseName);
                        //章表中不存在要添加章的描述
                        if (false == repeat1)
                        {
                            addchapter.AddChapter(chapter, courseName);
                            int i = addchapter.GetChapterIDBYChapterNO(cNO, courseName);
                            //数据库中存在添加的章,则成功添加
                            if (i > 0)
                            {
                                Directory.CreateDirectory(Server.MapPath("~/Text/") + courseName + @"/ClassTeach/TeachPlan/" + cds);
                                File.CreateText(Server.MapPath("~/Text/") + courseName + @"/ClassTeach/TeachPlan/" + cds + @"/StructGraph.txt");
                                File.CreateText(Server.MapPath("~/Text/") + courseName + @"/ClassTeach/TeachPlan/" + cds + @"/Summary.txt");

                                /*添加知识点*/
                                ProcessKnowledge(CHAPTER, i);

                                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>");
                        }
                    }
                    //该章NO在章表中已经存在
                    else
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                           "<script>alert('该章已经存在无需添加!')</script>");
                    }
                }
                //选择的章NO为空
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                          "<script>alert('请选择章!')</script>");

                }
            }
            //章的标题描述为空
        else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                         "<script>alert('章标题为空,请添加章标题!')</script>");

            }
        //刷新viewtree
            TreeView1.Nodes.Clear();
            this.TreeDataBind();
            TreeView1.ShowLines = true;//显示连接父节点与子节点间的线条
            TreeView1.ExpandDepth = 1;//控件显示时所展开的层数
            this.DropDownList1.Text = null;
            this.TextBox1.Text = null;

            DropDownList2.Items.Clear();
            DropDownList4.Items.Clear();
            DropDownList5.Items.Clear();
            DropDownList7.Items.Clear();
            DropDownList8.Items.Clear();
            DropDownList2.DataBind();
            DropDownList4.DataBind();
            DropDownList5.DataBind();
            DropDownList7.DataBind();
            DropDownList8.DataBind();

            KnowledgeCollection.Value = "";
    }
コード例 #15
0
    //用下拉列表绑定节号
    private void ddlSectionNOBind()
    {
        if (Convert.ToInt32(this.ddlChapterNO.SelectedItem.Value) != 0)
        {
            QuestionsManagement questionsManagement = new QuestionsManagement();
            int chapterID = Convert.ToInt32(this.ddlChapterNO.SelectedItem.Value);
            DataTable myDatatable = questionsManagement.GetAllSectionsByChapter(chapterID);

            //将节号绑定在下拉列表中
            this.ddlSectionNO.DataSource = myDatatable.DefaultView;
            ddlSectionNO.DataTextField = "sectionNO";
            ddlSectionNO.DataValueField = "ID";
            this.ddlSectionNO.DataBind();
        }
        else
        {
            this.ddlSectionNO.Items.Clear();
        }
    }
コード例 #16
0
    /// <summary>
    ///  修改章描述
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ModifyChapter_Click(object sender, EventArgs e)
    {
        //章NO在前台控件中绑定
        string chapterNO = this.DropDownList4.Text;
        string cdsp=this.TextBox3.Text;
        string chapterdscrip = cdsp.Replace(" ", "");
        //new一个QuestionsManagement对象
        QuestionsManagement editchapter = new QuestionsManagement();
        if ("-1" != chapterNO && "" != chapterNO)
        {
            //根据章NO获得章ID
            int i = editchapter.GetChapterIDBYChapterNO(chapterNO, courseName);
            //根据章NO获得章名
            string check = DropDownList4.SelectedItem.Text;
            //输入框中章名和数据库中章名不同
            if (check != chapterdscrip)
            {
                //new一个ChapterInfo并初始化
                ChapterInfo chapter = new ChapterInfo();
                chapter.IChapterId = i;
                //输入框中章名不为空
                if ("" == chapterdscrip)
                    chapter.StrDescription = check;
                else
                    chapter.StrDescription = chapterdscrip;
                //编辑章
                editchapter.EditChapter(chapter);

                try
                {
                    Directory.Move(Server.MapPath("~/Text/") + courseName + @"/ClassTeach/TeachPlan/" + DropDownList4.SelectedItem.Text, Server.MapPath("~/Text/") + courseName + @"/ClassTeach/TeachPlan/" + chapterdscrip);
                }
                catch { }

                /*添加知识点*/
                ProcessKnowledge(CHAPTER, i);
                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>");
        }
        //刷新viewtree
        TreeView1.Nodes.Clear();
        this.TreeDataBind();
        TreeView1.ShowLines = true;//显示连接父节点与子节点间的线条
        TreeView1.ExpandDepth = 1;//控件显示时所展开的层数
        this.DropDownList4.Text = null;
        this.TextBox3.Text = null;

        DropDownList2.Items.Clear();
        DropDownList4.Items.Clear();
        DropDownList5.Items.Clear();
        DropDownList7.Items.Clear();
        DropDownList8.Items.Clear();
        DropDownList2.DataBind();
        DropDownList4.DataBind();
        DropDownList5.DataBind();
        DropDownList7.DataBind();
        DropDownList8.DataBind();
    }
コード例 #17
0
    //编辑选择题确认事件
    protected void btEMultipleConfirm_Click(object sender, EventArgs e)
    {
        QuestionsManagement questionsManagement = new QuestionsManagement();
        QuestionInfo newQuestion = new QuestionInfo();
        string answer = null;

        //获得选择题答案
        if (CheckBoxA.Checked)
        {
            answer += "A";
        }
        if (CheckBoxB.Checked)
        {
            answer += "B";
        }
        if (CheckBoxC.Checked)
        {
            answer += "C";
        }
        if (CheckBoxD.Checked)
        {
            answer += "D";
        }

        if (answer != null)
        {
            //设置编辑后的选择题信息
            newQuestion.IQuestionId = Convert.ToInt32(Session["Questionid"].ToString());
            newQuestion.ISectionId = Convert.ToInt32(Session["Sectionid"].ToString());
            newQuestion.StrQuestionBody = this.txbMultiple.Text;
            newQuestion.StrAnswer = answer;

            //保存结果到数据库
            if (questionsManagement.EditQuestion(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>");
        }
    }