-
Notifications
You must be signed in to change notification settings - Fork 1
/
NoticeMidList.ascx.cs
127 lines (119 loc) · 3.96 KB
/
NoticeMidList.ascx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class NoticeMidList : System.Web.UI.UserControl
{
BaseDAL<OA_announcement> dalNotice = new BaseDAL<OA_announcement>();
List<OA_announcement> noticesList = new List<OA_announcement>();
public bool leaderF
{
get { return (bool)ViewState["leaderFlag"]; }
set { ViewState["leaderFlag"] = value; }
}
private int _noticeCuPage;
protected void Page_Load(object sender, EventArgs e)
{
}
public int noticeCuPage
{
get
{
_noticeCuPage = this.noticeAspNetPager.CurrentPageIndex;
return _noticeCuPage;
}
set
{
this.noticeAspNetPager.CurrentPageIndex = value;
_noticeCuPage = this.noticeAspNetPager.CurrentPageIndex;
}
}
public void DataBind(int noticeId, List<OA_announcement> noticeList, int noticeCount,bool leaderFlag)
{
if (noticesList==null) mid_list_notice.InnerText = "暂无数据";
else
{
noticesList = noticeList;
noticeRptList.DataSource = noticeList;
noticeRptList.DataBind();
noticeAspNetPager.RecordCount = noticeCount;
if (noticeId != 0)
{
noticeContentDataBind(noticeId);
change.Visible = false;
}
else
{
noticeContent.Visible = false;
mid_list_notice.Visible = !noticeContent.Visible;
change.Visible = !noticeContent.Visible;
}
leaderF = leaderFlag;
if (leaderF)
{
foreach (CheckBox checkbox in GetCheckboxs())
{
checkbox.Style.Remove("display");
}
}
}
}
protected void noticeContentDataBind(int noticeId)
{
change.Visible = false;
mid_list_notice.Visible = false;
OA_announcement notice = dalNotice.GetModel(noticeId, "id");
if (notice != null)
{
noticeTitleSpan.InnerText = notice.title;
posterSpan.InnerText = notice.poster;
postDateSpan.InnerText = notice.postDate.ToString("yyy.MM.d");
if (notice.content == "")
notice.content = "无";
contentP.InnerHtml = " " + notice.content;
noticeContent.Visible = !mid_list_notice.Visible;
}
else noticeContent.InnerHtml = "<strong>尝试查看的公告不存在!</strong>";
}
public List<CheckBox> GetCheckboxs()
{
List<CheckBox> checkBoxList=new List<CheckBox>();
for(int i=0;i<noticeRptList.Items.Count;i++)
{
checkBoxList.Add((CheckBox)noticeRptList.Items[i].FindControl("NoticeCheckBox"));
}
return checkBoxList;
}
public string GetCheckdId()
{
List<CheckBox> checkBoxList = GetCheckboxs();
string ids="";
foreach(CheckBox cBox in checkBoxList)
{
if(cBox.Checked)
{
if (ids == "") ids = cBox.Text;
else ids += "," + cBox.Text;
}
}
return ids;
}
protected void noticePpt_ItemCommand(object source, RepeaterCommandEventArgs e)
{
int noticeId = int.Parse(e.CommandArgument.ToString());
noticeContentDataBind(noticeId);
}
protected void OnPageChanged(object sender, EventArgs e)
{
List<OA_announcement> nextNoticeList = dalNotice.GetList(noticeAspNetPager.CurrentPageIndex, 10,"","[postDate] DESC");
DataBind(0, nextNoticeList, noticeAspNetPager.RecordCount,leaderF );
}
protected void backList_Click(object sender, EventArgs e)
{
mid_list_notice.Visible = true;
change.Visible = true;
noticeContent.Visible = !mid_list_notice.Visible;
}
}