Exemplo n.º 1
0
        /// <summary>
        /// This methods filters the information passed to it in order to refine the query
        /// that will be called in the database layer.
        /// </summary>
        /// <param name="criteria">The partial text used to query the database</param>
        /// <param name="maxRows">The maximum number of rows that the database will return. a value of zero will return the entire set</param>
        /// <param name="contains">indicator as to whether the text is to be searched starting from the beginning or anywhere
        ///                        in the string</param>
        /// <returns>Returns the search results</returns>
        public static DrugDictionaryCollection SearchNameOnly(string criteria, int maxRows, bool contains)
        {
            DrugDictionaryCollection dc = new DrugDictionaryCollection();

            // Find out how we should search for the string
            if (Strings.Clean(criteria) != null)
            {
                // put the '%' at the end to indicate that the search starts
                // with the criteria passed.
                criteria += "%";

                // put the '%' at the beginning to indicate that the search
                // data contains the criteria passed
                if (contains)
                {
                    criteria = "%" + criteria;
                }

                // The stored procedure needs to change to reflect a 0 number of
                // rows to mean the entire set.
                if (maxRows <= 0)
                {
                    maxRows = 9999;
                }

                try
                {
                    // Call the database layer and get data
                    DataTable dt = DrugDictionaryQuery.SearchNameOnly(criteria, maxRows);

                    // use Linq to move information from the dataTable
                    // into the DrugDictionaryCollection
                    dc.AddRange(
                        from entry in dt.AsEnumerable()
                        select GetEntryFromDR(entry)
                        );
                }
                catch (Exception ex)
                {
                    CancerGovError.LogError("DrugDictionatyManager", 2, ex);
                    throw ex;
                }
            }

            // return the collection
            return(dc);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This methods filters the information passed to it in order to refine the query
        /// that will be called in the database layer.
        /// </summary>
        /// <param name="criteria">The partial text used to query the database</param>
        /// <param name="maxRows">The maximum number of rows that the database will return. a value of zero will return the entire set</param>
        /// <param name="contains">indicator as to whether the text is to be searched starting from the beginning or anywhere
        ///                        in the string</param>
        /// <returns>Returns the search results</returns>
        public static DrugDictionaryCollection Search(string criteria, int maxRows, int curPage, bool bOtherNames, bool contains)
        {
            DrugDictionaryCollection dc = new DrugDictionaryCollection();

            // Find out how we should search for the string
            if (Strings.Clean(criteria) != null)
            {
                // replace any '[' with '[[]'
                //criteria = criteria.Replace("[", "[[]");

                // put the '%' at the end to indicate that the search starts
                // with the criteria passed.
                criteria += "%";

                // put the '%' at the beginning to indicate that the search
                // data contains the criteria passed
                if (contains)
                {
                    criteria = "%" + criteria;
                }

                // The stored procedure needs to change to reflect a 0 number of
                // rows to mean the entire set.
                if (maxRows <= 0)
                {
                    maxRows = 9999;
                }

                // The stored procedure need to reflect a cur pag of 0 to be 1
                if (curPage == 0)
                {
                    curPage = 1;
                }

                try
                {
                    int queryCount;

                    int matchCount = 0;

                    // Call the database layer and get data
                    DataTable dt = DrugDictionaryQuery.Search(
                        criteria,
                        maxRows,
                        curPage,
                        (bOtherNames ? 'Y' : 'N'),
                        out matchCount
                        );

                    // Set the value on the collection
                    dc.matchCount = matchCount;

                    // Now get a new collection with only one unique termIDs in the collection
                    if (bOtherNames)
                    {
                        concatenateDuplicateEntries(dt, dc);
                    }
                    else
                    {
                        // use Linq to move information from the dataTable
                        // into the DrugDictionaryCollection
                        dc.AddRange(
                            from entry in dt.AsEnumerable()
                            select GetEntryFromDR(entry)
                            );
                    }
                }
                catch (Exception ex)
                {
                    CancerGovError.LogError("DrugDictionatyManager", 2, ex);
                    throw ex;
                }
            }

            // return the collection
            return(dc);
        }