public ActionResult AddFunctionGroupsUser(string pStrFunction, int pIdGroups, int pIdUser) { try { ViewBag.tabFocus = 2; string FunctionInUser = "******" + pIdGroups.ToString() + pIdUser.ToString(); string FuncInGroup = "FuncInGroup" + pIdGroups.ToString() + pIdUser.ToString(); GroupFunctionBL _funcg = new GroupFunctionBL(); UserFunctionBL _userfunc = new UserFunctionBL(); decimal preturn = 0; if (pStrFunction != null) { // xoa di r insert tung thang vao if (_userfunc.Delete_UserFunction_ByUser(pIdUser)) { string[] _arr_func = pStrFunction.Split(','); foreach (string item in _arr_func) { UserFunction_Info pinfo = new UserFunction_Info(); pinfo.lstFunction = pStrFunction.Trim(','); pinfo.User_Id = pIdUser; pinfo.Group_Id = pIdGroups; pinfo.Created_By = SessionData.CurrentUser.User_Name; preturn = _userfunc.UserFunctionInsert(pinfo); } } } if (preturn > 0) { //danh sachs chuc nang thuoc nhom dc phan quen cho user Session[FunctionInUser] = _userfunc.UserFunctionGetAll(pIdUser, pIdGroups); //danh sach chuc nang thuoc nhom Session[FuncInGroup] = _funcg.FunctionInGroupsGetAllToList(pIdGroups); } ViewBag.IDGroup = pIdGroups; return(Json(new { success = true, status = preturn })); } catch (Exception ex) { NaviCommon.Common.log.Error(ex.ToString()); return(Json(new { success = false, status = -3 })); } }
/// <summary> /// Hiệu chỉnh danh Danh sách chức năng của user /// </summary> /// <returns></returns> public ActionResult FunctionGroupOfUserList() { try { ViewBag.tabFocus = 2; GroupsBL _groups = new GroupsBL(); GroupFunctionBL _funcg = new GroupFunctionBL(); UserFunctionBL _userFunc = new UserFunctionBL(); string _ip = Request.UserHostAddress; //string _url = "/ModuleUserRoles/FunctionOfGroups/FunctionOfGroupList"; string _url = "/ModuleUser/GroupsUser/GroupUserList"; string _ok = CommonFunc.Nvs_Redirect_QuyenTruyCapUser(_url, _ip); if (_ok != "") { return(Redirect(_ok)); } if (!RouteData.Values.ContainsKey("id")) { return(View(new List <Functions_Info>())); } int idUserFun = 0; int idGroup = 0; if (RouteData.Values["id"] != null) { string pidgroupiduser = RouteData.Values["id"].ToString(); if (pidgroupiduser.Contains('-')) { string[] arr = pidgroupiduser.Split('-'); if (arr.Length == 2) { idUserFun = Convert.ToInt32(arr[0]); idGroup = Convert.ToInt32(arr[1]); } else { return(View(new List <Functions_Info>())); } } else { return(View(new List <Functions_Info>())); } } ViewBag.IDGroup = idGroup; ViewBag.CreateGroupOwner = true; //nếu nhóm chính người dùng tạo thì chuyển về true if (SessionData.CurrentUser.User_Id < 0) { ViewBag.CreateGroupOwner = false; } List <Groups_Info> lstGroup = _groups.GroupsGetAll(); CommonData.gLstGroups = lstGroup; foreach (var item in lstGroup) { if (item.Group_Id == idGroup) { //nếu là nhóm người khác tạo xong phân quyền thì Có tổng 46/58 quyền được chọn. //hiển thị số đc chọn / tổng là = nhau để người đc phân ko biết rõ là các quyền đc phân thiếu if (item.Created_By.ToUpper() == SessionData.CurrentUser.User_Name.ToUpper()) { ViewBag.CreateGroupOwner = true; } else { ViewBag.CreateGroupOwner = false; } ViewBag.GroupInfoUser = item; break; } } ViewBag.IdUserFunc = idUserFun; //danh sach chuc nang thuoc user ViewBag.FunctionInUser = _userFunc.UserFunctionGetAll(idUserFun, idGroup); ViewBag.FunctionInUserMans = _userFunc.UserFunctionGetAll(SessionData.CurrentUser.User_Id, idGroup); //dang xem chinh no ViewBag.CurrentUser = 0; if (idUserFun == SessionData.CurrentUser.User_Id) { ViewBag.CurrentUser = 1; } //danh sach chuc nang thuoc nhom 10:28.08.2015 ViewBag.FuncInGroup = _funcg.FunctionInGroupsGetAllToList(idGroup); ViewBag.IDGroupUser = idGroup.ToString() + idUserFun.ToString(); string FunctionInUser = "******" + ViewBag.IDGroupUser.ToString(); string FuncInGroup = "FuncInGroup" + ViewBag.IDGroupUser.ToString(); Session[FunctionInUser] = ViewBag.FunctionInUser; Session[FuncInGroup] = ViewBag.FuncInGroup; return(View()); } catch (Exception ex) { NaviCommon.Common.log.Error(ex.ToString()); return(View()); } }