Example #1
0
        public void DoFilter()
        {
            Records = DataContext.Schedule.ToList();

            if (string.IsNullOrEmpty(Pattern))
            {
                FilteredResults = Records;
            }
            else
            {
                Regex           aRegex  = new Regex(Pattern);
                List <Schedule> Results = new List <Schedule>();
                for (int i = 0; i < Records.Count; i++)
                {
                    string Words = (Records[i].Id).ToString() + " " + Records[i].Name + " " + Records[i].BeginDate + " " + Records[i].BeginTime + " " + Records[i].EndDate + " "
                                   + Records[i].EndTime + " " + Records[i].Place + " " + Records[i].Memo;
                    MatchCollection aMatches = aRegex.Matches(Words);
                    for (int j = 0; j < aMatches.Count; j++)
                    {
                        if (aMatches[j].Success)
                        {
                            Results.Add(Records[i]);
                        }
                    }
                }
                FilteredResults = Results;
            }
            for (int i = 0; i < FilteredResults.Count; i++)
            {
                for (int j = FilteredResults.Count - 1; j > i; j--)
                {
                    if (FilteredResults[i] == FilteredResults[j])
                    {
                        FilteredResults.RemoveAt(j);
                    }
                }
            }
        }
Example #2
0
        public void SearchStr()
        {
            Records = DataContext.Conts.ToList();

            if (string.IsNullOrEmpty(Pattern))
            {
                FilteredResults = Records;
            }
            else
            {
                Regex        aRegex  = new Regex(Pattern);
                List <Conts> Results = new List <Conts>();
                for (int i = 0; i < Records.Count; i++)
                {
                    string Words = Records[i].name + " " + Records[i].mobile + " " + Records[i].memo + " " + Records[i].sex + " "
                                   + Records[i].birth;
                    MatchCollection aMatches = aRegex.Matches(Words);
                    for (int j = 0; j < aMatches.Count; j++)
                    {
                        if (aMatches[j].Success)
                        {
                            Results.Add(Records[i]);
                        }
                    }
                }
                FilteredResults = Results;
            }
            for (int i = 0; i < FilteredResults.Count; i++)
            {
                for (int j = FilteredResults.Count - 1; j > i; j--)
                {
                    if (FilteredResults[i] == FilteredResults[j])
                    {
                        FilteredResults.RemoveAt(j);
                    }
                }
            }
        }