Esempio n. 1
0
        /// <summary>
        ///     添加和新增修改
        /// </summary>
        /// <param name="param">新增或修改的实体</param>
        /// <returns></returns>
        public WCFAddUpdateResult AddOrUpdate(Sys_RoleResult param)
        {
            CheckSession();
            var ret = new WCFAddUpdateResult();

            try
            {
                #region 判断重复
                WhereClip whereChk = Sys_Roles._.RoleID != -1 && Sys_Roles._.RoleName == param.RoleName;
                if (param.RoleID > 0)
                {
                    whereChk = whereChk & Sys_Roles._.RoleID != param.RoleID;
                }
                int chkNum = Count <Sys_RoleResult>(whereChk);
                if (chkNum > 0)
                {
                    throw new WarnException("存在重复的角色名称!");
                }

                #endregion

                #region 系统默认值

                if (param.RoleID > 0)
                {
                    WhereClip where = Sys_Roles._.RoleID == param.RoleID;
                    Update(param, @where);
                }
                else
                {
                    param.IsDeleted  = false;
                    param.GCompanyID = this.SessionInfo.CompanyID;
                    this.Insert(param);
                    param = Select <Sys_RoleResult>(new List <Field> {
                        Sys_Roles._.RoleID
                    },
                                                    Sys_Roles._.RoleName == param.RoleName);
                }

                #region 设置返回值

                ret.Key = param.RoleID;

                #endregion

                #endregion
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (Exception exp)
            {
                LogInfoBLL.WriteLog(SessionInfo, exp);
                throw exp;
            }
            return(ret);
        }
Esempio n. 2
0
        public PageList <Sys_FormRightResult> GetPageList(Sys_FormRightParam param)
        {
            this.CheckSession();
            PageList <Sys_FormRightResult> rst = new PageList <Sys_FormRightResult>();

            try
            {
                #region 获取分页列表
                WhereClip where = GetWhereClip(param);
                List <Field> lstField = new List <Field>()
                {
                    Sys_FormRight._.FormRightID, Sys_FormRight._.NameSpace, Sys_FormRight._.FormEngName,
                    Sys_FormRight._.FormChsName, Sys_FormRight._.UserControlEngName, Sys_FormRight._.UserControlChsName,
                    Sys_FormRight._.OprControlEngName, Sys_FormRight._.OprControlChsName, Sys_FormRight._.OprPropertyName,
                    Sys_FormRight._.ModuleID, Sys_FormRight._.ActionCode, Sys_FormRight._.IsDeleted
                };
                rst = this.SelectList <Sys_FormRightResult>(param.PageIndex.GetValueOrDefault(1), param.PageSize.GetValueOrDefault(20), lstField, where, Sys_FormRight._.NameSpace.Desc);
                #endregion
                #region 单据对应模块名称
                if (rst != null && rst.ResultList != null)
                {
                    Sys_ModuleBLL moduleBll   = new Sys_ModuleBLL();
                    int?[]        arrModuleID = rst.ResultList.Select(a => a.ModuleID).Distinct().ToArray();
                    moduleBll.SessionInfo = this.SessionInfo;
                    List <Sys_ModuleResult> moduleList = new List <Sys_ModuleResult>();
                    if (arrModuleID.Length > 0)
                    {
                        moduleList = moduleBll.GetPageList(new Sys_ModuleParam()
                        {
                            PageIndex = 1, PageSize = arrModuleID.Length, ModuleIDs = arrModuleID
                        }).ResultList;
                    }
                    Sys_ModuleResult findModule = new Sys_ModuleResult();
                    foreach (Sys_FormRightResult info in rst.ResultList)
                    {
                        findModule = moduleList.Find(a => a.ModuleID == info.ModuleID);
                        if (findModule != null)
                        {
                            info.ModuleName = findModule == null ? "" : findModule.ModuleName;
                        }
                    }
                }
                #endregion
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
            }
            return(rst);
        }
Esempio n. 3
0
        /// <summary>
        /// 获取员工的操作权限
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public PageList <Sys_EmpRightResult> GetPageList(Sys_EmpRightParam param)
        {
            this.CheckSession();
            PageList <Sys_EmpRightResult> pagelist = new PageList <Sys_EmpRightResult>();

            try
            {
                WhereClip whereClip = WhereClip.All;//
                if (param.IsNoAction)
                {
                    whereClip = whereClip && Sys_EmpRight._.ActionCode.IsNull();
                }
                else
                {
                    whereClip = GetWhereClip(param);
                }
                if (param.MenuID > 0)
                {
                    whereClip = whereClip && Sys_Module._.MenuID.At("b") == param.MenuID;
                }
                if (!string.IsNullOrEmpty(param.ModuleName))
                {
                    whereClip = whereClip && Sys_Module._.ModuleName.At("b").Like("%" + param.ModuleName + "%");
                }

                List <Field> fiels = new List <Field>()
                {
                    Sys_EmpRight._.EmpRightID,
                    Sys_EmpRight._.EmpID,
                    Sys_Module._.ModuleID.At("b"),
                    Sys_EmpRight._.ActionCode,
                    Sys_Module._.ModuleName.At("b"),
                    Sys_Module._.ModuleCode.At("b"),
                    Sys_Module._.MenuID.At("b"),
                    Sys_Module._.ActionCode.At("b").As("BaseActionCode")
                };
                WhereClip onWhereClip = Sys_EmpRight._.ModuleID == Sys_Module._.ModuleID.At("b");
                pagelist = this.SelectList <Sys_EmpRightResult, Sys_Module>(JoinType.RightJoin, onWhereClip, param.PageIndex.GetValueOrDefault(1), param.PageSize.GetValueOrDefault(50), fiels, whereClip, Sys_Module._.ModuleCode.At("b").Asc, null, null);
                pagelist.ResultJoinList.Columns.Add("RightName");
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
                throw exp;
            }
            return(pagelist);
        }
Esempio n. 4
0
        public WCFAddUpdateResult AddOrUpdate(SYS_CredentialCodeRuleResult param)
        {
            this.CheckSession();
            int affect             = 0;
            WCFAddUpdateResult ret = new WCFAddUpdateResult();

            try
            {
                #region 判断
                if (param.TableName.ToStringHasNull().Trim() == "")
                {
                    throw new WarnException("请指定表名!");
                }
                if (param.CodeFieldName.ToStringHasNull().Trim() == "")
                {
                    throw new WarnException("请指定单据名称");
                }
                if (param.CodeFieldName.ToStringHasNull().Trim() == "")
                {
                    throw new WarnException("请指定编号字段!");
                }
                if (param.ModuleName.ToStringHasNull().Trim() == "")
                {
                    throw new WarnException("请指定模块名称!");
                }
                if (param.RuleID > 0)
                {
                    WhereClip where = SYS_CredentialCodeRuleResult._.RuleID == param.RuleID;
                    affect          = this.Update <SYS_CredentialCodeRuleResult>(param, where);
                    ret.Key         = param.RuleID;
                }
                else
                {
                    Sys_CodeRulerBLL codeRulerBll = new Sys_CodeRulerBLL();
                    codeRulerBll.SessionInfo = this.SessionInfo;
                    affect  = this.Insert <SYS_CredentialCodeRuleResult>(param);
                    ret.Key = this.Select <SYS_CredentialCodeRuleResult>(SYS_CredentialCodeRule._.TableName == param.TableName && SYS_CredentialCodeRule._.CodeFieldName == param.CodeFieldName && SYS_CredentialCodeRule._.IsDeleted == false).RuleID;
                }
                #endregion
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
            }

            return(ret);
        }
Esempio n. 5
0
        public WCFAddUpdateResult AddOrUpdate(Sys_FormRightResult param)
        {
            this.CheckSession();
            int affect             = 0;
            WCFAddUpdateResult ret = new WCFAddUpdateResult();

            try
            {
                #region 判断
                if (param.FormEngName.ToStringHasNull().Trim() == "")
                {
                    throw new WarnException("请指定窗体英文名!");
                }
                //if (param.UserControlEngName.ToStringHasNull().Trim() == "") throw new WarnException("请指定用户控件英文名!");
                if (param.OprControlEngName.ToStringHasNull().Trim() == "")
                {
                    throw new WarnException("请指定操作控件英文名!");
                }
                if (param.ActionCode.ToStringHasNull().Trim() == "")
                {
                    throw new WarnException("请指定对应权限!");
                }
                if (param.FormRightID > 0)
                {
                    WhereClip where = Sys_FormRightResult._.FormRightID == param.FormRightID;
                    affect          = this.Update <Sys_FormRightResult>(param, where);
                    ret.Key         = param.FormRightID;
                }
                else
                {
                    Sys_FormRightBLL formrightbll = new Sys_FormRightBLL();
                    formrightbll.SessionInfo = this.SessionInfo;
                    param.IsDeleted          = false;
                    affect  = this.Insert <Sys_FormRightResult>(param);
                    ret.Key = this.Select <Sys_FormRightResult>(Sys_FormRight._.NameSpace == param.NameSpace && Sys_FormRight._.OprControlEngName == param.OprControlEngName && Sys_FormRight._.IsDeleted == false).FormRightID;
                }
                #endregion
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
            }

            return(ret);
        }
Esempio n. 6
0
        public PageList <SYS_DictItemLineResult> GetDictItemLineList(SYS_DictItemLineParam param)
        {
            this.CheckSession();
            PageList <SYS_DictItemLineResult> ret = new PageList <SYS_DictItemLineResult>();

            try
            {
                WhereClip whereClip = SYS_DictItem._.IsDeleted.At("b") == 0 && SYS_DictItemLine._.IsDeleted == 0;
                if (param.ItemName != null)
                {
                    whereClip = whereClip && SYS_DictItem._.ItemName.At("b") == param.ItemName;
                }
                if (param.ItemCode != null)
                {
                    whereClip = whereClip && SYS_DictItem._.ItemCode.At("b") == param.ItemCode;
                }
                if (param.ItemCodes != null)
                {
                    whereClip = whereClip && SYS_DictItem._.ItemCode.At("b").In(param.ItemCodes);
                }
                if (param.NoItemValue != null)
                {
                    whereClip = whereClip && !SYS_DictItemLine._.ItemValue2.In(param.NoItemValue);
                }
                WhereClip    onWhereClip = SYS_DictItem._.DictItemID.At("b") == SYS_DictItemLine._.DictItemID;
                List <Field> field       = new List <Field> {
                    SYS_DictItemLine._.DictItemLineID,
                    SYS_DictItemLine._.ItemValue,
                    SYS_DictItemLine._.ItemValue2,
                    SYS_DictItem._.DictItemID.At("b"),
                    SYS_DictItem._.ItemCode.At("b"),
                    SYS_DictItem._.ItemName.At("b")
                };
                ret = this.SelectList <SYS_DictItemLineResult, SYS_DictItem>(JoinType.InnerJoin, onWhereClip,
                                                                             param.PageIndex.GetValueOrDefault(1), param.PageSize.GetValueOrDefault(50), field, whereClip, null, null, null);
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
                throw exp;
            }
            return(ret);
        }
Esempio n. 7
0
        /// <summary>
        ///     删除角色
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public WCFAddUpdateResult DelInfo(Sys_RoleParam param)
        {
            CheckSession();
            var ret = new WCFAddUpdateResult();

            try
            {
                #region 判断

                if (param.RoleID.ToInt32() <= 0)
                {
                    throw new WarnException("请指定要删除的模块ID!");
                }
                if (this.Count <Sys_EmpDataRight>(Sys_EmpDataRight._.IsDeleted == false && Sys_EmpDataRight._.RoleIDs.Like("%," + param.RoleID.ToStringHasNull() + ",%")) >= 0)
                {
                    throw new WarnException("存在业务引用,不允许删除!");
                }
                if (this.Count <Sys_RoleRight>(Sys_RoleRight._.RoleID == param.RoleID && Sys_RoleRight._.IsDeleted == false) >= 0)
                {
                    throw new WarnException("存在业务引用,不允许删除!");
                }
                #endregion

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

                #region 设置返回值

                ret.Key = affect;

                #endregion
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (Exception exp)
            {
                LogInfoBLL.WriteLog(SessionInfo, exp);
                throw exp;
            }
            return(ret);
        }
Esempio n. 8
0
        /// <summary>
        /// 添加和新增修改
        /// </summary>
        /// <param name="param">新增或修改的实体</param>
        /// <returns></returns>
        public WCFAddUpdateResult AddOrUpdate(Sys_EmpDataRightResult param)
        {
            this.CheckSession();
            WCFAddUpdateResult ret = new WCFAddUpdateResult();

            try
            {
                int affect = 0;
                #region 判断


                #endregion

                #region 系统默认值
                if (param.SysEmpRoleID != 0)
                {
                    WhereClip where = Sys_EmpDataRight._.SysEmpRoleID == param.SysEmpRoleID;
                    affect          = this.Update <Sys_EmpDataRightResult>(param, where);
                }
                else
                {
                    param.IsDeleted  = false;
                    param.GCompanyID = this.SessionInfo.CompanyID;
                    affect           = this.Insert <Sys_EmpDataRightResult>(param);
                    param            = this.Select <Sys_EmpDataRightResult>(new List <Field>()
                    {
                        Sys_EmpDataRight._.SysEmpRoleID
                    }, Sys_EmpDataRight._.EmpID == param.EmpID);
                }
                #region 设置返回值
                ret.Key = param.SysEmpRoleID.ToInt32();
                #endregion

                #endregion
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
                throw exp;
            }
            return(ret);
        }
Esempio n. 9
0
        public List <SYS_DictItemLineResult> GetList(SYS_DictItemLineParam param)
        {
            this.CheckSession();
            List <SYS_DictItemLineResult> ret = new List <SYS_DictItemLineResult>();

            try
            {
                WhereClip whereClip = GetWhereClip(param);
                ret = this.SelectList <SYS_DictItemLineResult>(whereClip, SYS_DictItemLine._.DictItemLineID.Asc);
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
            }
            return(ret);
        }
Esempio n. 10
0
        public List <Sys_MenuResult> GetMenuTree(Sys_MenuParam param)
        {
            this.CheckSession();
            List <Sys_MenuResult> ret = new List <Sys_MenuResult>();

            try
            {
                WhereClip whereClip = GetWhereClip(param);
                ret = this.SelectList <Sys_MenuResult>(whereClip, Sys_MenuResult._.MenuCode.Asc);
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
            }
            return(ret);
        }
Esempio n. 11
0
        public List <Sys_RoleResult> GetRolesTree(Sys_RoleParam param)
        {
            CheckSession();
            var ret = new List <Sys_RoleResult>();

            try
            {
                WhereClip whereClip = GetWhereClip(param);
                ret = SelectList <Sys_RoleResult>(whereClip, Sys_Roles._.RoleName.Asc);
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (Exception exp)
            {
                LogInfoBLL.WriteLog(SessionInfo, exp);
                throw exp;
            }
            return(ret);
        }
Esempio n. 12
0
        /// <summary>
        /// 获取集合
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public List <Sys_AttachFilesResult> GetList(Sys_AttachFilesParam param)
        {
            this.CheckSession();
            List <Sys_AttachFilesResult> ret = new List <Sys_AttachFilesResult>();

            try
            {
                WhereClip whereClip = GetWhereClip(param);
                ret = this.SelectList <Sys_AttachFilesResult>(whereClip, Sys_AttachFiles._.CreatedTime.Asc);
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
                throw exp;
            }
            return(ret);
        }
Esempio n. 13
0
        /// <summary>
        /// 删除实体
        /// </summary>
        /// <param name="param">删除条件实体</param>
        /// <returns></returns>
        public WCFAddUpdateResult DelInfo(Sys_MenuParam param)
        {
            this.CheckSession();
            WCFAddUpdateResult ret = new WCFAddUpdateResult();
            int affect             = 0;

            try
            {
                #region 判断
                if (param.MenuID.ToInt32() <= 0)
                {
                    throw new WarnException("请指定要删除的菜单ID!");
                }
                #endregion
                #region 业务关联判断
                if (this.Count <Sys_Module>(Sys_Module._.MenuID == param.MenuID && Sys_Module._.IsDeleted == false) > 0)
                {
                    throw new WarnException("已发生业务关联!");
                }
                #endregion

                WhereClip where = GetWhereClip(param);
                Sys_MenuResult info = new Sys_MenuResult();
                info.IsDeleted = true;
                affect         = this.Update <Sys_MenuResult>(info, where);
                #region 设置返回值
                ret.Key = affect;
                #endregion
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
            }
            return(ret);
        }
Esempio n. 14
0
        public Sys_FormRightResult GetInfo(Sys_FormRightParam param)
        {
            this.CheckSession();
            Sys_FormRightResult rst = new Sys_FormRightResult();

            try
            {
                #region 判断
                if (param.FormRightID <= 0)
                {
                    throw new WarnException("请指定关键字GUID!");
                }
                #endregion
                #region 保存实体
                WhereClip where = Sys_FormRight._.FormRightID == param.FormRightID;
                rst             = this.Select <Sys_FormRightResult>(where);
                if (rst != null)
                {
                    Sys_ModuleBLL moduleBll = new Sys_ModuleBLL();
                    moduleBll.SessionInfo = this.SessionInfo;
                    Sys_ModuleResult moduleRst = moduleBll.GetInfo(new Sys_ModuleParam()
                    {
                        ModuleID = rst.ModuleID.ToInt32()
                    });
                    rst.ModuleName = moduleRst == null ? "" : moduleRst.ModuleName;
                }

                #endregion
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
            }
            return(rst);
        }
Esempio n. 15
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);
        }
Esempio n. 16
0
        /// <summary>
        /// 批量修改和插入
        /// </summary>
        /// <param name="paramList"></param>
        /// <returns></returns>
        public WCFAddUpdateResult UpdateOrInsertList(List <Sys_RoleRightResult> list)
        {
            this.CheckSession();
            WCFAddUpdateResult ret = new WCFAddUpdateResult();

            try
            {
                #region 判断
                if (list.Count <= 0)
                {
                    throw new WarnException("没有需要保存的对象!");
                }
                #endregion
                int affect = 0;
                foreach (Sys_RoleRightResult info in list)
                {
                    info.GCompanyID = this.SessionInfo.CompanyID;
                    if (info.IsDeleted == null)
                    {
                        info.IsDeleted = false;
                    }
                }
                affect += this.BatchInsertOrUpdate <Sys_RoleRightResult>(list);
                this.BatchExecute();
                #region 设置返回值
                ret.Key = affect;
                #endregion
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
            }
            return(ret);
        }
Esempio n. 17
0
        public List <Sys_FormRightResult> GetRightTree(Sys_FormRightParam param)
        {
            this.CheckSession();
            PageList <Sys_FormRightResult> ret = new PageList <Sys_FormRightResult>();
            List <Field> lstField = new List <Field>()
            {
                Sys_FormRight._.NameSpace
            };

            try
            {
                WhereClip whereClip = GetWhereClip(param);
                ret = this.SelectList <Sys_FormRightResult>(param.PageIndex.GetValueOrDefault(1), int.MaxValue, lstField, whereClip, Sys_FormRightResult._.NameSpace.Asc, Sys_FormRight._.NameSpace.Group, null);
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
            }
            return(ret.ResultList);
        }
Esempio n. 18
0
        /// <summary>
        /// 分页集合
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public PageList <Sys_AttachFilesResult> GetPageList(Sys_AttachFilesParam param)
        {
            this.CheckSession();
            PageList <Sys_AttachFilesResult> ret = new PageList <Sys_AttachFilesResult>();

            try
            {
                List <Field> field = new List <Field>()
                {
                    Field.All
                };
                ret = this.SelectList <Sys_AttachFilesResult>(param.PageIndex.GetValueOrDefault(1), param.PageSize.GetValueOrDefault(50), field, GetWhereClip(param), Sys_AttachFiles._.CreatedTime.Desc);
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
                throw exp;
            }
            return(ret);
        }
Esempio n. 19
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);
        }
