예제 #1
0
        public override bool OnPreLoad()
        {
            if (!base.OnPreLoad())
            {
                return(false);
            }

            if (AppService.GetUserID() == "admin")
            {
                return(true);
            }

            //如果当前窗口设置了模块ID,取权限列表
            if (!string.IsNullOrEmpty(this.FunctionID))
            {
                //如果不需要把权限信息传到客户端,不要用PermissionDataStore,直接用new SafeDS

                _dsRight = new SafeDS("d_sys_user_permissions");

                _dsRight.SetTransaction(this.AdoTransaction);
                _dsRight.Retrieve(AppService.GetUserID(), this.FunctionID);

                if (this._dsRight.RowCount <= 0)
                {
                    _dsRight.Dispose();
                    _dsRight = null;
                    return(true);
                }

                //如果系统有定义权限,但当前用户没有该模块的任何一个功能的权限
                //则作为没有权限打开该窗口
                if (_dsRight.FindRow("HasRight='1' ", 1, _dsRight.RowCount) <= 0)
                {
                    _dsRight.Dispose();
                    _dsRight = null;
                    this.LoadErrorMessage = "当前登录用户没有相应模块的权限";
                    this.LoadSuccessed    = false;
                    return(false);
                }
            }


            return(true);
        }