1 2 CssClass="data_table" AllowPaging="false" OnPageIndexChanging="RptUsers_PageIndexChanging" 3 OnRowCommand="RptUsers_RowCommand" onrowdatabound="RptUsers_RowDataBound" > 4 5 6 7 8 9 10 11 12 13 14 15 <%#GetInputTagHtml(Convert.ToInt32(Eval("Id")))%> 16 17 18 19 20 21 22 <%# (this.AspNetPager1.CurrentPageIndex - 1) * this.AspNetPager1.PageSize + Container.DataItemIndex + 1%> 23 24 25 26 27 28 <%#Eval("Name")%> 29 30 31 32 33 34 <%# Eval("Organizer")%> 35 36 37 38 39 40 <%#GetUserName(Convert.ToInt32(Eval("Creater")))%> 41 42 43 44 45 <%# GetDateStr(Eval("StartTime").ToString()) %> 46 47 48 49 50 <%# GetDateStr(Eval("EndTime").ToString())%> 51 52 53 54 55 56 <%#Convert.ToDateTime(Eval("CreateTime").ToString()).ToString("yyyy-MM-dd")%> 57 58 59 60 61 62 <%#GetActiveType(Eval("ActiveType").ToString())%> 63 64 65 66 67 <%#GetIPLimitType(Eval("IPLimitType").ToString())%> 68 69 70 71 72 <%#GetUserLimitType(Eval("UserLimitType").ToString())%> 73 74 75 76 77 <%# GetStateStr(Eval("States").ToString())%> 78 79 80 81 82 <%# GetOperateStr(Eval("ActiveType").ToString(), Eval("Id").ToString())%> 83 编辑 84 85 86 87 88 )">投票统计 89 90 91 92 93 94 95 96 
View Code
1 protected void RptUsers_RowCommand(object sender, GridViewCommandEventArgs e)
2 {
3 //删除
4 if (e.CommandName.Equals("lkbDelete"))
5 {
6 try
7 {
8 Dictionary
9 searchConditions.Add("States",0);
10 searchConditions.Add("ActivityId", Convert.ToInt32(e.CommandArgument.ToString()));
11
12 IList
13 if (workInfo_list.Count > 0)
14 {
15 JSUtil.MessageBox("该投票下面有图文作品,请先删除图片作品!");
16 return;
17 }
18
19 ActivityInfo model_activeInfo = ServiceFactory.ActivityInfoService.GetById(Convert.ToInt32(e.CommandArgument.ToString()));
20 string imgpath =model_activeInfo==null?"": model_activeInfo.ImgPath;
21 ActivityInfo activity = model_activeInfo;
22 //ServiceFactory.ActivityInfoService.Delete(Convert.ToInt32(e.CommandArgument.ToString()));
23 IOHelper.DeleteFile(Server.MapPath(imgpath));
24 UserInfo user=ServiceFactory.UserInfoService.GetById(int.Parse(activity.Creater));
25 IDictionary
26 param.Add("Activity", activity.Id);
27 param.Add("AdminId", user.Id);
28 //投票活动和管理员授权列表
29 IList
30 if (res != null && res.Count > 0)
31 {
32 foreach(var item in res)
33 {
34 ServiceFactory.RelationAdminActivityInfoService.Delete(item.Id);
35 }
36 }
37 //删除投票活动 20161216
38 ServiceFactory.ActivityInfoService.Delete(Convert.ToInt32(e.CommandArgument.ToString()));
39
40 JSUtil.MessageBox("删除成功!");
41 BindData();
42 }
43 catch
44 {
45 JSUtil.MessageBox("删除失败,请稍后再试!");
46 }
47 }
48 //投票同步
49 else if (e.CommandName.Equals("lkbtnVote"))//作品数和投票数数据同步
50 {
51 try
52 {
53 int votecount = 0;
54 ActivityInfo activity = ServiceFactory.ActivityInfoService.GetById(int.Parse(e.CommandArgument.ToString()));
55 //图文投票
56 if (activity.ActiveType == 1)
57 {
58 Dictionary
59 searchConditions.Add("States", 1);
60 searchConditions.Add("ActivityId", Convert.ToInt32(e.CommandArgument.ToString()));
61 IList
62 if (workInfo_list != null && workInfo_list.Count > 0)
63 {
64 for (int i = 0; i < workInfo_list.Count; i++)
65 {
66 votecount += workInfo_list[i].TotalVoteCount;
67 }
68 }
69 activity.VoteCount = votecount; //投票数
70 activity.WorkCount = workInfo_list.Count;//作品数
71 ServiceFactory.ActivityInfoService.Update(activity);
72 }
73 else //文字投票 ToDo
74 {
75 }
76 JSUtil.MessageBox("同步成功!");
77 BindData();
78 }
79 catch
80 {
81 JSUtil.MessageBox("同步失败,请稍后再试!");
82 }
83 }
84
85 //开启
86 else if (e.CommandName.Equals("lkbtnOpen"))//开启
87 {
88 try
89 {
90 ActivityInfo activity = ServiceFactory.ActivityInfoService.GetById(int.Parse(e.CommandArgument.ToString()));
91 if (activity.States == 0)
92 {
93 activity.States = 1;
94 activity.UpdateTime = DateTime.Now;
95 }
96 else
97 {
98 activity.States = 0;
99 activity.UpdateTime = DateTime.Now;
100 }
101 ServiceFactory.ActivityInfoService.Update(activity);
102 JSUtil.MessageBox("操作成功!");
103 BindData();
104 }
105 catch
106 {
107 JSUtil.MessageBox("操作失败,请稍后再试!");
108 }
109 }
110 }
View Code
1 protected void RptUsers_RowDataBound(object sender, GridViewRowEventArgs e)
2 {
3 if (e.Row.RowType == DataControlRowType.DataRow)
4 {
5 //用FindControl方法找到模板中的Label控件
6 HiddenField HiddenField = (HiddenField)e.Row.FindControl("hid_states");// 0不开启 1 开启
7 LinkButton lkbtnOpen = (LinkButton)e.Row.FindControl("lkbtnOpen"); //开启按钮
8 if (HiddenField.Value == "0")
9 {
10 lkbtnOpen.Text = "开启";
11 }
12 else
13 {
14 lkbtnOpen.Text = "关闭";
15 }
16 }
17 }
View Code