Esempio n. 20
0
        /// <summary>
        /// 添加和新增修改
        /// </summary>
        /// <param name="param">新增或修改的实体</param>
        /// <returns></returns>
        public WCFAddUpdateResult AddOrUpdate(SYS_DictItemResult param)
        {
            this.CheckSession();
            WCFAddUpdateResult ret = new WCFAddUpdateResult();

            try
            {
                int affect = 0;
                #region 判断
                if (param.ItemCode.Trim() == "")
                {
                    throw new WarnException("请指定数据字典编码!");
                }
                if (param.ItemName.Trim() == "")
                {
                    throw new WarnException("请指定数据字典名称!");
                }
                if (param.DictGroupName.Trim() == "")
                {
                    throw new WarnException("请指定数据字典所属组名!");
                }
                #endregion

                #region 判断重复
                WhereClip whereChk = SYS_DictItem._.IsDeleted == false && SYS_DictItem._.ItemCode == param.ItemCode;
                if (param.DictItemID > 0)
                {
                    whereChk = whereChk & SYS_DictItem._.DictItemID != param.DictItemID;
                }
                int chkNum = this.Count <SYS_DictItemResult>(whereChk);
                if (chkNum > 0)
                {
                    throw new WarnException("存在重复的数据字典编码!");
                }
                #endregion
                #region 系统默认值
                if (param.DictItemID > 0)
                {
                    WhereClip where = SYS_DictItem._.DictItemID == param.DictItemID;
                    affect          = this.Update <SYS_DictItemResult>(param, where);
                }
                else
                {
                    param.GCompanyID = this.SessionInfo.CompanyID;
                    param.IsDeleted  = false;
                    affect           = this.Insert <SYS_DictItemResult>(param);
                    param            = this.Select <SYS_DictItemResult>(new List <Field>()
                    {
                        SYS_DictItemResult._.DictItemID
                    }, SYS_DictItem._.ItemCode == param.ItemCode);
                }
                #region 设置返回值
                ret.Key = param.DictItemID;
                #endregion
                #endregion
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
            }
            return(ret);
        }
