Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
 private User_RightsInfo ConvertToUser_RightsInfo(User_FunctionsInfo _User_FunctionsInfo, decimal user_id)
 {
     try
     {
         User_RightsInfo _User_RightsInfo = new User_RightsInfo();
         _User_RightsInfo.userid   = user_id;
         _User_RightsInfo.funcid   = _User_FunctionsInfo.functionId;
         _User_RightsInfo.authcode = _User_FunctionsInfo.authcode;
         return(_User_RightsInfo);
     }
     catch (Exception ex)
     {
         ErrorLog.log.Error(ex.ToString());
         return(null);
     }
 }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
        public void User_Rights_Insert_Barth(List <User_RightsInfo> p_lst)
        {
            try
            {
                User_RightsInfo[] _arr = new User_RightsInfo[p_lst.Count];
                for (int i = 0; i < p_lst.Count; i++)
                {
                    User_RightsInfo _User_RightsInfo = (User_RightsInfo)p_lst[i];
                    _arr[i] = _User_RightsInfo;
                }

                CommonData.c_serviceWCF.User_Rights_Insert_Barth(_arr);
            }
            catch (Exception ex)
            {
                ErrorLog.log.Error(ex.ToString());
            }
        }
Beispiel #5
0
 private User_RightsInfo ConvertToUser_RightsInfo(User_FunctionsInfo _User_FunctionsInfo, decimal user_id)
 {
     try
     {
         User_RightsInfo _User_RightsInfo = new User_RightsInfo();
         _User_RightsInfo.userid       = user_id;
         _User_RightsInfo.funcid       = _User_FunctionsInfo.functionId;
         _User_RightsInfo.authcode     = _User_FunctionsInfo.right;
         _User_RightsInfo.notes        = "";
         _User_RightsInfo.deleted      = 0;
         _User_RightsInfo.created_by   = CommonData.c_Urser_Info.User_Name;
         _User_RightsInfo.created_date = DateTime.Now;
         return(_User_RightsInfo);
     }
     catch (Exception ex)
     {
         CommonData.log.Error(ex.ToString());
         return(null);
     }
 }
Beispiel #6
0
        public int User_Rights_Insert_Barth(User_RightsInfo[] p_arr)
        {
            try
            {
                List <User_RightsInfo> p_lst = new List <User_RightsInfo>();

                for (int i = 0; i < p_arr.Length; i++)
                {
                    User_RightsInfo item = p_arr[i];
                    p_lst.Add(item);
                }
                User_Rights_DA _User_Rights_DA = new User_Rights_DA();
                return(_User_Rights_DA.User_Rights_Insert_Barth(p_lst));
            }
            catch (Exception ex)
            {
                ErrorLog.log.Error(ex.ToString());
                return(-1);
            }
        }
Beispiel #7
0
        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());
            }
        }