コード例 #1
0
ファイル: StudentBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Primo
        /// 时间:2014.07.09
        /// 描述:获取学员列表
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="branchId"></param>
        /// <param name="productLevelId"></param>
        /// <param name="searchKeyWord"></param>
        /// <returns></returns>
        public static List<GetStudentServiceUser_Result> GetStudentList(int? userId, int? branchId, int? productLevelId, int? searchKey, string searchKeyWord)
        {
            var Db = new EmeEntities(dbRead);

            var query = Db.GetStudentServiceUser(branchId, productLevelId).ToList();

            if (userId.HasValue && userId.Value != 0)
            {
                query = query.Where(a => a.SaId == userId).ToList();
            }

            if (searchKey.HasValue && !string.IsNullOrEmpty(searchKeyWord))
            {
                if (searchKey.Value == ConvertEnum.SearchStudentKeyForKeyWord)
                {
                    query = query.Where(a => a.CName.Contains(searchKeyWord)
                        || a.EName.Contains(searchKeyWord)
                        || a.Email.Contains(searchKeyWord)
                        || a.Mobile.Contains(searchKeyWord)
                        || a.UserName.Equals(searchKeyWord, StringComparison.CurrentCultureIgnoreCase)).ToList();

                }
                else if (searchKey.Value == ConvertEnum.SearchStudentKeyForUserName)
                {
                    query = query.Where(a => a.CName.Contains(searchKeyWord) || a.EName.Contains(searchKeyWord)).ToList();
                }
                else if (searchKey.Value == ConvertEnum.SearchStudentKeyForSA)
                {
                    query = query.Where(a => a.SaId.HasValue && a.SaName.Contains(searchKeyWord)).ToList();
                }
                else if (searchKey.Value == ConvertEnum.SearchStudentKeyForCC)
                {
                    query = query.Where(a => a.CcId.HasValue && a.CcName.Contains(searchKeyWord)).ToList();
                }
                else if (searchKey.Value == ConvertEnum.SearchStudentKeyForAccount)
                {
                    query = query.Where(a => a.UserName.Equals(searchKeyWord, StringComparison.CurrentCultureIgnoreCase)).ToList();
                }
            }
            return query.Distinct().ToList();
        }