/// <summary> /// 处理添加权限的方法 /// </summary> /// <returns></returns> public ActionResult ExeAddPer() { //接收权限ids string ids = Request["nums"]; //接收被授权员工的id int?emerid = Convert.ToInt32(Session["id"]); //在添加员工权限时 先查询该员工权限 将该员工权限全部删除 再进行授权 List <Employee_PermissionInfo> li = dal.GetPerByEmID(emerid); if (li.Count > 0) //有权限 { bool isDel = dal.DelPerByEmID(emerid); //删除权限 if (isDel) { //添加权限 List <string> list = ids.Split(',').ToList(); bool isAdd = false; for (int i = 0; i < list.Count() - 1; i++) { Employee_PermissionInfo ep = new Employee_PermissionInfo(); ep.EmployeeId = emerid; ep.PermissionID = Convert.ToInt32(list[i]); isAdd = dal.AddPerByEmID(ep); } if (isAdd) { return(RedirectToAction("PermissionManage")); } } } else//没有权限 { //添加权限 List <string> list = ids.Split(',').ToList(); bool isAdd = false; for (int i = 0; i < list.Count() - 1; i++) { Employee_PermissionInfo ep = new Employee_PermissionInfo(); ep.EmployeeId = emerid; ep.PermissionID = Convert.ToInt32(list[i]); isAdd = dal.AddPerByEmID(ep); } if (isAdd) { return(RedirectToAction("PermissionManage")); } } return(RedirectToAction("PermissionManage")); }