Esempio n. 1
0
        /// <summary>
        /// method to create a new search term and retrieve its data
        /// </summary>
        /// <returns></returns>
        public List <SearchResult> CalculateResultList()
        {
            SearchTerm          searchTerm    = new SearchTerm(canNum, code, animalName, breed, owner, town, state);
            SearchResults       searchResults = new SearchResults();
            List <SearchResult> results       = searchResults.retrieveData(searchTerm);

            return(results);
        }
Esempio n. 2
0
        /// <summary>
        /// method to create a new search term and retrieve its data by a list of strings
        /// </summary>
        /// <returns></returns>
        public List <string> CalculateInventoryList()
        {
            SetAllTerms();

            searchTerm    = new SearchTerm(canNum, code, animalName, breed, owner, town, state);
            searchResults = new SearchResults();
            List <SearchResult> results     = searchResults.retrieveData(searchTerm);
            List <string>       description = new List <string>();

            foreach (SearchResult s in results)
            {
                description.Add(s.ToString());
            }
            return(description);
        }
Esempio n. 3
0
        /// <summary>
        /// Sorts the terms in the text boxes by the SearchContents text, and creates a Search Term to
        /// find the search results with. Returns the results of the search in SearchResults
        /// </summary>
        /// <returns>A list of search results</returns>
        private List <SearchResult> CalculateResultList()
        {
            //Sort the unspecified search terms

            SetTerm(uxSearchTerm1.Text, uxSearchContents1.Text);
            SetTerm(uxSearchTerm2.Text, uxSearchContents2.Text);
            SetTerm(uxSearchTerm3.Text, uxSearchContents3.Text);
            SetTerm(uxSearchTerm4.Text, uxSearchContents4.Text);

            searchTerm    = new SearchTerm(canNum, code, animalName, breed, owner, town, state);
            searchTerm    = new SearchTerm(canNum, code, animalName, breed, owner, town, state);
            searchResults = new SearchResults();
            List <SearchResult> results = searchResults.retrieveData(searchTerm); //Executes database search procedure, returns SearchResult List

            return(results);
        }
        /// <summary>
        ///  Re-initializes the current window with refreshed search results.
        /// </summary>
        private void RetrieveAndRefreshResults()
        {
            searchResults = new SearchResults();
            List <SearchResult> results = searchResults.retrieveData(searchTerm); //initializes the data grid's context to be the search results

            InitializeComponent();
            uxSearchResults.ItemsSource = results;
            ValidColumn.Width           = 40;
            CanNumColumn.Width          = 50;
            CodeColumn.Width            = 110;
            CollDateColumn.Width        = 90;
            UnitsColumn.Width           = 40;
            AnimalNameColumn.Width      = 225;
            BreedColumn.Width           = 80;
            RegNumColumn.Width          = 80;
            OwnerColumn.Width           = 100;
            TownColumn.Width            = 100;
            StateColumn.Width           = 42;
        }
Esempio n. 5
0
        /// <summary>
        /// this finds the capacity of the cans in question
        /// if they are entered with ',' seperating them, then if will take every can # entered.
        /// if no can numbers were entered, it returns an empty list
        /// Note that this function is very slow.
        /// </summary>
        /// <returns></returns>
        public List <SearchResult> RetrieveCanList(out int numOfCans)
        {
            SearchResults       searchResults = new SearchResults();
            List <SearchResult> results       = new List <SearchResult>();

            //Case: no can numbers were entered.
            if (canNum.Equals("*"))
            {
                SearchTerm searchTerm = new SearchTerm(canNum, code, animalName, breed, owner, town, state);
                results   = searchResults.retrieveData(searchTerm);
                numOfCans = results.GroupBy(x => x.CanNum).Count();
                return(results);
            }

            //Check that query is valid
            if (IsValidQuery(canNum))
            {
                //split the query by ','
                string[] canNumbers = canNum.Split(',');
                string[] canRange   = new string[(canNumbers.Length * 2)];
                int      j          = 0;
                //split each section by ':'
                for (int i = 0; i < canNumbers.Length; i++)
                {
                    string[] temp = canNumbers[i].Split(':');
                    if (temp.Length > 1)
                    {
                        canRange[j]     = temp[0];
                        canRange[j + 1] = temp[1];
                        j += 2;
                        //if there is a colon, delete that query from canNumbers
                        canNumbers[i] = "";
                    }
                }

                //get all cans from canNumbers
                foreach (string number in canNumbers)
                {
                    if (number != "")
                    {
                        SearchTerm searchTerm = new SearchTerm(number.Trim().ToString(), code, animalName, breed, owner, town, state);
                        results.AddRange(searchResults.retrieveData(searchTerm));
                    }
                }

                for (int i = 0; i < canRange.Length; i += 2)
                {
                    if (canRange[i] != null)
                    {
                        int begin = Int32.Parse(canRange[i]);
                        int end   = Int32.Parse(canRange[i + 1]);

                        if (begin > end)
                        {
                            int temp = begin;
                            begin = end;
                            end   = temp;
                        }

                        while (begin <= end)
                        {
                            SearchTerm searchTerm = new SearchTerm(begin.ToString(), code, animalName, breed, owner, town, state);
                            results.AddRange(searchResults.retrieveData(searchTerm));
                            begin++;
                        }
                    }
                }

                numOfCans = results.GroupBy(x => x.CanNum).Count();
                return(results);
            }
            else
            {
                //TODO: tell user the input was invalid
                numOfCans = 0;
                return(results);
            }
        }