Beispiel #1
0
        /// <summary>
        /// Retrieve all data from CustomerDemographics table. Used to fill combo box.
        /// </summary>
        /// <returns>List of CustomerDemographics</returns>
        public List <ModelNotifiedForCustomerDemographics> GetAll_CustomerDemographics(out string error)
        {
            error = null;
            CustomerDemographicsBsn                     bsn           = new CustomerDemographicsBsn(wpfConfig);
            List <CustomerDemographicsInfo>             dbItems       = bsn.GetAll();
            List <ModelNotifiedForCustomerDemographics> notifiedItems = new List <ModelNotifiedForCustomerDemographics>();

            foreach (CustomerDemographicsInfo dbItem in dbItems)
            {
                ModelNotifiedForCustomerDemographics itemToAdd = new ModelNotifiedForCustomerDemographics();
                Cloner.CopyAllTo(typeof(CustomerDemographicsInfo), dbItem, typeof(ModelNotifiedForCustomerDemographics), itemToAdd);
                notifiedItems.Add(itemToAdd);
            }
            return(notifiedItems);
        }
Beispiel #2
0
        private List <ModelNotifiedForCustomerCustomerDemo> FilterGrid(string filterValue)
        {
            filterValue = filterValue.ToLower();
            List <ModelNotifiedForCustomerCustomerDemo> filteredList = new List <ModelNotifiedForCustomerCustomerDemo>();

            foreach (ModelNotifiedForCustomerCustomerDemo item in CustomerCustomerDemoDataContext.modelNotifiedForCustomerCustomerDemoMain)
            {
                if (item.CustomerID.ToString().ToLower().Contains(filterValue))
                {
                    filteredList.Add(item);
                    continue;
                }

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

                if (item.CustomerTypeID.ToString().ToLower().Contains(filterValue))
                {
                    filteredList.Add(item);
                    continue;
                }

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

//Filter FK values.
                if (item.CustomerID != null)
                {
                    ModelNotifiedForCustomers comboItem = CustomerCustomerDemoDataContext.modelNotifiedForCustomers.Where(x => x.CustomerID == item.CustomerID).FirstOrDefault();
                    if ((comboItem != null) && (comboItem.CompanyName != null) && (comboItem.CompanyName.ToLower().Contains(filterValue)))
                    {
                        filteredList.Add(item);
                        continue;
                    }
                }

                if (item.CustomerTypeID != null)
                {
                    ModelNotifiedForCustomerDemographics comboItem = CustomerCustomerDemoDataContext.modelNotifiedForCustomerDemographics.Where(x => x.CustomerTypeID == item.CustomerTypeID).FirstOrDefault();
                    if ((comboItem != null) && (comboItem.CustomerTypeID != null) && (comboItem.CustomerTypeID.ToLower().Contains(filterValue)))
                    {
                        filteredList.Add(item);
                        continue;
                    }
                }
            }
            return(filteredList);
        }