Beispiel #1
0
        private List <ModelNotifiedForEmployeeTerritories> FilterGrid(string filterValue)
        {
            filterValue = filterValue.ToLower();
            List <ModelNotifiedForEmployeeTerritories> filteredList = new List <ModelNotifiedForEmployeeTerritories>();

            foreach (ModelNotifiedForEmployeeTerritories item in EmployeeTerritoriesDataContext.modelNotifiedForEmployeeTerritoriesMain)
            {
                if (item.EmployeeID.ToString().ToLower().Contains(filterValue))
                {
                    filteredList.Add(item);
                    continue;
                }

                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;
                    }
                }

//Filter FK values.
                if (item.EmployeeID != null)
                {
                    ModelNotifiedForEmployees comboItem = EmployeeTerritoriesDataContext.modelNotifiedForEmployees.Where(x => x.EmployeeID == item.EmployeeID).FirstOrDefault();
                    if ((comboItem != null) && (comboItem.LastName != null) && (comboItem.LastName.ToLower().Contains(filterValue)))
                    {
                        filteredList.Add(item);
                        continue;
                    }
                }

                if (item.TerritoryID != null)
                {
                    ModelNotifiedForTerritories comboItem = EmployeeTerritoriesDataContext.modelNotifiedForTerritories.Where(x => x.TerritoryID == item.TerritoryID).FirstOrDefault();
                    if ((comboItem != null) && (comboItem.TerritoryDescription != null) && (comboItem.TerritoryDescription.ToLower().Contains(filterValue)))
                    {
                        filteredList.Add(item);
                        continue;
                    }
                }
            }
            return(filteredList);
        }
Beispiel #2
0
        /// <summary>
        /// Retrieve all data from Territories table. Used to fill combo box.
        /// </summary>
        /// <returns>List of Territories</returns>
        public List <ModelNotifiedForTerritories> GetAll_Territories(out string error)
        {
            error = null;
            TerritoriesBsn                     bsn           = new TerritoriesBsn(wpfConfig);
            List <TerritoriesInfo>             dbItems       = bsn.GetAll();
            List <ModelNotifiedForTerritories> notifiedItems = new List <ModelNotifiedForTerritories>();

            foreach (TerritoriesInfo dbItem in dbItems)
            {
                ModelNotifiedForTerritories itemToAdd = new ModelNotifiedForTerritories();
                Cloner.CopyAllTo(typeof(TerritoriesInfo), dbItem, typeof(ModelNotifiedForTerritories), itemToAdd);
                notifiedItems.Add(itemToAdd);
            }
            return(notifiedItems);
        }