Asp.net源码专业站
首页->博客空间->SpaceBuilder v1.1源代码>>BasicWebControls/Manage/Club/EditClubCategory.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:SpaceBuilder v1.1源代码
当前文件:文件类型 SpaceBuider11/BasicWebControls/Manage/Club/EditClubCategory.cs[5K,2009-6-12 11:54:33]打开代码结构图
普通视图
		            
1//------------------------------------------------------------------------------ 2// <copyright company="Tunynet"> 3// Copyright (c) Tunynet Inc. All rights reserved. 4// </copyright> 5//------------------------------------------------------------------------------ 6 7using System; 8using System.Collections.Generic; 9using System.Text; 10using SpaceBuilder.Components; 11using SpaceBuilder.Posts.Permissions; 12using System.Web.UI.WebControls; 13using SpaceBuilder.Controls.Utils; 14using SpaceBuilder.Clubs.Components; 15using TunyNet.Data.Utils; 16using TunyNet.Utils; 17using SpaceBuilder.Utils; 18using System.Collections; 19using TunyNet.Web.UI; 20using System.Web.UI.HtmlControls; 21 22namespace SpaceBuilder.Web.Manage.Controls 23{ 24 /// <summary> 25 /// 编辑圈子类别 26 /// </summary> 27 public class EditClubCategory : ManageBaseControl 28 { 29 SBContext wlContext; 30 int parentID = -1; 31 int categoryID = -1; 32 33 /// <summary> 34 /// 验证权限 35 /// </summary> 36 protected override void Authorize() 37 { 38 base.Authorize(); 39 if (!(SBContext.Current.User.IsClubAdministrator)) 40 PermissionBase.RedirectOrExcpetion(SBExceptionType.AccessDenied); 41 } 42 43 protected override void OnInit(EventArgs e) 44 { 45 if (SkinName == null) 46 SkinName = "Clubs/Skin-EditClubCategory.ascx"; 47 48 wlContext = SBContext.Current; 49 base.OnInit(e); 50 } 51 52 protected override void OnLoad(EventArgs e) 53 { 54 base.OnLoad(e); 55 EnsureChildControls(); 56 parentID = wlContext.GetIntFromQueryString("ParentID", -1); 57 categoryID = wlContext.GetIntFromQueryString("CategoryID", -1); 58 if (!Page.IsPostBack) 59 BindData(); 60 } 61 62 63 Child Controls 87 88 protected override void AttachChildControls() 89 { 90 parentName = FindControl("ParentName") as Literal; 91 categoryName = FindControl("CategoryName") as TextBox; 92 saveButton = FindControl("SaveButton") as LinkButton; 93 parentCategoryTr = FindControl("ParentCategoryTr") as HtmlTableRow; 94 saveButton.Click += new EventHandler(saveButton_Click); 95 cancelButton = FindControl("CancelButton") as LinkButton; 96 cancelButton.Click += new EventHandler(cancelButton_Click); 97 } 98 99 100 101 void BindData() 102 { 103 string stringPageTitle = string.Empty; 104 if (parentID > 0) 105 { 106 stringPageTitle = "创建子类别"; 107 ClubCategory parentCategory = ClubCategories.GetCategory(parentID); 108 if (parentCategory != null) 109 { 110 if (parentName != null) 111 { 112 parentName.Text = parentCategory.CategoryName; 113 } 114 } 115 } 116 else if (categoryID > 0) 117 { 118 stringPageTitle = "更新类别"; 119 ClubCategory category = ClubCategories.GetCategory(categoryID); 120 if (category != null) 121 { 122 if (category.ParentID > 0) 123 { 124 ClubCategory parent = ClubCategories.GetCategory(category.ParentID); 125 if (parent != null) 126 { 127 parentName.Text = parent.CategoryName; 128 } 129 } 130 else 131 { 132 parentCategoryTr.Visible = false; 133 } 134 if (categoryName != null) 135 { 136 categoryName.Text = category.CategoryName; 137 } 138 } 139 140 } 141 else 142 { 143 stringPageTitle = "创建根类别"; 144 if (parentCategoryTr != null) 145 { 146 parentCategoryTr.Visible = false; 147 } 148 } 149 SpaceBuilder.Controls.Header.AddTitle(stringPageTitle, this.Context); 150 } 151 152 void cancelButton_Click(object sender, EventArgs e) 153 { 154 ModalHelper.ClosePage(this.Page); 155 } 156 157 void saveButton_Click(object sender, EventArgs e) 158 { 159 if (parentID > 0) 160 { 161 ClubCategory newCategory = new ClubCategory(); 162 newCategory.ParentID = parentID; 163 newCategory.CategoryName = categoryName.Text; 164 ClubCategories.Create(newCategory); 165 } 166 else if (categoryID > 0) 167 { 168 ClubCategory categoryToChange = ClubCategories.GetCategory(categoryID); 169 if (categoryToChange != null) 170 { 171 categoryToChange.CategoryName = categoryName.Text; 172 ClubCategories.Update(categoryToChange); 173 } 174 } 175 else 176 { 177 ClubCategory rootCategory = new ClubCategory(); 178 rootCategory.ParentID = 0; 179 rootCategory.CategoryName = categoryName.Text; 180 ClubCategories.Create(rootCategory); 181 } 182 ModalHelper.ClosePage(this.Page, "true"); 183 } 184 } 185} 186
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:SpaceBuilder v1.1源代码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146