private void User_Right_Insert() { try { if (c_change) { User_RightsController _User_RightsController = new User_RightsController(); List <User_RightsInfo> _lstRight = new List <User_RightsInfo>(); foreach (User_FunctionsInfo item in c_arrFunction) { if (item.authcode != 0) { User_RightsInfo _User_RightsInfo = ConvertToUser_RightsInfo(item, c_UsersInfo.User_Id); _User_RightsInfo.User_Name = c_UsersInfo.User_Name; _lstRight.Add(_User_RightsInfo); } } if (_lstRight.Count > 0) { MessageBoxResult result1 = NoteBox.Show("Bạn có muốn cập nhật hay không?", "", NoteBoxLevel.Question); if (result1 == MessageBoxResult.Yes) { Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; _User_RightsController.User_Rights_DelByUser(c_UsersInfo.User_Name); _User_RightsController.User_Rights_Insert_Barth(_lstRight); Mouse.OverrideCursor = null; c_ok = 1; NoteBox.Show("Cập nhật dữ liệu thành công", "", NoteBoxLevel.Note); this.Close(); } } else { Mouse.OverrideCursor = null; NoteBox.Show("Bạn chưa đặt quyền cho chức năng nào", "", NoteBoxLevel.Error); } } else { Mouse.OverrideCursor = null; NoteBox.Show("Bạn chưa thực hiện thay đổi quyền nào", "", NoteBoxLevel.Error); } } catch (Exception ex) { Mouse.OverrideCursor = null; ErrorLog.log.Error(ex.ToString()); NoteBox.Show("Cập nhật dữ liệu không thành công", "Lỗi", NoteBoxLevel.Error); } }
private void User_Right_Insert() { try { if (c_change) { User_RightsController _User_RightsController = new User_RightsController(); ArrayList arrRight = new ArrayList(); foreach (User_FunctionsInfo item in c_arrFunction) { if (item.right != "000000") { User_RightsInfo _User_RightsInfo = ConvertToUser_RightsInfo(item, c_UsersInfo.User_Id); arrRight.Add(_User_RightsInfo); } } if (arrRight.Count > 0) { MessageBoxResult result1 = NoteBox.Show("Bạn có muốn sửa thông tin này hay không?", "Thông báo", NoteBoxLevel.Question); if (result1 == MessageBoxResult.Yes) { _User_RightsController.User_Rights_DelByUser(c_UsersInfo.User_Name); _User_RightsController.User_Rights_Insert_Barth(arrRight, c_UsersInfo.User_Name); User_Controller _usC0n = new User_Controller(); _usC0n.User_Change_SetRight(c_UsersInfo.User_Id); NoteBox.Show("Cập nhật dữ liệu thành công"); this.Close(); } } else { NoteBox.Show("Bạn chưa đặt quyền cho chức năng nào", "Thông báo", NoteBoxLevel.Error); } } else { NoteBox.Show("Bạn chưa thực hiện thay đổi quyền nào", "Thông báo", NoteBoxLevel.Error); } } catch (Exception ex) { CommonData.log.Error(ex.ToString()); NoteBox.Show("Cập nhật dữ liệu không thành công", "Lỗi", NoteBoxLevel.Error); } }
void GetFunctionGroupAdd(ArrayList p_arr_new, Hashtable _hs_new_check) { try { #region Lấy thằng function nào đc add mới hoặc bỏ đi // xem những thằng nào được check thêm thì add thêm quyền cho nó ArrayList _funt_add = new ArrayList(); Hashtable _hs_funt_remove = new Hashtable(); foreach (FunctionsInfo item in p_arr_new) { // xem những thằng nào được check thêm thì add thêm quyền cho nó FunctionsInfo _tem = new FunctionsInfo(); _tem = (FunctionsInfo)c_hs_UserRight_First[item.id]; if (_tem == null) { _funt_add.Add(item); } } // xem những thằng nào mà lúc đầu có lúc sau ko có thì xóa quyền của nó đi foreach (FunctionsInfo item in c_hs_UserRight_First.Values) { FunctionsInfo _tem = new FunctionsInfo(); _tem = (FunctionsInfo)_hs_new_check[item.id]; if (_tem == null) { _hs_funt_remove[item.id] = item; } } #endregion #region Xóa quyền cho những function mới thêm vào cho all các user thuộc group đó if (_hs_funt_remove.Count > 0) { foreach (User_Info item_us in DBMemory.c_hash_Users.Values) { ArrayList _arrRightByUser = new ArrayList(); if (item_us.Group_Id == c_GroupUserInfo.Id) { foreach (FunctionsInfo fun in _hs_funt_remove.Values) { _User_RightsController.Delete_User_Right_By_UserFuntion(item_us.User_Name, fun.id); } } } } #endregion #region Thêm full quyền cho những function mới thêm vào cho all các user thuộc group đó if (_funt_add.Count > 0) { // lấy all user thuộc nhóm đó foreach (User_Info item_us in DBMemory.c_hash_Users.Values) { List <User_RightsInfo> _lstRightByUser = new List <User_RightsInfo>(); if (item_us.Group_Id == c_GroupUserInfo.Id) { #region Add thêm quyền vào user đó // add thêm những quyền mới thêm vào user đó foreach (FunctionsInfo fun in _funt_add) { User_FunctionsInfo _us_fun = new User_FunctionsInfo(); _us_fun.functionId = fun.id; _us_fun.authcode = 1; User_RightsInfo _User_RightsInfo = ConvertToUser_RightsInfo(_us_fun, item_us.User_Id); _User_RightsInfo.User_Name = item_us.User_Name; _lstRightByUser.Add(_User_RightsInfo); } _User_RightsController.User_Rights_Insert_Barth(_lstRightByUser); #endregion } } } #endregion } catch (Exception ex) { ErrorLog.log.Error(ex.ToString()); } }