Exemplo n.º 1
0
        public WCFAddUpdateResult AddOrUpdate(Sys_RoleRightResult result)
        {
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }
            ExeResult          rst = Execute("ZNLCRM.BLL.Sys.Sys_RoleRightBLL", "AddOrUpdate", result);
            WCFAddUpdateResult ret = (rst == null ? new WCFAddUpdateResult() : rst.Result as WCFAddUpdateResult);

            return(ret);
        }
Exemplo n.º 2
0
        public Sys_RoleRightResult GetInfo(Sys_RoleRightParam param)
        {
            var ret = new Sys_RoleRightResult();

            if (param.RoleRightID.ToInt32() <= 0)
            {
                ShowMessage("请指定要修改的记录!");
                return(ret);
            }
            ExeResult rst = Execute("ZNLCRM.BLL.Sys.Sys_RoleRightBLL", "GetInfo", param);

            ret = rst == null ? new Sys_RoleRightResult() : rst.Result as Sys_RoleRightResult;
            return(ret);
        }
Exemplo n.º 3
0
        private void btnSaveRoleRight_Click(object sender, EventArgs e)
        {
            Sys_RoleRightResult        param;
            List <Sys_RoleRightResult> list = new List <Sys_RoleRightResult>();

            for (int i = 0; i < dgvModule.Rows.Count; i++)
            {
                param             = new Sys_RoleRightResult();
                param.RoleRightID = dgvModule.Rows[i].Cells["colRoleRightID"].Value.ToInt32();
                param.ActionCode  = dgvModule.Rows[i].Cells["colActionCode"].Value.ToStringHasNull();
                list.Add(param);
            }

            WCFAddUpdateResult result = this.AsyncExecute <WCFAddUpdateResult, List <Sys_RoleRightResult> >(list, roleRightLogic.UpdateOrInsertList, (a) =>
            {
                BindDataGridView(1);
            });
        }
Exemplo n.º 4
0
        /// <summary>
        ///     删除角色
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public WCFAddUpdateResult DelInfo(Sys_RoleRightParam param)
        {
            CheckSession();
            var ret = new WCFAddUpdateResult();

            try
            {
                #region 判断

                if (param.RoleRightID.ToInt32() <= 0)
                {
                    throw new WarnException("请指定要删除的权限ID!");
                }

                #endregion

                WhereClip where = GetWhereClip(param);
                var info = new Sys_RoleRightResult {
                    IsDeleted = true
                };
                var affect = Update(info, @where);

                #region 设置返回值

                ret.Key = affect;

                #endregion
            }
            catch (WarnException)
            {
                throw;
            }
            catch (Exception exp)
            {
                LogInfoBLL.WriteLog(SessionInfo, exp);
            }
            return(ret);
        }
Exemplo n.º 5
0
        private void tlbAddModule_Click(object sender, EventArgs e)
        {
            List <int?> list = new List <int?> ();

            if (dgvModule.Rows.Count > 0)
            {
                foreach (DataGridViewRow row in dgvModule.Rows)
                {
                    list.Add(row.Cells["colModuleID"].Value.ToInt32());
                }
            }


            var frmModule = new frmSelectModule(true);

            frmModule.moduleID = list.ToArray();
            DialogResult rst = frmModule.ShowDialog();

            if (rst == DialogResult.OK)
            {
                List <Sys_ModuleResult>    moduleResultList    = frmModule.GetSelectList <Sys_ModuleResult>();
                List <Sys_RoleRightResult> roleRightResultList = new List <Sys_RoleRightResult>();
                foreach (Sys_ModuleResult moduleResult in moduleResultList)
                {
                    Sys_RoleRightResult result = new Sys_RoleRightResult
                    {
                        ModuleID   = moduleResult.ModuleID,
                        RoleID     = _roleID,
                        ActionCode = "Search",
                        IsDeleted  = false
                    };
                    roleRightResultList.Add(result);
                }

                WCFAddUpdateResult ret = this.AsyncExecute <WCFAddUpdateResult, List <Sys_RoleRightResult> >(roleRightResultList, roleRightLogic.UpdateOrInsertList, a => BindDataGridView(1));
            }
        }
