Asp.net源码专业站
首页->尚未分类->无限级树形(三层开发)源码>>WebUI/Default.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:无限级树形(三层开发)源码
当前文件:文件类型 ClassTree/WebUI/Default.aspx.cs[4K,2009-6-12 11:36:01]打开代码结构图
普通视图
		            
1using System; 2using System.Configuration; 3using System.Data; 4using System.Linq; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.HtmlControls; 9using System.Web.UI.WebControls; 10using System.Web.UI.WebControls.WebParts; 11using System.Xml.Linq; 12using BLL; 13 14public partial class _Default : System.Web.UI.Page 15{ 16 protected void Page_Load(object sender, EventArgs e) 17 { 18 if (!IsPostBack) 19 { 20 BindClassName(); 21 } 22 23 } 24 protected void BindClassName() 25 { 26 BLL.ClassTree Article = new BLL.ClassTree(); 27 DataSet dset = Article.getAllClassName(); 28 this.ClassID.Items.Add(new ListItem("做为一级分类", "00")); 29 if (dset.Tables.Count>0 && dset.Tables[0].Rows.Count>0) 30 { 31 foreach (DataRowView dv in dset.Tables[0].DefaultView) 32 { 33 string path = dv.Row["path"].ToString(); 34 Array temp = path.Split(','); 35 int depath = temp.Length; 36 string valueTex = ""; 37 for (int i = 1; i < depath; i++) 38 { 39 valueTex = valueTex + "...┣━ "; 40 } 41 valueTex = valueTex + dv.Row["className"].ToString().Trim(); 42 this.ClassID.Items.Add(new ListItem(valueTex,dv.Row["id"].ToString().Trim())); 43 } 44 } 45 } 46 public bool InsertClass() 47 { 48 bool flag = false; 49 try 50 { 51 string className = this.TextBox1.Text.Trim(); 52 string ParentID = this.ClassID.SelectedValue.Trim().ToString(); 53 string sql = ""; 54 BLL.ClassTree da = new ClassTree(); 55 if (ParentID != "00") 56 { 57 58 string path = da.getParentPathByClassID(Convert.ToInt32(ParentID)) + "," + ParentID; 59 sql = "insert into classTree (classname,parentID,path)values('" + className + "'," + ParentID + ",'" + path + "')"; 60 } 61 else 62 { 63 sql = "insert into classTree (classname,parentid)values('"+className+"',"+ParentID+")"; 64 } 65 flag = da.InsertClass(sql); 66 67 } 68 catch {} 69 return flag; 70 } 71 72 protected void updateclass() 73 { 74 string className = this.ClassNameEdit.Text.Trim(); 75 int ClassIDTemp = Convert.ToInt32(this.ClassIDHid.Value); 76 BLL.ClassTree db = new BLL.ClassTree(); 77 if (db.updateClassByClassID(ClassIDTemp, className)) 78 { 79 Response.Write("<script>alert('更新成功!');window.location='default.aspx';</script>"); 80 } 81 else 82 { 83 Response.Write("<script>alert('更新失败!');</script>"); 84 } 85 } 86 protected void DelClass() 87 { 88 int id =Convert.ToInt32( this.ClassID.SelectedValue); 89 BLL.ClassTree db = new BLL.ClassTree(); 90 if (db.delClassByID(id)) 91 { 92 Response.Write("<script>alert('删除成功!');window.location='default.aspx';</script>"); 93 } 94 else 95 { 96 Response.Write("<script>alert('删除失败!');</script>"); 97 } 98 } 99 100 protected void Button1_Click(object sender, EventArgs e) 101 { 102 if (InsertClass()) 103 { 104 Response.Write("<script>alert('添加成功');window.location='default.aspx';</script>"); 105 BindClassName(); 106 } 107 else 108 { 109 Response.Write("<script>alert('添加失败');</script>"); 110 } 111 } 112 protected void Button4_Click(object sender, EventArgs e) 113 { 114 updateclass(); 115 } 116 protected void Button2_Click(object sender, EventArgs e) 117 { 118 if (this.ClassID.SelectedValue !="00") 119 { 120 this.Panel1.Visible = false; 121 this.Panel2.Visible = true; 122 this.ClassNameEdit.Text = this.ClassID.SelectedItem.Text; 123 this.ClassIDHid.Value = this.ClassID.SelectedValue; 124 } 125 } 126 protected void Button5_Click(object sender, EventArgs e) 127 { 128 DelClass(); 129 } 130} 131
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:无限级树形(三层开发)源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146