温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:SpaceBuilder v1.0正式版源码
当前文件:
SpaceBuiderV10Source/BasicWebControls/Manage/News/EditNewsCategory.cs[4K,2009-6-12 11:55:08],打开代码结构图
SpaceBuiderV10Source/BasicWebControls/Manage/News/EditNewsCategory.cs[4K,2009-6-12 11:55:08],打开代码结构图1//------------------------------------------------------------------------------ 2
// <copyright company="Tunynet"> 3
// Copyright (c) Tunynet Network Technology Co., Ltd. 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 TunyNet.Web.UI; 14
using SpaceBuilder.Controls; 15
using SpaceBuilder.Utils; 16
17
namespace SpaceBuilder.Web.Manage.Controls 18
{ 19
public class EditNewsCategory : ManageBaseControl 20
{ 21
SBContext wlContext = SBContext.Current; 22
23
protected override void Authorize() 24
{ 25
if (!wlContext.User.IsContentAdministrator) 26
PermissionBase.RedirectOrExcpetion(SBExceptionType.AccessDenied); 27
} 28
29
protected override void OnInit(EventArgs e) 30
{ 31
if (SkinName == null) 32
SkinName = "Skin-EditNewsCategory.ascx"; 33
34
base.OnInit(e); 35
} 36
37
protected override void OnLoad(EventArgs e) 38
{ 39
base.OnLoad(e); 40
Header.AddTitle("编辑资讯类别", this.Context); 41
EnsureChildControls(); 42
if (!Page.IsPostBack) 43
Bind(); 44
} 45
46
Child Controls 56
57
protected override void AttachChildControls() 58
{ 59
pageTitle = FindControl("PageTitle") as Literal; 60
this.SectionDescription = this.FindControl("SectionDescription") as TextBox; 61
this.SectionName = this.FindControl("SectionName") as TextBox; 62
63
saveButton = FindControl("SaveButton") as LinkButton; 64
saveButton.Click += new EventHandler(SaveButton_Click); 65
66
cancelButton = FindControl("CancelButton") as LinkButton; 67
cancelButton.Click += new EventHandler(CancelButton_Click); 68
69
sortOrder = FindControl("SortOrder") as TextBox; 70
} 71
72
void Bind() 73
{ 74
int categoryID = wlContext.GetIntFromQueryString("CategoryID", -1); 75
Forums.Components.Forum entity = Forums.Components.Forums.GetForum(categoryID); 76
if (entity != null) 77
{ 78
this.SectionName.Text = entity.SectionName; 79
this.SectionDescription.Text = entity.Description; 80
if (sortOrder != null) 81
{ 82
sortOrder.Text = Convert.ToString(entity.SortOrder); 83
} 84
} 85
86
if (categoryID > 0) 87
{ 88
pageTitle.Text = "修改资讯类别"; 89
} 90
else 91
{ 92
pageTitle.Text = "添加资讯类别"; 93
} 94
95
} 96
97
void SaveButton_Click(object sender, EventArgs e) 98
{ 99
int categoryID = wlContext.GetIntFromQueryString("CategoryID", -1); 100
101
Forums.Components.Forum entity; 102
if (categoryID > 0) 103
{ 104
entity = Forums.Components.Forums.GetForum(categoryID); 105
if (entity != null) 106
{ 107
entity.SortOrder = Convert.ToInt32(sortOrder.Text); 108
entity.Description = this.SectionDescription.Text; 109
entity.SectionName = this.SectionName.Text; 110
} 111
112
Forums.Components.Forums.Update(entity); 113
} 114
else 115
{ 116
entity = new SpaceBuilder.Forums.Components.Forum(); 117
entity.Description = this.SectionDescription.Text; 118
entity.SectionName = this.SectionName.Text; 119
entity.SortOrder = Convert.ToInt32(sortOrder.Text); 120
entity.ParentID = 0; 121
entity.IsSearchable = true; 122
entity.IsActive = true; 123
entity.GroupID = 0; 124
entity.ForumType = SpaceBuilder.Forums.Components.ForumType.Announcement; 125
entity.CreateDate = DateTime.Now; 126
entity.ClubID = 0; 127
128
Forums.Components.Forums.Create(entity); 129
} 130
131
this.Page.Response.Redirect(ManagerUrls.Instance().NewsCategoryManage()); 132
} 133
134
void CancelButton_Click(object sender, EventArgs e) 135
{ 136
this.Page.Response.Redirect(ManagerUrls.Instance().NewsCategoryManage()); 137
} 138
139
} 140
} 141






}
}