首页->博客空间->SpaceBuilder v1.0正式版源码>>BasicWebControls/Manage/Advertising/ManageAdvertisingPositions.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:SpaceBuilder v1.0正式版源码
当前文件:
SpaceBuiderV10Source/BasicWebControls/Manage/Advertising/ManageAdvertisingPositions.cs[9K,2009-6-12 11:55:07],打开代码结构图
SpaceBuiderV10Source/BasicWebControls/Manage/Advertising/ManageAdvertisingPositions.cs[9K,2009-6-12 11:55:07],打开代码结构图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; 9
using System.Collections.Generic; 10
using System.Text; 11
using SpaceBuilder.Components; 12
using SpaceBuilder.Security; 13
using System.Web.UI.WebControls; 14
using SpaceBuilder.Configuration; 15
using TunyNet.Caching; 16
using SpaceBuilder.Controls.Utils; 17
using SpaceBuilder.Utils; 18
using SpaceBuilder.Posts.Permissions; 19
using TunyNet.Data.Utils; 20
21
namespace SpaceBuilder.Web.Manage.Controls 22
{ 23
public class ManageAdvertisingPositions : ManageBaseControl 24
{ 25
SBContext wlContext; 26
27
protected override void Authorize() 28
{ 29
if (!SBContext.Current.User.IsAdministrator) 30
PermissionBase.RedirectOrExcpetion(SBExceptionType.AccessDenied); 31
} 32
33
protected override void OnInit(EventArgs e) 34
{ 35
if (SkinName == null) 36
SkinName = "Skin-ManageAdvertisingPositions.ascx"; 37
38
wlContext = SBContext.Current; 39
40
base.OnInit(e); 41
} 42
43
protected override void OnLoad(EventArgs e) 44
{ 45
base.OnLoad(e); 46
47
if (!Page.IsPostBack) 48
{ 49
DataBind(); 50
} 51
} 52
53
public override void DataBind() 54
{ 55
base.DataBind(); 56
BindData(); 57
} 58
59
Child Controls 72
73
protected override void AttachChildControls() 74
{ 75
pageTitle = FindControl("PageTitle") as Literal; 76
77
createButton = FindControl("CreateButton") as LinkButton; 78
createButton.Click += new EventHandler(CreateButton_Click); 79
80
deleteButton = FindControl("DeleteButton") as LinkButton; 81
deleteButton.Click += new EventHandler(DeleteButton_Click); 82
deleteButton.Attributes["onclick"] = "return confirm('您确定要删除选中的广告位置吗?');"; 83
84
advertisingPositionsRepeater = FindControl("AdvertisingPositionsRepeater") as Repeater; 85
advertisingPositionsRepeater.ItemDataBound += new RepeaterItemEventHandler(AdvertisingPositionsRepeater_ItemDataBound); 86
87
pager = FindControl("Pager") as PostBackPager; 88
pager.PageIndexChanged += new PagerEventHandler(pager_PageIndexChanged); 89
} 90
91
void BindData() 92
{ 93
pageTitle.Text = "广告位置管理"; 94
95
AdvertisingPositionQuery query = new AdvertisingPositionQuery(); 96
query.PageIndex = pager.PageIndex; 97
query.PageSize = DisplayItemCount; 98
99
PagingDataSet<AdvertisingPosition> pds = AdvertisingPositions.GetAdvertisingPositions(query); 100
pager.TotalRecords = pds.TotalRecords; 101
pager.PageSize = query.PageSize; 102
103
advertisingPositionsRepeater.DataSource = pds.Records; 104
advertisingPositionsRepeater.DataBind(); 105
106
} 107
108
private void AdvertisingPositionsRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) 109
{ 110
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) 111
{ 112
AdvertisingPosition record = e.Item.DataItem as AdvertisingPosition; 113
if (record != null) 114
{ 115
CheckBox selector = e.Item.FindControl("Selector") as CheckBox; 116
if (selector != null) 117
{ 118
selector.Attributes["value"] = record.PositionCode.ToString(); 119
} 120
121
HyperLink PositionCode = e.Item.FindControl("PositionCode") as HyperLink; 122
if (PositionCode != null) 123
{ 124
PositionCode.Text = record.PositionCode.ToString(); 125
PositionCode.NavigateUrl = ManagerUrls.Instance().EditAdvertisingPosition(record.PositionCode); 126
} 127
128
HyperLink description = e.Item.FindControl("Description") as HyperLink; 129
if (description != null) 130
{ 131
description.Text = record.Description; 132
description.NavigateUrl = ManagerUrls.Instance().EditAdvertisingPosition(record.PositionCode); 133
} 134
Literal size = e.Item.FindControl("Size") as Literal; 135
if (size != null) 136
size.Text = record.Width + "*" + record.Height; 137
138
Literal allowNumber = e.Item.FindControl("AllowNumber") as Literal; 139
if (allowNumber != null) 140
allowNumber.Text = record.AllowNumber.ToString(); 141
142
Image allowSystem = e.Item.FindControl("AllowSystem") as Image; 143
if (allowSystem != null) 144
{ 145
if (record.AllowSystem) 146
{ 147
allowSystem.ImageUrl = "~/Utility/Icons/icon_true.gif"; 148
allowSystem.ToolTip = "允许"; 149
} 150
else 151
{ 152
allowSystem.ImageUrl = "~/Utility/Icons/icon_false.gif"; 153
allowSystem.ToolTip = "不允许"; 154
} 155
} 156
157
Image allowClub = e.Item.FindControl("AllowClub") as Image; 158
if (allowClub != null) 159
{ 160
if (record.AllowClub) 161
{ 162
allowClub.ImageUrl = "~/Utility/Icons/icon_true.gif"; 163
allowClub.ToolTip = "允许"; 164
} 165
else 166
{ 167
allowClub.ImageUrl = "~/Utility/Icons/icon_false.gif"; 168
allowClub.ToolTip = "不允许"; 169
} 170
} 171
172
Image allowUser = e.Item.FindControl("AllowUser") as Image; 173
if (allowUser != null) 174
{ 175
if (record.AllowUser) 176
{ 177
allowUser.ImageUrl = "~/Utility/Icons/icon_true.gif"; 178
allowUser.ToolTip = "允许"; 179
} 180
else 181
{ 182
allowUser.ImageUrl = "~/Utility/Icons/icon_false.gif"; 183
allowUser.ToolTip = "不允许"; 184
} 185
} 186
187
HyperLink editButton = e.Item.FindControl("EditButton") as HyperLink; 188
if (editButton != null) 189
{ 190
editButton.NavigateUrl = ManagerUrls.Instance().EditAdvertisingPosition(record.PositionCode); 191
} 192
193
} 194
} 195
} 196
197
198
/// <summary> 199
/// 新建 200
/// </summary> 201
protected void CreateButton_Click(Object sender, EventArgs e) 202
{ 203
string redirectUrl = ManagerUrls.Instance().EditAdvertisingPosition(0); 204
Context.Response.Redirect(redirectUrl, true); 205
} 206
207
/// <summary> 208
/// 删除 209
/// </summary> 210
protected void DeleteButton_Click(Object sender, EventArgs e) 211
{ 212
int[] items = GetSelectedIDs(); 213
if (items.Length > 0) 214
{ 215
AdvertisingPositions.DeleteAdvertisingPositions(items); 216
217
BindData(); 218
//Context.Response.Redirect(wlContext.RawUrl, true); 219
} 220
} 221
222
void pager_PageIndexChanged(object sender, PagerEventArgs e) 223
{ 224
BindData(); 225
} 226
227
protected Int32[] GetSelectedIDs() 228
{ 229
ArrayList selectedItems = new ArrayList(); 230
foreach (RepeaterItem item in this.advertisingPositionsRepeater.Items) 231
{ 232
CheckBox selector = item.FindControl("Selector") as CheckBox; 233
if (selector != null && selector.Checked) 234
{ 235
Int32 postID = Convert.ToInt32(selector.Attributes["value"]); 236
selectedItems.Add(postID); 237
} 238
} 239
Int32[] IDs = new Int32[selectedItems.Count]; 240
selectedItems.CopyTo(IDs); 241
return IDs; 242
} 243
244
245
property 255
} 256
} 257






}
}