Exemple #1
0
        private void GetCustomers()
        {
            using (BackgroundWorker worker = new BackgroundWorker())
            {
                worker.DoWork += delegate(object sender, DoWorkEventArgs e)
                {
                    IMainModuleService mainModuleService = ProxyLocator.GetMainModuleService();
                    e.Result = mainModuleService.GetPagedCustomer(new PagedCriteria()
                    {
                        PageIndex = this._pageIndex, PageCount = 10
                    });
                };

                worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
                {
                    if (!e.Cancelled && e.Error == null)
                    {
                        List <Customer> customers = e.Result as List <Customer>;

                        if (customers != null)
                        {
                            this.Customers        = new ObservableCollection <Customer>(customers);
                            this._viewData        = CollectionViewSource.GetDefaultView(this.Customers);
                            this._viewData.Filter = null;
                        }
                    }
                    else
                    {
                        MessageBox.Show(e.Error.Message, "Customer List", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                };

                worker.WorkerSupportsCancellation = true;
                worker.RunWorkerAsync();
            }
        }
Exemple #2
0
        private Customer GetCustomerByName()
        {
            Customer customer = null;

            if (!string.IsNullOrEmpty(this.ContactName.Trim()))
            {
                IMainModuleService mainModuleService = ProxyLocator.GetMainModuleService();
                List <Customer>    customers         = mainModuleService.GetPagedCustomer(new PagedCriteria()
                {
                    PageIndex = 0, PageCount = 100
                });

                if (customers != null)
                {
                    customer = (from c in customers where c.ContactName.Equals(this.ContactName.Trim(), StringComparison.InvariantCultureIgnoreCase) select c).FirstOrDefault <Customer>();
                }
                else
                {
                    this.ContactName = string.Empty;
                }
            }

            return(customer);
        }