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