Пример #1
0
        /// <summary>
        /// Retrieve all data from Shippers table. Used to fill combo box.
        /// </summary>
        /// <returns>List of Shippers</returns>
        public List <ModelNotifiedForShippers> GetAll_Shippers(out string error)
        {
            error = null;
            ShippersBsn                     bsn           = new ShippersBsn(wpfConfig);
            List <ShippersInfo>             dbItems       = bsn.GetAll();
            List <ModelNotifiedForShippers> notifiedItems = new List <ModelNotifiedForShippers>();

            foreach (ShippersInfo dbItem in dbItems)
            {
                ModelNotifiedForShippers itemToAdd = new ModelNotifiedForShippers();
                Cloner.CopyAllTo(typeof(ShippersInfo), dbItem, typeof(ModelNotifiedForShippers), itemToAdd);
                notifiedItems.Add(itemToAdd);
            }
            return(notifiedItems);
        }
Пример #2
0
        private List <ModelNotifiedForOrders> FilterGrid(string filterValue)
        {
            filterValue = filterValue.ToLower();
            List <ModelNotifiedForOrders> filteredList = new List <ModelNotifiedForOrders>();

            foreach (ModelNotifiedForOrders item in OrdersDataContext.modelNotifiedForOrdersMain)
            {
                if (item.OrderID.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.ShipName != null)
                {
                    if (item.ShipName.ToLower().Contains(filterValue))
                    {
                        filteredList.Add(item);
                        continue;
                    }
                }

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

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

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

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

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

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

                if (item.EmployeeID != null)
                {
                    ModelNotifiedForEmployees comboItem = OrdersDataContext.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.ShipVia != null)
                {
                    ModelNotifiedForShippers comboItem = OrdersDataContext.modelNotifiedForShippers.Where(x => x.ShipperID == item.ShipVia).FirstOrDefault();
                    if ((comboItem != null) && (comboItem.CompanyName != null) && (comboItem.CompanyName.ToLower().Contains(filterValue)))
                    {
                        filteredList.Add(item);
                        continue;
                    }
                }
            }
            return(filteredList);
        }