예제 #1
0
        /// <summary>
        /// Retrieve all data from Region table. Used to fill combo box.
        /// </summary>
        /// <returns>List of Region</returns>
        public List <ModelNotifiedForRegion> GetAll_Region(out string error)
        {
            error = null;
            RegionBsn                     bsn           = new RegionBsn(wpfConfig);
            List <RegionInfo>             dbItems       = bsn.GetAll();
            List <ModelNotifiedForRegion> notifiedItems = new List <ModelNotifiedForRegion>();

            foreach (RegionInfo dbItem in dbItems)
            {
                ModelNotifiedForRegion itemToAdd = new ModelNotifiedForRegion();
                Cloner.CopyAllTo(typeof(RegionInfo), dbItem, typeof(ModelNotifiedForRegion), itemToAdd);
                notifiedItems.Add(itemToAdd);
            }
            return(notifiedItems);
        }
예제 #2
0
        private List <ModelNotifiedForTerritories> FilterGrid(string filterValue)
        {
            filterValue = filterValue.ToLower();
            List <ModelNotifiedForTerritories> filteredList = new List <ModelNotifiedForTerritories>();

            foreach (ModelNotifiedForTerritories item in TerritoriesDataContext.modelNotifiedForTerritoriesMain)
            {
                if (item.TerritoryID.ToString().ToLower().Contains(filterValue))
                {
                    filteredList.Add(item);
                    continue;
                }

//Filter string values.
                if (item.TerritoryID != null)
                {
                    if (item.TerritoryID.ToLower().Contains(filterValue))
                    {
                        filteredList.Add(item);
                        continue;
                    }
                }

                if (item.TerritoryDescription != null)
                {
                    if (item.TerritoryDescription.ToLower().Contains(filterValue))
                    {
                        filteredList.Add(item);
                        continue;
                    }
                }

//Filter FK values.
                if (item.RegionID != null)
                {
                    ModelNotifiedForRegion comboItem = TerritoriesDataContext.modelNotifiedForRegion.Where(x => x.RegionID == item.RegionID).FirstOrDefault();
                    if ((comboItem != null) && (comboItem.RegionDescription != null) && (comboItem.RegionDescription.ToLower().Contains(filterValue)))
                    {
                        filteredList.Add(item);
                        continue;
                    }
                }
            }
            return(filteredList);
        }