public override void Add(RoleWithUser value)
 {
     try
     {
         base.Add(value);
         NotificationHandlerFactory.NotificationHandler.OnRoleAuthorityChanged();
     }
     catch (Exception ex)
     {
         Log.Error(ex);
     }
 }
Beispiel #2
0
        private void Initial()
        {
            _currentUser = AppClientContext.CurrentUser.Id;
            listUser     = PharmacyDatabaseService.GetUser(out msg, _currentUser);
            listR        = PharmacyDatabaseService.AllRoles(out msg).Where(p => p.Name == "SystemRole" || p.Name == "信息管理员").FirstOrDefault();
            listRU       = PharmacyDatabaseService.GetRoleWithUserInfo(out msg, listUser.Id, listR.Id).FirstOrDefault();

            _tabPageEdit   = tabPageEdit;
            _tabPageSearch = tabPageSearch;
            DisplayTabPage(false);
            if (EnabledActions.Count > 0)
            {
                if (!EnabledActions.Contains("Search"))
                {
                    btnCancel.Visible  = false;
                    btnRefresh.Visible = false;
                    btnSearch.Visible  = false;
                }


                if (!EnabledActions.Contains("Add"))
                {
                    btnAdd.Visible = false;
                }

                if (!EnabledActions.Contains("Edit"))
                {
                    btnModify.Visible = false;
                }

                if (!EnabledActions.Contains("Edit") && !EnabledActions.Contains("Add"))
                {
                    btnSave.Visible   = false;
                    btnCancel.Visible = false;
                }
            }

            //用户修改自己密码
            if (listRU == null)
            {
                btnAdd.Visible     = false;
                btnDelete.Visible  = false;
                btnRefresh.Visible = false;
                btnSearch.Visible  = false;
            }

            HeaderTexts          = _headTexts;
            this.btnAdd.Click   += new System.EventHandler(this.OnButtonAddClick);
            this.btnClose.Click += new System.EventHandler(this.OnButtonCloseClick);
        }
        public override bool Add(RoleWithUser value, out string msg)
        {
            msg = string.Empty;
            try
            {
                return(base.Add(value, out msg));

                NotificationHandlerFactory.NotificationHandler.OnRoleAuthorityChanged();
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                return(false);
            }
        }
Beispiel #4
0
        void checkBox_CheckedChanged(object sender, EventArgs e)
        {
            if (!UsersRolesSetted)
            {
                return;
            }
            if (SelectedUsersRoles == null)
            {
                return;
            }
            CheckBox checkBox = sender as CheckBox;
            string   message  = string.Empty;

            if (checkBox != null)
            {
                Role role = checkBox.Tag as Role;
                if (checkBox.Checked)
                {
                    //选中了
                    if (!SelectedUsersRoles.Any(ur => ur.RoleId == role.Id && ur.Id == SelectedUser.Id))
                    {
                        //原来没有则添加
                        RoleWithUser rwu = new RoleWithUser();
                        rwu.Id     = Guid.NewGuid();
                        rwu.RoleId = role.Id;
                        rwu.UserId = SelectedUser.Id;
                        PharmacyDatabaseService.AddRoleWithUser(out message, rwu);
                        this.PharmacyDatabaseService.WriteLog(AppClientContext.CurrentUser.Id, "员工岗位信息设置成功!");
                    }
                }
                else
                {
                    //没选
                    RoleWithUser rwu = SelectedUsersRoles.FirstOrDefault(ur => ur.RoleId == role.Id && ur.UserId == SelectedUser.Id);
                    if (rwu != null)
                    {
                        PharmacyDatabaseService.DeleteRoleWithUser(out message, rwu.Id);
                    }
                }
                LoadSelectedUsersRoles();
            }
        }