-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmanager.aspx.cs
More file actions
313 lines (309 loc) · 14.1 KB
/
manager.aspx.cs
File metadata and controls
313 lines (309 loc) · 14.1 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.Web.UI.HtmlControls;
using System.Web.Security;
using System.Text.RegularExpressions;
public partial class managerspx : System.Web.UI.Page
{
OA_users user = new OA_users();
List<OA_users> usersList = new List<OA_users>();
List<OA_users> leadersList = new List<OA_users>();
List<OA_users> qianDuanUserList = new List<OA_users>();
List<OA_users> pingMainList = new List<OA_users>();
List<OA_users> houTaiList = new List<OA_users>();
List<OA_users> flashList = new List<OA_users>();
List<OA_users> oldUserList = new List<OA_users>();
BaseDAL<OA_users> userDal = new BaseDAL<OA_users>();
BaseDAL<OA_item> dalItem = new BaseDAL<OA_item>();
protected void Page_Load(object sender, EventArgs e)
{
user = (OA_users)Session["user"];
usersList = userDal.GetList(1, 2000, "", "[grade]");
leadersList = SetUsersByGroup("负责人", usersList);
qianDuanUserList = SetUsersByGroup("前端", usersList);
pingMainList = SetUsersByGroup("平面", usersList);
houTaiList = SetUsersByGroup("程序", usersList);
flashList = SetUsersByGroup("flash", usersList);
oldUserList = SetUsersByGroup("往届", usersList);
if (user == null) Response.Redirect("sign.aspx");
if (!IsPostBack)
{
GetList(user.groups);
DropListDataBind();
}
}
//绑定数据
protected void GetList(string groupNow)
{
List<OA_item> allItemList = dalItem.GetList(1, 2000);
Header1.DataBind(allItemList, user.realName, user.loginName);
usersByLeaders.DataBind(leadersList);
usersByQianDuan.DataBind(qianDuanUserList);
usersByPingMian.DataBind(pingMainList);
usersByFlash.DataBind(flashList);
usersByHouTai.DataBind(houTaiList);
usersByOld.DataBind(oldUserList);
rightListDataBindByGroup(groupNow);
loginNameIn.Value = user.loginName;
rLongNumIn.Value = user.longNumber == null ? "" : user.longNumber;
rShortNumIn.Value = user.shortNumber == null ? "" : user.shortNumber;
}
protected void GetListAfterGet(string groupNow)
{
usersList = userDal.GetList(1, 2000, "", "[grade]");
leadersList = SetUsersByGroup("负责人", usersList);
qianDuanUserList = SetUsersByGroup("前端", usersList);
pingMainList = SetUsersByGroup("平面", usersList);
houTaiList = SetUsersByGroup("程序", usersList);
flashList = SetUsersByGroup("flash", usersList);
oldUserList = SetUsersByGroup("往届", usersList);
GetList(groupNow);
}
//添加人员和修改个人资料里的dropDownList的绑定和根据用户的身份设置权限
protected void DropListDataBind()
{
ArrayList dropItemAl = new ArrayList { "平面", "前端", "程序", "flash", "往届" };
groupDrDL.DataSource = dropItemAl;
groupDrDL.DataBind();
groupDrDL.SelectedValue = user.groups;
if (user.roles == "负责人")
{
editDiv.Visible = true;
editFlag.Value = "true";
GroupDropList.DataSource = dropItemAl;
GroupDropList.DataBind();
dropItemAl = new ArrayList { "组员", "组长", "往届", "负责人", "财务管理" };
RolesDropList.DataSource = dropItemAl;
RolesDropList.DataBind();
}
else
{
editFlag.Value = "false";
save.Visible = false;
}
}
//根据组别绑定右边的管理页面
protected void rightListDataBindByGroup(string groupName)
{
switch (groupName)
{
case "平面": rightListDataBind("平面", pingMainList); break;
case "前端": rightListDataBind("前端", qianDuanUserList); break;
case "程序": rightListDataBind("程序", houTaiList); break;
case "flash": rightListDataBind("flash", flashList); break;
case "往届": rightListDataBind("往届", oldUserList); oldUserPager.RecordCount = oldUserList.Count; break;
default: break;
}
}
protected void rightListDataBind(string groupName, List<OA_users> usersList)
{
if (groupName == "往届")
{
pager.Visible = true;
if (usersList.Count > 8) usersList.RemoveAt(8);
}
else pager.Visible = false;
GroupNameLitr.Text = groupName;
userListRpt.DataSource = usersList;
userListRpt.DataBind();
}
//根据组别获得treeview里要绑定的数据
protected List<OA_users> SetUsersByGroup(string groupName, List<OA_users> usersList)
{
List<OA_users> groupList = new List<OA_users>();
if (groupName == "负责人" | groupName == "往届")
{
foreach (OA_users menber in usersList)
{
if (menber.roles == groupName)
groupList.Add(menber);
}
}
else
{
foreach (OA_users menber in usersList)
{
if (menber.groups == groupName & menber.roles != "往届") groupList.Add(menber);
}
}
return groupList;
}
//treeview里的根据触发onclick的button的id而绑定右边的管理页面
protected void GroupBtn_Click(object sender, EventArgs e)
{
String btnID;
HtmlInputButton btn = sender as HtmlInputButton;
if (btn != null)
{
btnID = btn.ID;
switch (btnID)
{
case "LeaderBtn": rightListDataBind("负责人", leadersList); break;
case "PingMainBtn": rightListDataBind("平面", pingMainList); break;
case "QianDuanBtn": rightListDataBind("前端", qianDuanUserList); break;
case "HouTaiBtn": rightListDataBind("程序", houTaiList); break;
case "FlashBtn": rightListDataBind("flash", flashList); break;
case "OldUserBtn": rightListDataBind("往届", oldUserList); break;
default: break;
}
}
}
protected void DeleteBtn_Click(object sender, EventArgs e)
{
if (menberHid.Value != null)
{
try
{
userDal.Delete(menberHid.Value.Trim());
scripthelp.Alert("删除人员成功!", Page);
GetListAfterGet(GroupNameLitr.Text);
}
catch(Exception ex)
{
ControlLog controlLog = new ControlLog("manager");
controlLog.WriteDebugLog("DeleteBtn_Click-删除人员失败", ex.ToString(), user.realName);
scripthelp.Alert("删除人员失败!", Page);
}
}
else scripthelp.Alert("没有选中任何人员,不可以进行删除。", Page);
}
//添加人员
protected void SubmitBtn_Click(object sender, EventArgs e)
{
if (UserIn.Value != "" & GradeIn.Value != "")
{
OA_users newUser = new OA_users();
newUser.realName = UserIn.Value.Trim();
if (userDal.GetUser("realName", newUser.realName) != null)
{
scripthelp.Alert("工作室已经存在" + newUser.realName + ",若真的要添加,请为该同学加不同的标识,如加上届数:10小花!", Page);
scripthelp.RunScript(this.Page, "document.getElementById('edit').style.display='block'");
UserIn.Focus();
}
else
{
newUser.loginName = newUser.realName;
newUser.groups = this.GroupDropList.SelectedValue.Trim();
newUser.grade = GradeIn.Value.Trim();
newUser.roles = RolesDropList.SelectedValue.Trim();
newUser.school = SchoolIn.Value.Trim();
newUser.major = MajorIn.Value.Trim();
newUser.longNumber = LongNumIn.Value.Trim();
newUser.shortNumber = ShortNumIn.Value.Trim();
string[] columnArray = { "loginName", "realName", "groups", "roles", "grade", "school", "major", "longNumber", "shortNumber" };
ArrayList al = new ArrayList { newUser.loginName, newUser.realName, newUser.groups, newUser.roles, newUser.grade, newUser.school, newUser.major, newUser.longNumber, newUser.shortNumber };
try
{
userDal.insert(columnArray, newUser, al);
scripthelp.Alert("添加" + newUser.realName + "成功!", Page);
}
catch(Exception ex)
{
ControlLog controlLog = new ControlLog("manager");
controlLog.WriteDebugLog("SubmitBtn_Click-添加"+newUser.realName+"人员失败", ex.ToString(), user.realName);
scripthelp.Alert("添加" + newUser.realName + "失败!", Page);
}
GetListAfterGet(newUser.groups);
}
}
else
{
scripthelp.Alert("姓名和届都不能空哦。", this.Page);
scripthelp.RunScript(this.Page, "document.getElementById('edit').style.display='block'");
UserIn.Focus();
}//else
}
//修改个人资料
protected void ChangPersonSubmitBtn_Click(object sender, EventArgs e)
{
string loginName = loginNameIn.Value.Trim();
string oldPw = oldPwIn.Value.Trim();
string newPw = newPwIn.Value.Trim();
OA_users reUser = user;
if (!Regex.IsMatch(loginName, @"[-|;|,|\/|\(|\)|\[|\]|\}|\{|%|@|\*|!|\']") && !Regex.IsMatch(oldPw, @"[-|;|,|\/|\(|\)|\[|\]|\}|\{|%|\*|!|\']") && !Regex.IsMatch(newPw, @"[-|;|,|\/|\(|\)|\[|\]|\}|\{|%|\*|!|\']"))
{
string oldEncodePw = FormsAuthentication.HashPasswordForStoringInConfigFile(oldPw, "md5").Substring(0, 30);
if (oldEncodePw == user.pw)
{
if (loginName!=user.loginName&&userDal.GetUser("loginName", loginName) != null)
{
scripthelp.Alert("登录昵称" + loginName + "已经存在啦,请换昵称啦!", Page);
scripthelp.RunScript(Page, "document.getElementById('editPerson').style.display ='block';;document.getElementById('loginNameIn').focus();");
}
else
{
reUser.pw = FormsAuthentication.HashPasswordForStoringInConfigFile(newPw, "md5").Substring(0, 30);
reUser.loginName = loginName;
reUser.longNumber = rLongNumIn.Value.Trim();
reUser.shortNumber = rShortNumIn.Value.Trim();
reUser.groups = groupDrDL.Text;
if (userDal.Update(user) == 1)
{
scripthelp.Alert("个人资料修改成功!", Page);
user = reUser;
DropListDataBind();
GetListAfterGet(reUser.groups);
}
else scripthelp.Alert("个人资料修改失败!", Page);
}
}
else
{
scripthelp.Alert("输入的旧密码不正确,请重新输入!", Page);
}
}
}
protected void OnPageChanged(object sender, EventArgs e)
{
List< OA_users> oldUserList = userDal.GetList(oldUserPager.CurrentPageIndex, 8, "[roles]='往届'", "[grade]");
rightListDataBind("往届", oldUserList);
}
protected void save_Click(object sender, EventArgs e)
{
string[] ids = Common.StringToArray(changeMenHid.Value);
string[] colArray = { "roles", "grade", "school", "major", "longNumber", "shortNumber" };
int gross = 0;
OA_users cUser = new OA_users();
try
{
for (int i = 0; i < userListRpt.Items.Count; i++)
{
cUser.id = Convert.ToInt32(ids[i]);
string roles = ((HtmlInputText)userListRpt.Items[i].FindControl("roles")).Value.Trim();
if (roles == "负责人" | roles == "组长" | roles == "组员" | roles == "往届")
{
ArrayList al = new ArrayList {roles,((HtmlInputText)userListRpt.Items[i].FindControl("grade")).Value.Trim(),
((HtmlInputText)userListRpt.Items[i].FindControl("school")).Value.Trim(),
((HtmlInputText)userListRpt.Items[i].FindControl("major")).Value.Trim(),
((HtmlInputText)userListRpt.Items[i].FindControl("longNumber")).Value.Trim(),
((HtmlInputText)userListRpt.Items[i].FindControl("shortNumber")).Value.Trim()};
gross += userDal.Update(colArray, cUser, al);
}
else
{
scripthelp.Alert("职务只能是负责人或组长或组员或往届,请重新修改再保存!", Page);
((HtmlInputText)userListRpt.Items[i].FindControl("roles")).Focus();
return;
}
}
if (gross == userListRpt.Items.Count)
{
scripthelp.Alert("保存修改成功!", Page);
GetListAfterGet(GroupNameLitr.Text);
DropListDataBind();
oldUserPager.CurrentPageIndex = 1;
}
}
catch(Exception ex)
{
ControlLog controlLog = new ControlLog("manager");
controlLog.WriteDebugLog("save_Click-保存修改失败", ex.ToString(), user.realName);
scripthelp.Alert("保存修改失败!", Page);
}
}
}