温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:SpaceBuilder v1.1源代码
当前文件:
SpaceBuider11/BasicWebControls/Manage/Club/ManageClubCategories.cs[7K,2009-6-12 11:54:33],打开代码结构图
SpaceBuider11/BasicWebControls/Manage/Club/ManageClubCategories.cs[7K,2009-6-12 11:54:33],打开代码结构图1//------------------------------------------------------------------------------ 2
// <copyright company="Tunynet"> 3
// Copyright (c) Tunynet Inc. All rights reserved. 4
// </copyright> 5
//------------------------------------------------------------------------------ 6
7
using System; 8
using System.Collections.Generic; 9
using System.Text; 10
using SpaceBuilder.Components; 11
using SpaceBuilder.Posts.Permissions; 12
using System.Web.UI.WebControls; 13
using SpaceBuilder.Controls.Utils; 14
using SpaceBuilder.Clubs.Components; 15
using TunyNet.Data.Utils; 16
using TunyNet.Utils; 17
using SpaceBuilder.Utils; 18
using System.Collections; 19
20
namespace SpaceBuilder.Web.Manage.Controls 21
{ 22
/// <summary> 23
/// 圈子类别管理 24
/// </summary> 25
public class ManageClubCategories : ManageBaseControl 26
{ 27
SBContext sbContext; 28
Int32 depth = SpaceBuilder.Clubs.Configuration.ClubDomainConfiguration.Instance().CategoryDepth; 29
30
/// <summary> 31
/// 验证权限 32
/// </summary> 33
protected override void Authorize() 34
{ 35
base.Authorize(); 36
if (!(SBContext.Current.User.IsClubAdministrator)) 37
PermissionBase.RedirectOrExcpetion(SBExceptionType.AccessDenied); 38
} 39
40
protected override void OnInit(EventArgs e) 41
{ 42
if (SkinName == null) 43
SkinName = "Clubs/Skin-ManageClubCategories.ascx"; 44
45
sbContext = SBContext.Current; 46
base.OnInit(e); 47
} 48
49
protected override void OnLoad(EventArgs e) 50
{ 51
base.OnLoad(e); 52
EnsureChildControls(); 53
RefreshJavaScript.RegisterRefresh(Page); 54
if (!Page.IsPostBack) 55
BindData(); 56
} 57
58
59
Child Controls 82
83
protected override void AttachChildControls() 84
{ 85
clubCategoryListRepeater = FindControl("ClubCategoryListRepeater") as Repeater; 86
createButton = FindControl("CreateButton") as ModalLink; 87
if (clubCategoryListRepeater != null) 88
{ 89
clubCategoryListRepeater.ItemDataBound += new RepeaterItemEventHandler(clubCategoryListRepeater_ItemDataBound); 90
clubCategoryListRepeater.ItemCommand += new RepeaterCommandEventHandler(clubCategoryListRepeater_ItemCommand); 91
} 92
} 93
94
void BindData() 95
{ 96
this.SetPageTitle("圈子类别管理"); 97
98
categories = ClubCategories.GetAllCategories(); 99
if (createButton != null) 100
{ 101
createButton.Url = ManagerUrls.Instance().AddRootClubCategory(); 102
} 103
clubCategoryListRepeater.DataSource = categories; 104
clubCategoryListRepeater.DataBind(); 105
} 106
107
108
void clubCategoryListRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) 109
{ 110
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) 111
{ 112
ClubCategory clubCategory = (ClubCategory)e.Item.DataItem; 113
if (clubCategory != null) 114
{ 115
if (clubCategory.Depth <= depth) 116
{ 117
Literal prefix = e.Item.FindControl("Prefix") as Literal; 118
if (prefix != null) 119
{ 120
prefix.Text = PrefixForDepth(clubCategory); 121
} 122
123
HyperLink clubCategoryName = e.Item.FindControl("ClubCategoryName") as HyperLink; 124
if (clubCategoryName != null) 125
{ 126
clubCategoryName.Text = clubCategory.CategoryName; 127
clubCategoryName.NavigateUrl = ChannelUrls.Instance().ClubShowCategory(clubCategory.CategoryID); 128
clubCategoryName.Target = "_blank"; 129
} 130
131
Literal clubCount = e.Item.FindControl("ClubCount") as Literal; 132
if (clubCount != null) 133
clubCount.Text = clubCategory.CumulateClubCount.ToString(); 134
ModalLink updateButton = e.Item.FindControl("UpdateButton") as ModalLink; 135
if (updateButton != null) 136
{ 137
updateButton.Url = ManagerUrls.Instance().EditClubCategory(clubCategory.CategoryID); 138
} 139
LinkButton deleteButton = e.Item.FindControl("DeleteButton") as LinkButton; 140
{ 141
deleteButton.CommandArgument = clubCategory.CategoryID.ToString(); 142
deleteButton.Attributes["onclick"] = "if(!confirm(\"确认要删除此圈子类别吗?\")) return false;"; 143
} 144
if (depth >= (clubCategory.Depth + 1)) 145
{ 146
ModalLink addChildCategory = e.Item.FindControl("AddChildCategory") as ModalLink; 147
if (addChildCategory != null) 148
{ 149
addChildCategory.Visible = true; 150
addChildCategory.Url = ManagerUrls.Instance().AddChildClubCategory(clubCategory.CategoryID); 151
} 152
} 153
} 154
else 155
{ 156
e.Item.Visible = false; 157
} 158
} 159
} 160
} 161
162
private string PrefixForDepth(ClubCategory clubCategory) 163
{ 164
string prefixString = string.Empty; 165
for (int i = 1; i < clubCategory.Depth; i++) 166
{ 167
prefixString += " "; 168
} 169
return prefixString ; 170
} 171
172
173
void clubCategoryListRepeater_ItemCommand(object source, RepeaterCommandEventArgs e) 174
{ 175
switch (e.CommandName) 176
{ 177
case "Delete": 178
int clubCategoryID = Convert.ToInt32(e.CommandArgument); 179
if (DeleteClubCategoryStatus.ExistsClub == ClubCategories.Delete(clubCategoryID)) 180
{ 181
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), this.GetType().FullName, "alert('您必须删除该类别下的所有圈子才能删除此类别!');", true); 182
} 183
//else 184
//{ 185
// sbContext.Context.Response.Redirect(ManagerUrls.Instance().ManageClubCategories()); 186
//} 187
BindData(); 188
break; 189
} 190
} 191
192
193
property 196
} 197
} 198






}