/// <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 = ""; }