Exemplo n.º 6
0
        /// <summary>
        ///     添加和新增修改
        /// </summary>
        /// <param name="param">新增或修改的实体</param>
        /// <returns></returns>
        public WCFAddUpdateResult AddOrUpdate(Sys_RoleRightResult param)
        {
            CheckSession();
            var ret = new WCFAddUpdateResult();

            try
            {
                #region 判断

                if (param.ActionCode.ToStringHasNull().Trim() == "")
                {
                    throw new WarnException("请指定权限ActionCode!");
                }
                if (param.RoleRightID < 0)
                {
                    throw new WarnException("请指定权限RoleRightID!");
                }

                var rolesResult = Select <Sys_RoleRightResult>(Sys_RoleRight._.RoleRightID == param.RoleRightID);
                if (param.RoleRightID > 0 && (rolesResult == null || rolesResult.ActionCode == ""))
                {
                    throw new WarnException("权限不存在!");
                }

                #endregion

                #region 判断重复

                WhereClip whereChk = Sys_RoleRight._.RoleRightID != -1 &&
                                     Sys_RoleRight._.RoleID == param.RoleID && Sys_RoleRight._.ModuleID == param.ModuleID &&
                                     Sys_RoleRight._.IsDeleted == param.IsDeleted;
                if (param.RoleRightID > 0)
                {
                    whereChk = whereChk & Sys_RoleRight._.RoleRightID != param.RoleRightID;
                }
                int chkNum = Count <Sys_RoleRightResult>(whereChk);
                if (chkNum > 0)
                {
                    throw new WarnException("存在重复的模块权限!");
                }

                #endregion

                #region 系统默认值

                if (param.RoleRightID > 0)
                {
                    WhereClip where = Sys_RoleRight._.RoleRightID == param.RoleRightID;
                    Update(param, @where);
                }
                else
                {
                    // var roleResult = new Sys_RoleRightResult();
                    Insert(param);
                    param = Select <Sys_RoleRightResult>(new List <Field> {
                        Sys_RoleRight._.RoleRightID
                    },
                                                         Sys_RoleRight._.ActionCode == param.ActionCode);
                }

                #region 设置返回值

                ret.Key = param.RoleRightID;

                #endregion

                #endregion
            }
            catch (WarnException)
            {
                throw;
            }
            catch (Exception exp)
            {
                LogInfoBLL.WriteLog(SessionInfo, exp);
            }
            return(ret);
        }
Exemplo n.º 7
0
        public List <Sys_FormRightResult> GetEmpWindowRight(Sys_FormRightParam param)
        {
            #region 判断
            this.CheckSession();
            if (param.NameSpace.ToStringHasNull() == "")
            {
                throw new WarningException("请指定命名空间!");
            }
            if (param.FormEngName.ToStringHasNull() == "")
            {
                throw new WarningException("请指定窗体名称!");
            }
            #endregion
            #region 员工所拥有权限设置
            List <Sys_FormRightResult> ret = new List <Sys_FormRightResult>();
            WhereClip where = Sys_FormRight._.IsDeleted == false;
            List <Sys_EmpRight> lstEmpRight = new List <Sys_EmpRight>();
            lstEmpRight = this.SelectList <Sys_EmpRight>(Sys_EmpRight._.EmpID == this.SessionInfo.UserID && Sys_EmpRight._.GCompanyID == this.SessionInfo.CompanyID && Sys_EmpRight._.IsDeleted == false);
            #endregion
            #region 员工所在角色
            Sys_EmpDataRightBLL    empDataRightBll = new Sys_EmpDataRightBLL();
            Sys_EmpDataRightResult empDataRightRst = new Sys_EmpDataRightResult();
            empDataRightBll.SessionInfo = this.SessionInfo;
            empDataRightRst             = empDataRightBll.GetEmpDataRight(new Sys_EmpDataRightParam()
            {
            });
            string roleIDs = empDataRightRst.RoleIDs;
            List <Sys_RoleRightResult> roleRightList = new List <Sys_RoleRightResult>();
            Sys_RoleRightResult        findRoleRight = new Sys_RoleRightResult();
            WhereClip whereClip = Sys_RoleRight._.IsDeleted == false;
            if (roleIDs.ToStringHasNull().Trim() != "")
            {
                int?[] arrRoleIds = roleIDs.Split(',').Where(a => a != "").Select(a => (int?)a.ToInt32()).ToArray();
                whereClip     = whereClip && Sys_RoleRight._.RoleID.In(arrRoleIds);
                roleRightList = this.SelectList <Sys_RoleRightResult>(whereClip);
            }
            #endregion

            #region 窗体控件集合
            List <Sys_FormRightResult> lstForm = new List <Sys_FormRightResult>();
            ret = this.SelectList <Sys_FormRightResult>(Sys_FormRight._.NameSpace == param.NameSpace && Sys_FormRight._.FormEngName == param.FormEngName && Sys_FormRight._.IsDeleted == false);
            #endregion
            #region 判断窗体控件是否有权限
            string[] arrActionForm = new string[] { };
            bool     existRight    = false;
            foreach (Sys_FormRightResult info in ret)
            {
                #region 判断是否拥有权限
                arrActionForm = info.ActionCode.ToStringHasNull().Split(',');
                if (arrActionForm.Length <= 0)
                {
                    info.PropertyValue = false;
                }
                else
                {
                    existRight = false;
                    foreach (string s in arrActionForm)
                    {
                        if (lstEmpRight.Exists(a => a.ActionCode.ToStringHasNull().Split(',').Contains(s) && a.ModuleID == info.ModuleID) ||
                            roleRightList.Exists(a => a.ActionCode.ToStringHasNull().Split(',').Contains(s) && a.ModuleID == info.ModuleID))
                        {
                            existRight = true;
                            break;
                        }
                    }
                    info.PropertyValue = existRight;
                }
                #endregion
            }
            #endregion

            return(ret);
        }