/// <summary> /// 处理添加角色的方法 /// </summary> /// <returns></returns> public ActionResult ExeAddEmployeerRole() { //获值 //接收被授权员工的id int?emerid = Convert.ToInt32(Request["id"]); /* * 只能拥有一个角色 */ //接收角色id int?id = 0; if (Request["num"] != null) { id = Convert.ToInt32(Request["num"]); } //根据id查询角色 Employee_RoleInfo haver = dal.GetRoleByID(id); if (haver != null) { //删除原本角色再添加新角色 bool isDel = dal.DelEmpRole(haver); if (isDel) { //添加角色 Employee_RoleInfo er = new Employee_RoleInfo(); er.EmployeeID = emerid; er.RoleID = id; bool isAdd = dal.AddRoleByEmID(er); if (isAdd) { return(RedirectToAction("PermissionManage")); } } } else { //添加角色 Employee_RoleInfo er = new Employee_RoleInfo(); er.EmployeeID = emerid; er.RoleID = id; bool isAdd = dal.AddRoleByEmID(er); if (isAdd) { return(RedirectToAction("PermissionManage")); } } return(RedirectToAction("PermissionManage")); }