Ejemplo n.º 1
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();
    }
Ejemplo n.º 2
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 = "";
    }
Ejemplo n.º 3
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();
    }
Ejemplo n.º 4
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 = "";
    }