示例#1
0
        /// <summary>
        /// 根据编辑的菜单项更新角色的访问
        /// </summary>
        /// <param name="obj"></param>
        private void UpdateRole(TB_Permission obj)
        {
            // 更新默认角色可以访问的
            if (obj.IsDefault == true)
            {
                var dftPermission = PermissionInstance.GetDefaultMenus();
                // 查找非管理角色
                var roles = RoleInstance.FindList(f => f.IsAdministrator == false && f.Delete == false);
                foreach (var role in roles)
                {
                    var pers = role.Permission.Split(new char[] { ',' });
                    if (!pers.Contains(obj.id.ToString()))
                    {
                        RoleInstance.Update(f => f.id == role.id, act => act.Permission = dftPermission);
                    }
                }
            }
            // 查找更新管理员角色的访问权限
            RoleInstance.Update(f => f.IsAdministrator == true && f.Delete == false,
                                act => act.Permission = PermissionInstance.GetAdministratorsMenus());

            // 重置当前登陆者的session
            Account = AccountInstance.Find(f => f.id == Account.id);
            Session[Utility.SessionName] = Account;
        }
示例#2
0
        private void NewAccount()
        {
            var account = AccountInstance.GetObject();

            BuildAccountInfo(account);
            // check the same login code
            var chk = AccountInstance.Find(f => f.Code.Equals(account.Code));

            if (null != chk)
            {
                ShowNotification("./account_add.aspx", "The login code \"" + account.Code + "\" is exist.", false);
            }
            else
            {
                AccountInstance.Add(account);

                // 保存历史记录
                SaveHistory(new TB_AccountHistory()
                {
                    ActionId = ActionInstance.Find(f => f.Name.Equals("AddAccount")).id,
                    ObjectA  = "[id=" + account.id + "] " + account.Name + ", " + account.Code
                });

                ShowNotification("./account_add.aspx", "You add a new account: " + account.Name + "(" + account.Code + ").");
            }
        }
示例#3
0
        private void EditAccount()
        {
            var account = AccountInstance.Find(f => f.id == ParseInt(Utility.Decrypt(hidID.Value)));

            if (null != account)
            {
                BuildAccountInfo(account);
                Update(account);

                // 保存历史记录
                SaveHistory(new TB_AccountHistory
                {
                    ActionId = ActionInstance.Find(f => f.Name.Equals("EditAccount")).id,
                    ObjectA  = "[id=" + account.id + "] " + account.Name + ", " + account.Code
                });

                ShowNotification("./account_list.aspx", "You changed account: " + account.Name + "(" + account.Code + ").");
            }
        }
示例#4
0
        private void showEdit()
        {
            var account = AccountInstance.Find(f => f.id == ParseInt(Utility.Decrypt(_key)));

            if (null != account)
            {
                txtCode.Value       = account.Code;
                txtDepartment.Value = (int?)null == account.Department ? "" : account.TB_Department.Name;
                txtEmail.Value      = account.Email;
                txtLindline.Value   = account.LandlineNumber;
                txtName.Value       = account.Name;
                txtPhone.Value      = account.Phone;
                txtQuestion.Value   = account.Question;
                txtAnswer.Disabled  = !string.IsNullOrEmpty(account.Question);
                txtRole.Value       = (int?)null == account.Role ? "" : account.TB_Role.Name;
                hidDepartment.Value = (int?)null == account.Department ? "" : account.Department.ToString();
                hidRole.Value       = (int?)null == account.Role ? "" : account.Role.ToString();
            }
            else
            {
                ShowNotification("./account_list.aspx", "Error: paramenter error, cannot edit the account.", false);
            }
        }