Esempio n. 21
0
        /// <summary>
        /// 添加和新增修改
        /// </summary>
        /// <param name="param">新增或修改的实体</param>
        /// <returns></returns>
        public WCFAddUpdateResult AddOrUpdate(Sys_MenuResult param)
        {
            this.CheckSession();
            WCFAddUpdateResult ret = new WCFAddUpdateResult();

            try
            {
                int affect = 0;
                #region 判断
                if (param.MenuCode.ToStringHasNull().Trim() == "")
                {
                    throw new WarnException("请指定菜单编号!");
                }
                if (param.MenuName.ToStringHasNull().Trim() == "")
                {
                    throw new WarnException("请指定菜单名称!");
                }
                if (param.MenuType.ToStringHasNull().Trim() == "")
                {
                    throw new WarnException("请指定菜单类型!");
                }
                if (param.MenuCode.Length % 3 > 0)
                {
                    throw new WarnException("请菜单编号为三位迭加!");
                }
                string parentCode = "";
                if (param.MenuCode.Length > 3)
                {
                    parentCode = param.MenuCode.Substring(0, param.MenuCode.Length - 3);
                }
                if (parentCode != "" && this.Count <Sys_MenuResult>(Sys_Menu._.MenuCode == parentCode) < 0)
                {
                    throw new WarnException("菜单编号的父菜单不存在!");
                }
                #endregion
                #region 判断重复
                WhereClip whereChk = Sys_Menu._.IsDeleted == false && Sys_Menu._.MenuCode == param.MenuCode;
                if (param.MenuID > 0)
                {
                    whereChk = whereChk & Sys_Menu._.MenuID != param.MenuID;
                }
                int chkNum = this.Count <Sys_MenuResult>(whereChk);
                if (chkNum > 0)
                {
                    throw new WarnException("存在重复的菜单编号!");
                }
                #endregion
                #region 系统默认值
                if (param.MenuID > 0)
                {
                    WhereClip where = Sys_Menu._.MenuID == param.MenuID;
                    affect          = this.Update <Sys_MenuResult>(param, where);
                }
                else
                {
                    Sys_MenuResult codeRulerBll = new Sys_MenuResult();
                    param.IsDeleted = false;
                    affect          = this.Insert <Sys_MenuResult>(param);
                    param           = this.Select <Sys_MenuResult>(new List <Field>()
                    {
                        Sys_Menu._.MenuID
                    }, Sys_Menu._.MenuCode == param.MenuCode);
                }
                #region 设置返回值
                ret.Key = param.MenuID;
                #endregion
                #endregion
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
            }
            return(ret);
        }
