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