public Model.PageModel <Model.CAS_MAIN_INFO> PageSearchCasList(QueryModel.CAS_MAIN_INFOQuery casQuery)
        {
            int num = 0;

            try
            {
                IQueryable <CAS_MAIN_INFO> cas = context.CAS_MAIN_INFO.AsQueryable <CAS_MAIN_INFO>();

                if (!string.IsNullOrWhiteSpace(casQuery.CAS_NUMBER))
                {
                    cas =
                        from d in cas
                        where d.CAS_NUMBER.Contains(casQuery.CAS_NUMBER) || d.CHINESE.Equals(casQuery.CAS_NUMBER) || d.CHINESE_ALIAS.Equals(casQuery.CAS_NUMBER) || d.ENGLISH.Equals(casQuery.CAS_NUMBER) || d.ENGLISH_ALIAS.Equals(casQuery.CAS_NUMBER)
                        select d;
                }

                if (!string.IsNullOrWhiteSpace(casQuery.CAS_NUMBERList))
                {
                    List <string> listcas = new List <string>();
                    string[]      array   = casQuery.CAS_NUMBERList.Split('~');
                    for (int i = 0; i < array.Length; i++)
                    {
                        if (!string.IsNullOrWhiteSpace(array[i]))
                        {
                            listcas.Add(array[i]);
                        }
                    }
                    cas =
                        from d in cas
                        where (from p in listcas select p).Contains(d.CAS_NUMBER)
                        select d;
                }


                cas = cas.GetPage(out num, casQuery.PageNo, casQuery.PageSize, (IQueryable <CAS_MAIN_INFO> d) =>
                                  from o in d
                                  orderby o.ADD_DATE descending
                                  select o);
                return(new PageModel <CAS_MAIN_INFO>()
                {
                    Models = cas,
                    Total = num
                });
            }
            catch (Exception) { return(null); }
        }
        public Model.PageModel <Model.CAS_MAIN_INFO> GetCasList(QueryModel.CAS_MAIN_INFOQuery casQuery)
        {
            int num = 0;

            IQueryable <CAS_MAIN_INFO> cas = context.CAS_MAIN_INFO.AsQueryable <CAS_MAIN_INFO>();

            if (!string.IsNullOrWhiteSpace(casQuery.CAS_NUMBER))
            {
                cas =
                    from d in cas
                    where d.CAS_NUMBER.Equals(casQuery.CAS_NUMBER)
                    select d;
            }
            if (!string.IsNullOrWhiteSpace(casQuery.type))
            {
                int i;
                int k;
                if (int.TryParse(casQuery.type, out i))
                {
                    k   = int.Parse(casQuery.type);
                    cas =
                        from d in cas
                        where d.IS_AUDIT == k
                        select d;
                }
            }
            cas = cas.GetPage(out num, casQuery.PageNo, casQuery.PageSize, (IQueryable <CAS_MAIN_INFO> d) =>
                              from o in d
                              orderby o.ADD_DATE descending
                              select o);
            return(new PageModel <CAS_MAIN_INFO>()
            {
                Models = cas,
                Total = num
            });
        }
        public int SearchCasInfoListCount(QueryModel.CAS_MAIN_INFOQuery casQuery, string islike)
        {
            int num = 0;

            try
            {
                IQueryable <CAS_MAIN_INFO> cas = context.CAS_MAIN_INFO.AsQueryable <CAS_MAIN_INFO>();

                if (!string.IsNullOrWhiteSpace(casQuery.CAS_NUMBER))
                {
                    string search = casQuery.CAS_NUMBER;

                    if (islike == "0")
                    {
                        if (Regex.IsMatch(search, @"[0-9?-]") && !Regex.IsMatch(search, @"[A-Za-z]+"))
                        {
                            cas = (from u in cas
                                   where u.CAS_NUMBER.Contains(search)
                                   orderby u.ADD_DATE descending
                                   select u);
                        }
                        else if (Regex.IsMatch(search, @"[\u4E00-\u9FA5]"))
                        {
                            cas = (from u in cas
                                   where u.CHINESE.Contains(search) || u.CHINESE_ALIAS.Contains(search)
                                   orderby u.ADD_DATE descending
                                   select u);
                        }
                        //else if (Regex.IsMatch(search, @"[A-Za-z0-9]+"))
                        else
                        {
                            cas = (from u in cas
                                   where u.ENGLISH.Contains(search) || u.ENGLISH_ALIAS.Contains(search)
                                   orderby u.ADD_DATE descending
                                   select u);
                        }
                    }
                    else //精确查询
                    {
                        if (Regex.IsMatch(search, @"[0-9?-]") && !Regex.IsMatch(search, @"[A-Za-z]+"))
                        {
                            cas = (from u in cas
                                   where u.CAS_NUMBER.Equals(search)
                                   orderby u.ADD_DATE descending
                                   select u);
                        }
                        else if (Regex.IsMatch(search, @"[\u4E00-\u9FA5]"))
                        {
                            cas = (from u in cas
                                   where u.CHINESE.Equals(search) || u.CHINESE_ALIAS.Equals(search)
                                   orderby u.ADD_DATE descending
                                   select u);
                        }
                        //else if (Regex.IsMatch(search, @"[A-Za-z0-9]+"))
                        else
                        {
                            cas = (from u in cas
                                   where u.ENGLISH.Equals(search) || u.ENGLISH_ALIAS.Equals(search)
                                   orderby u.ADD_DATE descending
                                   select u);
                        }
                    }
                }

                if (!string.IsNullOrWhiteSpace(casQuery.CAS_NUMBERList))
                {
                    List <string> listcas = new List <string>();
                    string[]      array   = casQuery.CAS_NUMBERList.Split('~');
                    for (int i = 0; i < array.Length; i++)
                    {
                        if (!string.IsNullOrWhiteSpace(array[i]))
                        {
                            listcas.Add(array[i]);
                        }
                    }
                    cas =
                        from d in cas
                        where (from p in listcas select p).Contains(d.CAS_NUMBER)
                        select d;
                }
                cas = cas.GetPage(out num, casQuery.PageNo, casQuery.PageSize, (IQueryable <CAS_MAIN_INFO> d) =>
                                  from o in d
                                  orderby o.ADD_DATE descending
                                  select o);
                return(num);
            }
            catch (Exception) { return(0); }
        }
        public PageModel <CAS_MAIN_INFO> SearchCasInfoList(QueryModel.CAS_MAIN_INFOQuery casQuery, string islike)
        {
            int num = 0;

            try
            {
                IQueryable <CAS_MAIN_INFO> cas = context.CAS_MAIN_INFO.AsQueryable <CAS_MAIN_INFO>();

                if (!string.IsNullOrWhiteSpace(casQuery.CAS_NUMBER))
                {
                    string search = casQuery.CAS_NUMBER;
                    #region 模糊查询
                    if (islike == "0")
                    {
                        if (Regex.IsMatch(search, @"[0-9?-]") && !Regex.IsMatch(search, @"[A-Za-z]+"))
                        {
                            cas = (from u in cas
                                   where u.CAS_NUMBER.Contains(search)
                                   orderby u.UPDATE_TIME descending
                                   select u).Skip(casQuery.PageSize * (casQuery.PageNo - 1)).Take(casQuery.PageSize);
                        }
                        else if (Regex.IsMatch(search, @"[\u4E00-\u9FA5]"))
                        {
                            cas = (from u in cas
                                   where u.CHINESE.Contains(search) || u.CHINESE_ALIAS.Contains(search)
                                   orderby u.UPDATE_TIME descending
                                   select u).Skip(casQuery.PageSize * (casQuery.PageNo - 1)).Take(casQuery.PageSize);
                        }
                        else
                        {
                            cas = (from u in cas
                                   where u.ENGLISH.Contains(search) || u.ENGLISH_ALIAS.Contains(search)
                                   orderby u.UPDATE_TIME descending
                                   select u).Skip(casQuery.PageSize * (casQuery.PageNo - 1)).Take(casQuery.PageSize);
                        }
                    }
                    #endregion
                    #region 精确查询
                    else
                    {
                        if (Regex.IsMatch(search, @"[0-9?-]") && !Regex.IsMatch(search, @"[A-Za-z]+"))
                        {
                            cas = (from u in cas
                                   where u.CAS_NUMBER.Equals(search)
                                   orderby u.UPDATE_TIME descending
                                   select u).Skip(casQuery.PageSize * (casQuery.PageNo - 1)).Take(casQuery.PageSize);
                        }
                        else if (Regex.IsMatch(search, @"[\u4E00-\u9FA5]"))
                        {
                            cas = (from u in cas
                                   where u.CHINESE.Equals(search) || u.CHINESE_ALIAS.Equals(search)
                                   orderby u.UPDATE_TIME descending
                                   select u).Skip(casQuery.PageSize * (casQuery.PageNo - 1)).Take(casQuery.PageSize);
                        }
                        else
                        {
                            cas = (from u in cas
                                   where u.ENGLISH.Equals(search) || u.ENGLISH_ALIAS.Equals(search)
                                   orderby u.UPDATE_TIME descending
                                   select u).Skip(casQuery.PageSize * (casQuery.PageNo - 1)).Take(casQuery.PageSize);
                        }
                    }
                    #endregion
                }
                if (!string.IsNullOrWhiteSpace(casQuery.CAS_NUMBERList))
                {
                    List <string> listcas = new List <string>();
                    string[]      array   = casQuery.CAS_NUMBERList.Split('~');
                    for (int i = 0; i < array.Length; i++)
                    {
                        if (!string.IsNullOrWhiteSpace(array[i]))
                        {
                            listcas.Add(array[i]);
                        }
                    }
                    cas =
                        (from d in cas
                         where (from p in listcas select p).Contains(d.CAS_NUMBER)
                         orderby d.UPDATE_TIME descending
                         select d).Skip(casQuery.PageSize * (casQuery.PageNo - 1)).Take(casQuery.PageSize);
                }
                return(new PageModel <CAS_MAIN_INFO>()
                {
                    Models = cas,
                    Total = cas.Count <CAS_MAIN_INFO>()
                });
            }
            catch (Exception) { return(null); }
        }