Esempio n. 22
0
        /// <summary>
        /// 批量上传
        /// </summary>
        /// <param name="paramList"></param>
        /// <returns></returns>
        public List <Sys_AttachFilesResult> UploadAttach(List <Sys_AttachFilesResult> list)
        {
            this.CheckSession();
            WCFAddUpdateResult ret = new WCFAddUpdateResult();

            try
            {
                #region 判断
                if (list.Count <= 0)
                {
                    throw new WarnException("没有需要操作的对象!");
                }
                if (list.Exists(a => a.AttachType == null))
                {
                    throw new  WarnException("没有设置上传的附件类型!");
                }


                #endregion
                AttachType type       = list[0].AttachType;
                string     attachType = string.Empty;

                switch (type)
                {
                case AttachType.Bill:
                    attachType = "Bill";
                    break;

                case AttachType.Pic:
                    attachType = "Pic";
                    break;
                }
                Sys_RootDirMappingBLL mBLL = new Sys_RootDirMappingBLL();
                mBLL.SessionInfo = this.SessionInfo;
                //获取根目录
                Sys_RootDirMappingResult mRst = mBLL.GetInfo(new Sys_RootDirMappingParam()
                {
                    AttachType = attachType, IsEffect = true
                });
                if (mRst == null)
                {
                    throw new WarnException("根目录映射表没有有效的设置信息!");
                }
                mRst.PhysicalRootPath = mRst.PhysicalRootPath.Replace("{Company}", this.SessionInfo.CompanyID.ToStringHasNull());
                //设置文件目录
                string folderPath          = mRst.PhysicalRootPath + @"\" + DateTime.Now.Year + @"\" + DateTime.Now.ToString("yyyyMMdd");
                string thumbnailFolderPath = string.Empty;
                if (!Directory.Exists(folderPath))
                {
                    Directory.CreateDirectory(folderPath);
                }
                ////如果有图片才形成压缩图片的存放目录
                //if (list.Exists(a => ".bmp.png.jpg.gif.jpeg.BMP.PNG.JPG.GIF.JPEG".Contains(a.FileSuffix)))
                //{
                //    //设置压缩图片的存放目录
                //     thumbnailFolderPath= folderPath + @"\Thumbnail";
                //    if (!Directory.Exists(thumbnailFolderPath))
                //    {
                //        Directory.CreateDirectory(thumbnailFolderPath);
                //    }
                //}
                foreach (Sys_AttachFilesResult rst in list)
                {
                    rst.FileName = DateTime.Now.ToString("yyyyMMddHHmmssms") + new Random().Next(10000, 99999);
                    rst.FilePath = folderPath + @"\" + rst.FileName + rst.FileSuffix;
                    using (FileStream fs = new FileStream(rst.FilePath, FileMode.CreateNew))
                    {
                        fs.Write(rst.File, 0, rst.FileSize.ToInt32());
                        fs.Close();
                    }

                    if (rst.TBNFile != null)
                    {
                        rst.TBNFileName = rst.FileName + "_TBN" + ".JPG";;
                        rst.TBNFilePath = folderPath + @"\" + rst.TBNFileName;
                        using (FileStream fs = new FileStream(rst.TBNFilePath, FileMode.CreateNew))
                        {
                            fs.Write(rst.TBNFile, 0, rst.TBNFile.Length.ToInt32());
                            fs.Close();
                        }
                    }
                }
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
                throw exp;
            }
            return(list);
        }
