分类管理模块-修改新闻分类(简单版本)
2012-06-08 22:33
309 查看
设计界面如下:
HTML代码如下:
CS代码如下:
BLL类:
DAL类:
HTML代码如下:
<body> <form id="form1" runat="server"> <div> <table cellpadding="0" cellspacing="0" style="width: 100%"> <tr> <td style="width: 211px"> 修改新闻分类</td> <td colspan="2"> </td> </tr> <tr> <td rowspan="5" style="width: 211px"> <asp:TreeView ID="TreeView1" runat="server" ImageSet="Arrows" onselectednodechanged="TreeView1_SelectedNodeChanged"> <ParentNodeStyle Font-Bold="False" /> <HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" /> <SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px" VerticalPadding="0px" /> <NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black" HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" /> </asp:TreeView> </td> <td colspan="2" style="text-align: center"> <asp:Label ID="lblMessage" runat="server"></asp:Label> </td> </tr> <tr> <td style="width: 166px; text-align: center"> ID</td> <td> <asp:TextBox ID="txtClassID" runat="server"></asp:TextBox> </td> </tr> <tr> <td style="width: 166px; text-align: center"> 分类名称:</td> <td> <asp:TextBox ID="txtClassName" runat="server"></asp:TextBox> </td> </tr> <tr> <td style="width: 166px; text-align: center"> 是否有子类:</td> <td> <asp:RadioButtonList ID="rblLastNode" runat="server" RepeatDirection="Horizontal"> <asp:ListItem Selected="True" Value="1">是</asp:ListItem> <asp:ListItem Value="0">否</asp:ListItem> </asp:RadioButtonList> </td> </tr> <tr> <td style="width: 166px; height: 117px; text-align: center"> 备注</td> <td style="height: 117px"> <asp:TextBox ID="txtExample" runat="server" Height="111px" TextMode="MultiLine" Width="241px"></asp:TextBox> </td> </tr> <tr> <td style="width: 211px"> </td> <td style="width: 166px"> </td> <td> <asp:Button ID="btnUpdate" runat="server" onclick="btnUpdate_Click" Text="提交修改" /> </td> </tr> </table> </div> </form> </body>
CS代码如下:
public partial class Admin_Admin_ClassEdit : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { this.TreeView1.Nodes.Clear(); BindTree(this.TreeView1.Nodes, 0); } private void BindTree(TreeNodeCollection treecol, int parentID) { CategoryBLL catsystem = new CategoryBLL(); List<Category> cateList = catsystem.GetClassDataID(parentID); foreach (Category cateData in cateList) { TreeNode node = new TreeNode(); node.Text = cateData.ClassName + "(" + cateData.Child + ")"; node.Value = cateData.ClassId.ToString(); treecol.Add(node); BindTree(node.ChildNodes, int.Parse(node.Value)); } } protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e) { int id = int.Parse(this.TreeView1.SelectedNode.Value); Category classdata = new Category(); classdata = (new CategoryBLL()).GetclassID(id); txtClassID.Text = classdata.ClassId.ToString(); txtClassName.Text = classdata.ClassName; txtExample.Text = classdata.Example; //rblLastNode.SelectedItem.Value = classdata.LastNode.ToString(); } protected void btnUpdate_Click(object sender, EventArgs e) { Category cateData = new Category(); cateData.ClassId = int.Parse(txtClassID.Text.Trim()); cateData.ClassName = txtClassName.Text.Trim(); cateData.LastNode = int.Parse(this.rblLastNode.SelectedValue.ToString()); cateData.Example = this.txtExample.Text.Trim(); CategoryBLL catesystem = new CategoryBLL(); catesystem.UpdateClass(cateData); this.ClientScript.RegisterStartupScript(this.GetType(), "succeed", "<script>alert('修改成功')</script>"); this.TreeView1.Nodes.Clear(); BindTree(this.TreeView1.Nodes, 0); Response.Redirect("Admin_ClassEdit.aspx"); } }
BLL类:
/// <summary> /// 更新分类信息 /// </summary> /// <param name="cateData"></param> /// <returns></returns> public bool UpdateClass(Category cateData) { CategoryDAL catesystem = new CategoryDAL(); return catesystem.Updateclass(cateData); }
DAL类:
/// <summary> /// 修改分类信息 /// </summary> /// <param name="classData"></param> /// <returns></returns> public bool Updateclass(Category classData) { DataClassesDataContext db = new DataClassesDataContext(); bool result = false; try { Category classresult = db.Category.Where(c => c.ClassId == classData.ClassId).First(); classresult.ClassName = classData.ClassName; db.SubmitChanges(); result = true; } catch { } return result; }
相关文章推荐
- 分类管理模块-新增新的新闻分类(简单版本)
- 分类管理模块-删除新闻分类(简单版本)
- 会员管理模块 - 会员修改功能(简易版本)
- DNN新闻管理模块使用指南(版本:1.01.03)
- 购物网第一阶段总结笔记7:新闻管理模块之管理新闻(修改,删除)
- 新闻管理模块(在程序中可以使用的一套完整的增添、修改、查询数据的思路)
- 会员管理模块 - 会员登录功能(简单版本)
- Maven 多模块项目的版本管理
- 希望这些建议,能推动管理软件开发的规范化进程 (数据库版本、修改记录)
- svn 版本控制简单管理
- 分享一个大一的课程设计,学校新闻系统——新闻管理模块
- Title: 搭建一个简单的GIT版本管理 Gitolite 服务器
- Java语言实现简单FTP软件------>上传下载管理模块的实现(十一)
- smarty实现简单新闻管理系统
- 利用virtualenv给管理python的多环境.(MAC亲测,简单几步即可,指定python版本)
- 创立网站管理系统,关于新闻文章内无法添加附件的修改
- 通过Maven的版本管理来管理项目公共模块
- spring 事务管理简单理解(待修改)
- 新闻模块之新闻修改-使用FreeboxText模块修改新闻数据-页面表示层(Linq方式)-1
- 使用fileinput模块进行原地修改文件 分类: python 小练习 2013-08-13 16:47 618人阅读 评论(0) 收藏