温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:SpaceBuilder v1.0正式版源码
当前文件:
SpaceBuiderV10Source/BasicWebControls/Manage/Event/EventSearchBlock.cs[5K,2009-6-12 11:55:07],打开代码结构图
SpaceBuiderV10Source/BasicWebControls/Manage/Event/EventSearchBlock.cs[5K,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
8
using System; 9
using System.Collections.Generic; 10
using System.Text; 11
using SpaceBuilder.Components; 12
using SpaceBuilder.Posts.Permissions; 13
using System.Web.UI.WebControls; 14
using SpaceBuilder.Controls; 15
using SpaceBuilder.Events.Controls; 16
using SpaceBuilder.Events.Components; 17
using TunyNet.Utils; 18
19
namespace SpaceBuilder.Web.Manage.Controls 20
{ 21
public class EventSearchBlock : ManageBaseControl 22
{ 23
SBContext wlContext; 24
25
protected override void Authorize() 26
{ 27
if (!(SBContext.Current.User.IsEventAdministrator)) 28
PermissionBase.RedirectOrExcpetion(SBExceptionType.AccessDenied); 29
} 30
31
protected override void OnInit(EventArgs e) 32
{ 33
if (SkinName == null) 34
SkinName = "Skin-EventSearchBlock.ascx"; 35
36
wlContext = SBContext.Current; 37
base.OnInit(e); 38
} 39
40
41
Child Controls 54
55
protected override void AttachChildControls() 56
{ 57
eventName = FindControl("EventName") as TextBox; 58
area = FindControl("Area") as AreaDropDownList; 59
eventCategory = FindControl("EventCategory") as EventCategoryDropDownList; 60
secrecyType = FindControl("SecrecyType") as DropDownList; 61
status = FindControl("Status") as DropDownList; 62
63
sortBy = FindControl("SortBy") as DropDownList; 64
sortOrder = FindControl("SortOrder") as SortOrderDropDownList; 65
66
searchButton = FindControl("SearchButton") as LinkButton; 67
searchButton.Click += new EventHandler(SearchButton_Click); 68
} 69
70
protected override void OnLoad(EventArgs e) 71
{ 72
base.OnLoad(e); 73
EnsureChildControls(); 74
if (!Page.IsPostBack) 75
{ 76
secrecyType.Items.Add(new ListItem("所有", ((int)SecrecyType.All).ToString())); 77
secrecyType.Items.Add(new ListItem("公开", ((int)SecrecyType.Public).ToString())); 78
secrecyType.Items.Add(new ListItem("私有", ((int)SecrecyType.Private).ToString())); 79
secrecyType.Items.Add(new ListItem("半公开", ((int)SecrecyType.HalfPublic).ToString())); 80
secrecyType.Items.Add(new ListItem("圈子活动", ((int)SecrecyType.Club).ToString())); 81
82
status.Items.Add(new ListItem("所有状态", ((int)EventStatus.All).ToString())); 83
status.Items.Add(new ListItem("进行中", ((int)EventStatus.Published).ToString())); 84
status.Items.Add(new ListItem("已结束", ((int)EventStatus.Finished).ToString())); 85
status.Items.Add(new ListItem("已取消", ((int)EventStatus.Canceled).ToString())); 86
87
sortBy.Items.Add(new ListItem("最后更新日期", ((int)SortEventsBy.LastUpdatedDate).ToString())); 88
sortBy.Items.Add(new ListItem("活动成员数", ((int)SortEventsBy.MemberCount).ToString())); 89
90
91
EventQuery query = new EventQuery(); 92
query.ConvertFromQueryString(); 93
eventName.Text = query.EventNameFilter; 94
95
if (!ValueHelper.IsNullOrEmpty(query.Area)) 96
area.SelectedValue = query.Area; 97
98
if (query.CategoryID > 0) 99
eventCategory.SelectedValue = query.CategoryID.ToString(); 100
101
if (query.SecrecyType != SecrecyType.All) 102
{ 103
ListItem item = secrecyType.Items.FindByValue(((int)query.SecrecyType).ToString()); 104
if (item != null) 105
item.Selected = true; 106
} 107
108
if (query.Status != EventStatus.All) 109
{ 110
ListItem item = status.Items.FindByValue(((int)query.Status).ToString()); 111
if (item != null) 112
item.Selected = true; 113
} 114
115
ListItem item2 = sortBy.Items.FindByValue(((int)query.SortBy).ToString()); 116
if (item2 != null) 117
item2.Selected = true; 118
119
sortOrder.SelectedValue = query.SortOrder; 120
} 121
} 122
123
void SearchButton_Click(object sender, EventArgs e) 124
{ 125
EventQuery query = new EventQuery(); 126
query.EventNameFilter = eventName.Text.Trim(); 127
query.Area = area.SelectedValue; 128
query.CategoryID = int.Parse(eventCategory.SelectedValue); 129
query.SecrecyType = (SecrecyType)int.Parse(secrecyType.SelectedValue); 130
query.Status = (EventStatus)int.Parse(status.SelectedValue); 131
query.SortBy = (SortEventsBy)int.Parse(sortBy.SelectedValue); 132
query.SortOrder = sortOrder.SelectedValue; 133
134
Page.Response.Redirect(ManagerUrls.Instance().EventSearchResult() + "?" + query.ConvertToQueryString(), true); 135
} 136
137
} 138
139
} 140
141






}
}