Esempio n. 23
0
        public List <Sys_MenuResult> GetEmpMenuTree(Sys_MenuParam param)
        {
            this.CheckSession();
            List <Sys_MenuResult> allRet          = new List <Sys_MenuResult>();
            List <Sys_MenuResult> ret             = new List <Sys_MenuResult>();
            List <int?>           arrHasModuleIDs = new List <int?>();

            try
            {
                //Sys_Module._.OrderSeq.At("b"), Sys_Module._.ActionCode.At("b"), Sys_Module._.ModuleCode.At("b"), Sys_Module._.ModuleName.At("b"), Sys_Module._.TargetForm.At("b"), Sys_Module._.ModuleID.At("b")
                #region 获取对应员工角色与权限
                List <Sys_RoleRight> roleRightList = new List <Sys_RoleRight>();
                Sys_EmpDataRight     formRight     = this.Select <Sys_EmpDataRight>(Sys_EmpDataRight._.EmpID == this.SessionInfo.UserID && Sys_EmpDataRight._.IsDeleted == false && Sys_EmpDataRight._.GCompanyID == this.SessionInfo.CompanyID);
                if (formRight != null)
                {
                    int?[] arrRightID = formRight.RoleIDs.Split(',').Where(a => a.ToStringHasNull().Trim() != "").Select(a => (int?)a.ToInt32()).ToArray();
                    if (arrRightID.Length > 0)
                    {
                        roleRightList = this.SelectList <Sys_RoleRight>(Sys_RoleRight._.RoleID.In(arrRightID) && Sys_RoleRight._.IsDeleted == false);
                        arrHasModuleIDs.AddRange(roleRightList.Select(a => a.ModuleID).Distinct().ToList());
                    }
                }
                #endregion
                #region 获取对应员工个人权限
                List <Sys_EmpRight> lstEmpRight = new List <Sys_EmpRight>();
                lstEmpRight = this.SelectList <Sys_EmpRight>(Sys_EmpRight._.EmpID == this.SessionInfo.UserID && Sys_EmpRight._.IsDeleted == false);
                arrHasModuleIDs.AddRange(lstEmpRight.Select(a => a.ModuleID).Distinct().ToList());
                #endregion
                #region 获取菜单列表
                List <Sys_Module> lstModule   = new List <Sys_Module>();
                WhereClip         whereModule = Sys_Module._.IsDeleted == false;
                if (lstEmpRight.Count > 0)
                {
                    whereModule = whereModule && Sys_Module._.ModuleID.In(lstEmpRight.ToArray());
                }
                lstModule = this.SelectList <Sys_Module>(whereModule);
                List <string> lstEmpMdlCode = lstModule.Where(a => a.ModuleCode.ToStringHasNull() != "").Select(a => a.ModuleCode.ToStringHasNull().Trim()).ToList();
                ret = this.SelectList <Sys_MenuResult>(Sys_Menu._.IsDeleted == false, Sys_Menu._.MenuCode.Asc);
                ret = ret.Where(a => !lstEmpMdlCode.Contains(a.MenuCode)).ToList();
                foreach (Sys_Module info in lstModule)
                {
                    ret.Add(new Sys_MenuResult()
                    {
                        MenuID     = info.ModuleID * -1,
                        MenuCode   = info.ModuleCode,
                        MenuName   = info.ModuleName,
                        TargetForm = info.TargetForm,
                        OrderSeq   = info.OrderSeq,
                        MenuType   = "Leaf"
                    });
                }
                #endregion
                #region old code
                //GroupByClip groupByClip = new GroupByClip("b.OrderSeq,b.ActionCode,b.ModuleCode,b.ModuleName,b.TargetForm,b.ModuleID");
                //DataTable lstEmpModeule = this.SelectList<Sys_EmpRight, Sys_Module>(JoinType.InnerJoin
                //                , Sys_EmpRight._.ModuleID == Sys_Module._.ModuleID.At("b")
                //                  , 1, int.MaxValue
                //                  , new List<Field>() {Sys_Module._.OrderSeq.At("b"), Sys_Module._.ActionCode.At("b"), Sys_Module._.ModuleCode.At("b"), Sys_Module._.ModuleName.At("b"), Sys_Module._.TargetForm.At("b"), Sys_Module._.ModuleID.At("b") },
                //                  Sys_EmpRight._.EmpID == this.SessionInfo.UserID && Sys_EmpRight._.IsDeleted == false
                //                  , Sys_Module._.ModuleCode.At("b").Asc, groupByClip, null).ResultJoinList;
                //List<string> lstEmpMdlCode = lstEmpModeule.Select("ModuleCode<>''").Select(a => a["ModuleCode"].ToStringHasNull()).ToList();
                //ret = this.SelectList<Sys_MenuResult>(Sys_Menu._.IsDeleted == false, Sys_Menu._.MenuCode.Asc);
                //ret = ret.Where(a => !lstEmpMdlCode.Contains(a.MenuCode)).ToList();
                //#region 将模块添加至菜单集合
                //foreach (DataRow row in lstEmpModeule.Rows)
                //{
                //    ret.Add(new Sys_MenuResult()
                //    {
                //        MenuID = row["ModuleID"].ToInt32() * -1,
                //        MenuCode = row["ModuleCode"].ToStringHasNull(),
                //        MenuName = row["ModuleName"].ToStringHasNull(),
                //        TargetForm = row["TargetForm"].ToStringHasNull(),
                //        OrderSeq = row["OrderSeq"].ToInt32(),
                //        MenuType = "Leaf"
                //    });
                //}
                //#endregion
                #endregion
                #region  指定的次序号重新排序
                List <Sys_MenuResult> newRet = new List <Sys_MenuResult>();
                int atIdx = 0;
                for (int i = 3; i <= 3 * 5; i = i + 3)
                {
                    newRet = ret.Where(a => a.MenuCode.Length == i).OrderBy(a => a.OrderSeq).ToList();
                    if (i > 3)
                    {
                        foreach (Sys_MenuResult info in newRet)
                        {
                            atIdx = allRet.FindIndex(a => a.MenuCode.Length == i - 3 && info.MenuCode.StartsWith(a.MenuCode));
                            if (atIdx < 0)
                            {
                                continue;
                            }
                            allRet.Insert(atIdx + 1, info);
                        }
                    }
                    else
                    {
                        allRet = ret.Where(a => a.MenuCode.Length == i).OrderBy(a => a.OrderSeq).ToList();
                    }
                }
                #endregion
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
            }
            return(allRet);
        }
