private void GetTransfers(string companyName, DateTime fromDate, DateTime toDate) { //TODO: Add service for recover transfer for this specification, at this moment only get all transfer in paged mode using (BackgroundWorker worker = new BackgroundWorker()) { worker.DoWork += delegate(object sender, DoWorkEventArgs e) { IMainModuleService mainModuleService = ProxyLocator.GetMainModuleService(); e.Result = mainModuleService.GetPagedTransfers(new PagedCriteria() { PageIndex = this._pageIndex, PageCount = 10 }); }; worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { if (!e.Cancelled && e.Error == null) { List <BankTransfer> transfers = e.Result as List <BankTransfer>; if (transfers != null) { this.Transfers = new ObservableCollection <BankTransfer>(transfers); } } else { MessageBox.Show(e.Error.Message, "Transfers List", MessageBoxButton.OK, MessageBoxImage.Error); } }; worker.WorkerSupportsCancellation = true; worker.RunWorkerAsync(); } }
private void RefreshBankAccountsStatus() { using (BackgroundWorker worker = new BackgroundWorker()) { worker.DoWork += delegate(object sender, DoWorkEventArgs e) { IMainModuleService mainModuleService = ProxyLocator.GetMainModuleService(); e.Result = mainModuleService.GetPagedBankAccounts(new PagedCriteria { PageIndex = 0, PageCount = 50 }); }; worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { if (!e.Cancelled && e.Error == null) { List <BankAccount> bankAccounts = e.Result as List <BankAccount>; if (bankAccounts != null) { this.BankAccountsStatus = new ObservableCollection <BankAccount>(bankAccounts); } } else { MessageBox.Show(e.Error.Message, "Perform Transfer", MessageBoxButton.OK, MessageBoxImage.Error); } }; worker.WorkerSupportsCancellation = true; worker.RunWorkerAsync(); } }
private void LockAccount() { if (this.BankAccountToLock != null) { using (BackgroundWorker worker = new BackgroundWorker()) { worker.DoWork += delegate(object sender, DoWorkEventArgs e) { IMainModuleService mainModuleService = ProxyLocator.GetMainModuleService(); mainModuleService.ChangeBankAccount(this.BankAccountToLock); }; worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { if (!e.Cancelled && e.Error == null) { this.BankAccountToLock = null; this.RefreshBankAccountsStatus(); } else { MessageBox.Show(e.Error.Message, "Perform Transfer", MessageBoxButton.OK, MessageBoxImage.Error); } }; worker.WorkerSupportsCancellation = true; worker.RunWorkerAsync(); } } }
private void LoadCountries() { using (BackgroundWorker worker = new BackgroundWorker()) { worker.DoWork += delegate(object sender, DoWorkEventArgs e) { IMainModuleService mainModuleService = ProxyLocator.GetMainModuleService(); e.Result = mainModuleService.GetPagedCountries(new PagedCriteria { PageIndex = 0, PageCount = 100 }); }; worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { if (!e.Cancelled && e.Error == null) { List <Country> countries = e.Result as List <Country>; if (countries != null) { this.Countries = new ObservableCollection <Country>(countries); } } else { MessageBox.Show(e.Error.Message, "Edit Customer", MessageBoxButton.OK, MessageBoxImage.Error); } }; worker.WorkerSupportsCancellation = true; worker.RunWorkerAsync(); } }
public VMPerformOrder() { //Initialize proxy IMainModuleService mainModuleService = ProxyLocator.GetMainModuleService(); mainModuleService = ProxyLocator.GetMainModuleService(); this._currentOrder = new Order(); }
public VMCustomer(Customer customer) { if (customer != null) { //initialize main module service IMainModuleService mainModuleService = ProxyLocator.GetMainModuleService(); this.Customer = mainModuleService.GetCustomerByCode(customer.CustomerCode); //load orders for this client using (BackgroundWorker worker = new BackgroundWorker()) { worker.DoWork += delegate(object sender, DoWorkEventArgs e) { try { e.Result = mainModuleService.GetOrdersByOrderInformation(new OrderInformation() { CustomerId = customer.CustomerId, DateTimeFrom = DateTime.MinValue, DateTimeTo = DateTime.Now }); } catch { e.Cancel = true; } }; worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { if (!e.Cancelled && e.Error == null) { List <Order> orders = e.Result as List <Order>; if (orders != null) { DateTimeFormatInfo dtformatInfo = new DateTimeFormatInfo(); this.CustomerOrders = orders; this.CurrentCustomerOrdersPie = (from co in this.CustomerOrders where co.OrderDate.Value.Year == this.Today.Year group co by co.OrderDate.Value.Month into g select new { id = g.Key, Month = dtformatInfo.GetMonthName(g.Key), Count = g.Count() } ).OrderByDescending(o => o.id) .ToList <object>(); } } }; worker.WorkerSupportsCancellation = true; worker.RunWorkerAsync(); } } }
public VMPerformTransfer() { //Initialize proxy IMainModuleService mainModuleService = ProxyLocator.GetMainModuleService(); mainModuleService = ProxyLocator.GetMainModuleService(); if (!NavigationController.IsInDesignMode) { this.RefreshBankAccountsStatus(); } }
public VMOrderList() { //Initialize proxy IMainModuleService mainModuleService = ProxyLocator.GetMainModuleService(); mainModuleService = ProxyLocator.GetMainModuleService(); if (!NavigationController.IsInDesignMode) { this.GetOrders(); } }
public VMEditCustomer(Customer customer) { //initialize proxy IMainModuleService mainModuleService = ProxyLocator.GetMainModuleService(); mainModuleService = ProxyLocator.GetMainModuleService(); if (!NavigationController.IsInDesignMode) { LoadCountries(); } this.Customer = customer; }
public VMEditCustomer() { //initialize proxy IMainModuleService mainModuleService = ProxyLocator.GetMainModuleService(); mainModuleService = ProxyLocator.GetMainModuleService(); //Create default customer this._currentCustomer = new Customer() { Address = new AddressInformation(), CustomerPicture = new CustomerPicture() }; }
private void DeleteExecute(Customer customer) { try { //remove customer IMainModuleService mainModuleService = ProxyLocator.GetMainModuleService(); mainModuleService.RemoveCustomer(customer); //refresh customer list this.GetCustomers(); } catch (FaultException <ServiceError> ex) { MessageBox.Show(ex.Detail.ErrorMessage); } }
private void GetBankAccounts() { if (!string.IsNullOrEmpty(this.FilterBankAccount)) { using (BackgroundWorker worker = new BackgroundWorker()) { worker.DoWork += delegate(object sender, DoWorkEventArgs e) { IMainModuleService mainModuleService = ProxyLocator.GetMainModuleService(); if (this.FilterSelector == 0) { e.Result = mainModuleService.GetBankAccounts(new BankAccountInformation() { BankAccountNumber = this.FilterBankAccount }); } else { e.Result = mainModuleService.GetBankAccounts(new BankAccountInformation() { CustomerName = this.FilterBankAccount }); } }; worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { if (!e.Cancelled && e.Error == null) { List <BankAccount> bankAccounts = e.Result as List <BankAccount>; if (bankAccounts != null) { this.BankAccounts = new ObservableCollection <BankAccount>(bankAccounts); } } else { MessageBox.Show(e.Error.Message, "Perform Transfer", MessageBoxButton.OK, MessageBoxImage.Error); } }; worker.WorkerSupportsCancellation = true; worker.RunWorkerAsync(); } } }
private void PerformTransfer() { if (!string.IsNullOrEmpty(this.BankAccountNumberDestination) && !string.IsNullOrEmpty(this.BankAccountNumberSource)) { using (BackgroundWorker worker = new BackgroundWorker()) { worker.DoWork += delegate(object sender, DoWorkEventArgs e) { IMainModuleService mainModuleService = ProxyLocator.GetMainModuleService(); mainModuleService.PerformBankTransfer(new TransferInformation() { Amount = this.BankTransferAmount, OriginAccountNumber = this.BankAccountNumberSource.Trim(), DestinationAccountNumber = this.BankAccountNumberDestination.Trim() }); }; worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { if (!e.Cancelled && e.Error == null) { this.BankAccountNumberSource = string.Empty; this.BankAccountNumberDestination = string.Empty; this.BankTransferAmount = 0; this.RefreshBankAccountsStatus(); } else { var exception = e.Error as FaultException <ServiceError>; if (exception != null) { MessageBox.Show(exception.Detail.ErrorMessage, "Perform Transfer", MessageBoxButton.OK, MessageBoxImage.Error); } else { MessageBox.Show(e.Error.Message, "Perform Transfer", MessageBoxButton.OK, MessageBoxImage.Error); } } }; worker.WorkerSupportsCancellation = true; worker.RunWorkerAsync(); } } }
private void SaveExecute(bool isValidData) { try { //Mark as modified this.Customer.MarkAsModified <Customer>(); //change data in server IMainModuleService mainModuleService = ProxyLocator.GetMainModuleService(); mainModuleService.ChangeCustomer(this.Customer); //accept changes this.Customer.AcceptChanges(); NavigationController.NavigateToView(new CustomerView(), new VMCustomer(this.Customer)); } catch (FaultException <ServiceError> ex) { MessageBox.Show(ex.Detail.ErrorMessage); } }
private void SaveExecute(bool isValidData) { try { //mark as added this._currentCustomer.MarkAsAdded <Customer>(); //save in server IMainModuleService mainModuleService = ProxyLocator.GetMainModuleService(); mainModuleService.AddCustomer(this._currentCustomer); //accept changes this._currentCustomer.AcceptChanges(); NavigationController.NavigateToView(new CustomerListView()); } catch (FaultException <ServiceError> ex) { MessageBox.Show(ex.Detail.ErrorMessage); } }
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); }
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(); } }
private void SaveExecute(bool isValidData) { try { this.Order.Customer = this.GetCustomerByName(); if (this.Order.Customer != null) { this.Order.MarkAsAdded <Order>(); IMainModuleService mainModuleService = ProxyLocator.GetMainModuleService(); mainModuleService.AddOrder(this.Order); this.Order.AcceptChanges(); NavigationController.CloseCurrentView.Execute(null); } } catch (FaultException <ServiceError> ex) { MessageBox.Show(ex.Detail.ErrorMessage); } }