温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:SpaceBuilder v1.1源代码
当前文件:
SpaceBuider11/BasicWebControls/Manage/Club/ClubSearchBlock.cs[6K,2009-6-12 11:54:33],打开代码结构图
SpaceBuider11/BasicWebControls/Manage/Club/ClubSearchBlock.cs[6K,2009-6-12 11:54:33],打开代码结构图1//------------------------------------------------------------------------------ 2
// <copyright company="Tunynet"> 3
// Copyright (c) Tunynet Inc. 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 System.Web.UI.WebControls; 13
using SpaceBuilder.Controls; 14
using SpaceBuilder.Clubs.Controls; 15
using SpaceBuilder.Clubs.Components; 16
using TunyNet.Utils; 17
using SpaceBuilder.Posts.Permissions; 18
19
namespace SpaceBuilder.Web.Manage.Controls 20
{ 21
/// <summary> 22
/// 圈子搜索模块 23
/// </summary> 24
public class ClubSearchBlock : ManageBaseControl 25
{ 26
SBContext wlContext; 27
28
/// <summary> 29
/// 验证权限 30
/// </summary> 31
protected override void Authorize() 32
{ 33
base.Authorize(); 34
if (!(SBContext.Current.User.IsClubAdministrator)) 35
PermissionBase.RedirectOrExcpetion(SBExceptionType.AccessDenied); 36
} 37
38
protected override void OnInit(EventArgs e) 39
{ 40
if (SkinName == null) 41
SkinName = "Clubs/Skin-ClubSearchBlock.ascx"; 42
43
wlContext = SBContext.Current; 44
base.OnInit(e); 45
} 46
47
48
Child Controls 85
86
protected override void AttachChildControls() 87
{ 88
clubName = FindControl("ClubName") as TextBox; 89
//area = FindControl("Area") as AreaDropDownList; 90
//areaSelector = FindControl("AreaSelector") as AreaSelector; 91
ajaxAreaList = FindControl("AjaxAreaList") as AjaxAreaDropDownList; 92
clubCategory = FindControl("ClubCategory") as ClubCategoryDropDownList; 93
secrecyType = FindControl("SecrecyType") as DropDownList; 94
status = FindControl("Status") as DropDownList; 95
96
sortBy = FindControl("SortBy") as DropDownList; 97
sortOrder = FindControl("SortOrder") as SortOrderDropDownList; 98
99
searchButton = FindControl("SearchButton") as LinkButton; 100
searchButton.Click += new EventHandler(SearchButton_Click); 101
} 102
103
protected override void OnLoad(EventArgs e) 104
{ 105
base.OnLoad(e); 106
EnsureChildControls(); 107
if (!Page.IsPostBack) 108
{ 109
secrecyType.Items.Add(new ListItem("所有", ((int)ClubSecrecyType.All).ToString())); 110
secrecyType.Items.Add(new ListItem("公开", ((int)ClubSecrecyType.Public).ToString())); 111
secrecyType.Items.Add(new ListItem("私有", ((int)ClubSecrecyType.Private).ToString())); 112
secrecyType.Items.Add(new ListItem("半公开", ((int)ClubSecrecyType.HalfPublic).ToString())); 113
114
status.Items.Add(new ListItem("所有状态", ((int)ClubStatus.All).ToString())); 115
status.Items.Add(new ListItem("待处理", ((int)ClubStatus.Pending).ToString())); 116
status.Items.Add(new ListItem("已批准", ((int)ClubStatus.IsApproved).ToString())); 117
status.Items.Add(new ListItem("未批准", ((int)ClubStatus.NotApproved).ToString())); 118
status.Items.Add(new ListItem("封禁", ((int)ClubStatus.Banned).ToString())); 119
120
sortBy.Items.Add(new ListItem("创建日期", ((int)SortClubsBy.CreateDate).ToString())); 121
sortBy.Items.Add(new ListItem("圈子积分", ((int)SortClubsBy.Points).ToString())); 122
sortBy.Items.Add(new ListItem("成员数量", ((int)SortClubsBy.MemberCount).ToString())); 123
sortBy.Items.Add(new ListItem("浏览次数", ((int)SortClubsBy.HitTimes).ToString())); 124
sortBy.Items.Add(new ListItem("本周浏览", ((int)SortClubsBy.WeekHitTimes).ToString())); 125
126
ClubQuery query = new ClubQuery(); 127
query.ConvertFromQueryString(); 128
clubName.Text = query.ClubNameFilter; 129
130
//if (query.AreaID>0) 131
// area.SelectedValue = query.AreaID; 132
if (query.AreaID > 0) 133
ajaxAreaList.SelectedValue = query.AreaID; 134
135
if (query.CategoryID > 0) 136
clubCategory.SelectedValue = query.CategoryID.ToString(); 137
138
if (query.SecrecyType != ClubSecrecyType.All) 139
{ 140
ListItem item = secrecyType.Items.FindByValue(((int)query.SecrecyType).ToString()); 141
if (item != null) 142
item.Selected = true; 143
} 144
145
if (query.Status != ClubStatus.All) 146
{ 147
ListItem item = status.Items.FindByValue(((int)query.Status).ToString()); 148
if (item != null) 149
item.Selected = true; 150
} 151
152
ListItem item2 = sortBy.Items.FindByValue(((int)query.SortBy).ToString()); 153
if (item2 != null) 154
item2.Selected = true; 155
156
sortOrder.SelectedValue = query.SortOrder; 157
} 158
} 159
160
void SearchButton_Click(object sender, EventArgs e) 161
{ 162
ClubQuery query = new ClubQuery(); 163
query.ClubNameFilter = clubName.Text.Trim(); 164
//query.AreaID = area.SelectedValue; 165
if (ajaxAreaList.SelectedValue>0) 166
query.AreaID = ajaxAreaList.SelectedValue; 167
query.CategoryID = int.Parse(clubCategory.SelectedValue); 168
query.SecrecyType = (ClubSecrecyType)int.Parse(secrecyType.SelectedValue); 169
query.Status = (ClubStatus)int.Parse(status.SelectedValue); 170
query.SortBy = (SortClubsBy)int.Parse(sortBy.SelectedValue); 171
query.SortOrder = sortOrder.SelectedValue; 172
173
Page.Response.Redirect(ManagerUrls.Instance().ClubSearchResult() + "?" + query.ConvertToQueryString(), true); 174
} 175
176
} 177
178
} 179
180






}