Esempio n. 24
0
        /// <summary>
        /// 添加和新增修改
        /// </summary>
        /// <param name="param">新增或修改的实体</param>
        /// <returns></returns>
        public WCFAddUpdateResult AddOrUpdate(SYS_CurrencyResult param)
        {
            this.CheckSession();
            WCFAddUpdateResult ret = new WCFAddUpdateResult();

            try
            {
                int affect = 0;
                #region 判断

                if (string.IsNullOrEmpty(param.CurrencyCode))
                {
                    throw new WarnException("请指定币种!");
                }
                if (param.RateDate == null)
                {
                    throw new WarnException("请选择汇率启用日期!");
                }
                if (param.ExchangeRate == null)
                {
                    throw new WarnException("请填写对应的汇率!");
                }

                #endregion

                #region 系统默认值
                if (param.RateTaxID > 0)
                {
                    WhereClip where      = SYS_Currency._.RateTaxID == param.RateTaxID;
                    param.UpdatedEmpID   = this.SessionInfo.UserID;
                    param.UpdatedEmpName = this.SessionInfo.UserName;
                    param.UpdatedTime    = DateTime.Now;
                    affect = this.Update <SYS_CurrencyResult>(param, where);
                }
                else
                {
                    param.RateTaxGuid    = new Guid();
                    param.GCompanyID     = this.SessionInfo.CompanyID;
                    param.IsDeleted      = false;
                    param.CreatedEmpID   = this.SessionInfo.UserID;
                    param.CreatedEmpName = this.SessionInfo.UserName;
                    param.CreatedTime    = DateTime.Now;
                    affect = this.Insert <SYS_CurrencyResult>(param);
                    param  = this.Select <SYS_CurrencyResult>(new List <Field>()
                    {
                        SYS_Currency._.All
                    }, SYS_Currency._.RateTaxGuid == param.RateTaxGuid);
                }

                #region 设置返回值

                ret.Key            = param.RateTaxID;
                ret.CreatedTime    = param.CreatedTime;
                ret.CreatedEmpID   = param.CreatedEmpID;
                ret.CreatedEmpName = param.CreatedEmpName;
                ret.UpdatedEmpID   = param.UpdatedEmpID;
                ret.UpdatedEmpName = param.UpdatedEmpName;
                ret.UpdatedTime    = param.UpdatedTime;
                #endregion
                #endregion
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
                throw exp;
            }
            return(ret);
        }
