Example #1
0
        /// <summary>
        /// Retrieve all data from Customers table. Used to fill combo box.
        /// </summary>
        /// <returns>List of Customers</returns>
        public List <ModelNotifiedForCustomers> GetAll_Customers(out string error)
        {
            error = null;
            CustomersBsn                     bsn           = new CustomersBsn(wpfConfig);
            List <CustomersInfo>             dbItems       = bsn.GetAll();
            List <ModelNotifiedForCustomers> notifiedItems = new List <ModelNotifiedForCustomers>();

            foreach (CustomersInfo dbItem in dbItems)
            {
                ModelNotifiedForCustomers itemToAdd = new ModelNotifiedForCustomers();
                Cloner.CopyAllTo(typeof(CustomersInfo), dbItem, typeof(ModelNotifiedForCustomers), itemToAdd);
                notifiedItems.Add(itemToAdd);
            }
            return(notifiedItems);
        }
Example #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);
        }