Esempio n. 25
0
        /// <summary>
        /// 添加和新增修改
        /// </summary>
        /// <param name="param">新增或修改的实体</param>
        /// <returns></returns>
        public WCFAddUpdateResult AddOrUpdate(Sys_RootDirMappingResult param)
        {
            this.CheckSession();
            WCFAddUpdateResult ret = new WCFAddUpdateResult();

            try
            {
                int affect = 0;
                #region 判断
                if (string.IsNullOrEmpty(param.AttachType))
                {
                    throw new WarnException("请指定单据类型!");
                }
                if (string.IsNullOrEmpty(param.PhysicalRootPath))
                {
                    throw new WarnException("请指定物理根目录路径!");
                }
                if (string.IsNullOrEmpty(param.MappingIdentifier))
                {
                    throw new WarnException("请指定映射标示符!");
                }
                #endregion

                #region
                if (param.MGuid != null)
                {
                    WhereClip where      = Sys_RootDirMapping._.MGuid == param.MGuid;
                    param.UpdatedEmpID   = this.SessionInfo.UserID;
                    param.UpdatedEmpName = this.SessionInfo.UserName;
                    param.UpdatedTime    = DateTime.Now;
                    affect = this.Update <Sys_RootDirMappingResult>(param, where);
                    List <Sys_RootDirMappingResult> rstList = this.SelectList <Sys_RootDirMappingResult>(Sys_RootDirMapping._.MGuid != param.MGuid &&
                                                                                                         Sys_RootDirMapping._.AttachType == param.AttachType &&
                                                                                                         Sys_RootDirMapping._.GCompanyID == this.SessionInfo.CompanyID);
                    if (rstList != null)
                    {
                        rstList.ForEach(a => { a.IsEffect = false; });
                    }
                    this.BatchInsertOrUpdate <Sys_RootDirMappingResult>(rstList);
                }
                else
                {
                    param.MGuid      = Guid.NewGuid();
                    param.GCompanyID = this.SessionInfo.CompanyID;
                    param.IsDeleted  = false;

                    param.CreatedEmpID   = this.SessionInfo.UserID;
                    param.CreatedEmpName = this.SessionInfo.UserName;
                    param.CreatedTime    = DateTime.Now;

                    affect = this.Insert <Sys_RootDirMappingResult>(param);
                    param  = this.Select <Sys_RootDirMappingResult>(new List <Field>()
                    {
                        Sys_RootDirMapping._.All
                    }, Sys_RootDirMapping._.MGuid == param.MGuid);
                }


                #region 设置返回值
                ret.Key            = param.MID;
                ret.KeyGuid        = param.MGuid;
                ret.CreatedTime    = param.CreatedTime;
                ret.CreatedEmpID   = param.CreatedEmpID;
                ret.CreatedEmpName = param.CreatedEmpName;
                ret.UpdatedEmpID   = param.UpdatedEmpID;
                ret.UpdatedEmpName = param.UpdatedEmpName;
                ret.UpdatedTime    = param.UpdatedTime;
                #endregion
                #endregion
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
                throw exp;
            }
            return(ret);
        }
Esempio n. 26
0
        /// <summary>
        /// 绑定下拉框使用
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public List <SYS_DictItemLineResult> GetListByCode(SYS_DictItemLineParam param)
        {
            this.CheckSession();
            List <SYS_DictItemLineResult> ret = new List <SYS_DictItemLineResult>();

            try
            {
                List <Field> fields = new List <Field> ()
                {
                    SYS_DictItem._.DictItemID,
                    SYS_DictItem._.ItemCode,
                    SYS_DictItem._.ItemName,
                    SYS_DictItem._.ValueType
                };
                WhereClip clip = SYS_DictItem._.ItemCode.In(param.ItemCodes) && SYS_DictItem._.IsDeleted == 0;
                List <SYS_DictItemResult> dictItemResultList = this.SelectList <SYS_DictItemResult>(fields, clip, SYS_DictItem._.ItemCode.Desc);
                int[] dictItemIDArr = dictItemResultList.Select(a => a.DictItemID).ToArray();
                if (dictItemIDArr != null && dictItemIDArr.Length > 0)
                {
                    WhereClip    clip2   = SYS_DictItemLine._.DictItemID.In(dictItemIDArr);
                    List <Field> fields2 = new List <Field>()
                    {
                        SYS_DictItemLine._.DictItemID,
                        SYS_DictItemLine._.DictItemLineID,
                        SYS_DictItemLine._.ItemValue,
                        SYS_DictItemLine._.ItemValue2
                    };
                    ret = this.SelectList <SYS_DictItemLineResult>(fields2, clip2, SYS_DictItemLine._.DictItemLineID.Asc);
                    foreach (SYS_DictItemLineResult itemLineResult in ret)
                    {
                        SYS_DictItemResult itemResult = dictItemResultList.FirstOrDefault(a => a.DictItemID == itemLineResult.DictItemID);
                        itemLineResult.ItemCode = itemResult.ItemCode;
                        switch (itemResult.ValueType)
                        {
                        case "Boolean":
                            itemLineResult.ValueType = DataValueType.Boolean;
                            break;

                        case "Decimal":
                            itemLineResult.ValueType = DataValueType.Decimal;
                            break;

                        case "Int32":
                            itemLineResult.ValueType = DataValueType.Int32;
                            break;

                        case "JSON":
                            itemLineResult.ValueType = DataValueType.JSON;
                            break;

                        case "String":
                            itemLineResult.ValueType = DataValueType.String;
                            break;

                        case "XML":
                            itemLineResult.ValueType = DataValueType.XML;
                            break;
                        }
                    }
                }
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
            }
            return(ret);
        }
Esempio n. 27
0
        /// <summary>
        /// 添加和新增修改
        /// </summary>
        /// <param name="param">新增或修改的实体</param>
        /// <returns></returns>
        public WCFAddUpdateResult AddOrUpdate(Sys_ModuleResult param)
        {
            this.CheckSession();
            WCFAddUpdateResult ret = new WCFAddUpdateResult();

            try
            {
                int affect = 0;
                #region 判断
                if (param.ModuleName.ToStringHasNull().Trim() == "")
                {
                    throw new WarnException("请指定菜单名称!");
                }
                if (param.MenuID.ToInt32() < 0)
                {
                    throw new WarnException("请指定所属菜单!");
                }
                if (param.TargetForm.ToStringHasNull().Trim() == "")
                {
                    throw new WarnException("请指定所属目标体窗!");
                }

                string         parentCode = "";
                Sys_MenuResult menuRst    = new Sys_MenuResult();
                menuRst = this.Select <Sys_MenuResult>(Sys_Menu._.MenuID == param.MenuID);
                if (param.MenuID > 0 && (menuRst == null || menuRst.MenuCode == ""))
                {
                    throw new WarnException("菜单编号的所属菜单不存在!");
                }
                parentCode = menuRst.MenuCode;
                #endregion
                #region 生成模块编号
                int maxModuleNum = 1;
                maxModuleNum = this.Count <Sys_ModuleResult>(Sys_Module._.MenuID == param.MenuID) + 1;
                #endregion
                #region 判断重复
                WhereClip whereChk = Sys_Module._.IsDeleted == false && Sys_Module._.ModuleName == param.ModuleName;
                if (param.ModuleID > 0)
                {
                    whereChk = whereChk & Sys_Module._.ModuleID != param.ModuleID;
                }
                int chkNum = this.Count <Sys_ModuleResult>(whereChk);
                if (chkNum > 0)
                {
                    throw new WarnException("存在重复的模块名称!");
                }
                #endregion
                #region 系统默认值
                if (param.ModuleID > 0)
                {
                    if (!param.ModuleCode.StartsWith(parentCode))
                    {
                        param.ModuleCode = parentCode + maxModuleNum.ToString().PadLeft(3, '0');
                    }
                    WhereClip where = Sys_Module._.ModuleID == param.ModuleID;
                    affect          = this.Update <Sys_ModuleResult>(param, where);
                }
                else
                {
                    Sys_ModuleResult codeRulerBll = new Sys_ModuleResult();
                    param.ModuleCode = parentCode + maxModuleNum.ToString().PadLeft(3, '0');
                    param.IsDeleted  = false;
                    affect           = this.Insert <Sys_ModuleResult>(param);
                    param            = this.Select <Sys_ModuleResult>(new List <Field>()
                    {
                        Sys_Module._.ModuleID
                    }, Sys_Module._.ModuleCode == param.ModuleCode);
                }
                #region 设置返回值
                ret.Key = param.ModuleID;
                #endregion
                #endregion
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
            }
            return(ret);
        }
Esempio n. 28
0
        /// <summary>
        /// 获取集合
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public List <SYS_CurrencyResult> GetList(SYS_CurrencyParam param)
        {
            this.CheckSession();
            List <SYS_CurrencyResult> ret = new List <SYS_CurrencyResult>();

            try
            {
                #region 取最近一条汇率记录
                if (param.GetLastRate.ToBooleanHasNull())
                {
                    #region 获取条件下的最靠近的汇率
                    #region 获取条件下的最靠近的汇率的条件日期列表
                    WhereClip whereClip = GetWhereClip(param);
                    List <SYS_CurrencyResult> lastRst = new List <SYS_CurrencyResult>();
                    List <Field> lstField             = new List <Field>()
                    {
                        SYS_Currency._.CurrencyCode,
                        SYS_Currency._.RateDate.Min().As("RateDate"),
                    };
                    PageList <SYS_CurrencyResult> pageRst = this.SelectList <SYS_CurrencyResult>(1, 500, lstField
                                                                                                 , whereClip, null
                                                                                                 , new GroupByClip("CurrencyCode"), null);
                    WhereClip whereClipLast   = SYS_Currency._.IsDeleted == false;
                    WhereClip whereClipLastEx = WhereClip.All;
                    #endregion
                    #region 生成取值条件
                    int countStep = -1;
                    if (pageRst != null)
                    {
                        foreach (SYS_CurrencyResult info in pageRst.ResultList)
                        {
                            if (countStep == -1)
                            {
                                whereClipLastEx = (whereClipLastEx && SYS_Currency._.CurrencyCode == info.CurrencyCode && SYS_Currency._.RateDate == info.RateDate);
                            }
                            else
                            {
                                whereClipLastEx = whereClipLastEx || (SYS_Currency._.CurrencyCode == info.CurrencyCode && SYS_Currency._.RateDate == info.RateDate);
                            }
                            countStep++;
                        }
                    }
                    #endregion
                    #region 条件步骤
                    if (countStep >= 0)
                    {
                        whereClipLast = whereClipLast && (whereClipLastEx);
                        lastRst       = this.SelectList <SYS_CurrencyResult>(whereClipLast);
                        foreach (SYS_CurrencyResult info in lastRst)
                        {
                            if (!ret.Exists(a => a.CurrencyCode == info.CurrencyCode && a.RateDate == info.RateDate))
                            {
                                ret.Add(info);
                            }
                        }
                    }
                    #endregion
                    #endregion

                    #region 获取最近条件
                    #region 获取最后一次日期条件
                    lastRst  = new List <SYS_CurrencyResult>();
                    lstField = new List <Field>()
                    {
                        SYS_Currency._.CurrencyCode,
                        SYS_Currency._.RateDate.Max().As("RateDate"),
                    };
                    pageRst = this.SelectList <SYS_CurrencyResult>(1, 500, lstField
                                                                   , SYS_Currency._.IsDeleted == false, null
                                                                   , new GroupByClip("CurrencyCode"), null);
                    whereClipLast   = SYS_Currency._.IsDeleted == false;
                    whereClipLastEx = WhereClip.All;
                    #endregion
                    #region 组合最后一次日期条件
                    countStep = -1;
                    if (pageRst != null)
                    {
                        foreach (SYS_CurrencyResult info in pageRst.ResultList)
                        {
                            if (countStep == -1)
                            {
                                whereClipLastEx = (whereClipLastEx && SYS_Currency._.CurrencyCode == info.CurrencyCode && SYS_Currency._.RateDate == info.RateDate);
                            }
                            else
                            {
                                whereClipLastEx = whereClipLastEx || (SYS_Currency._.CurrencyCode == info.CurrencyCode && SYS_Currency._.RateDate == info.RateDate);
                            }
                            countStep++;
                        }
                    }
                    if (countStep >= 0)
                    {
                        whereClipLast = whereClipLast && (whereClipLastEx);
                    }
                    #endregion
                    #endregion
                    #region 获取最近条件,将结果进行组合,加入返回值
                    lastRst = this.SelectList <SYS_CurrencyResult>(whereClipLast);
                    foreach (SYS_CurrencyResult info in lastRst)
                    {
                        if (!ret.Exists(a => a.CurrencyCode == info.CurrencyCode && a.RateDate == info.RateDate))
                        {
                            ret.Add(info);
                        }
                    }
                    #endregion
                }
                else
                {
                    WhereClip whereClip = GetWhereClip(param);
                    ret = this.SelectList <SYS_CurrencyResult>(whereClip, SYS_Currency._.CreatedTime.Asc);
                }
                #endregion
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
                throw exp;
            }
            return(ret);
        }