Beispiel #1
0
        private void PerformTransferCustomersProcess()
        {
            try
            {
                List <long> IDs = new List <long>();
                for (int i = 0; i < dgv_Customers.SelectedRows.Count; i++)
                {
                    IDs.Add(long.Parse(dgv_Customers.SelectedRows[i].Cells[0].Value.ToString()));
                }
                foreach (var id in IDs)
                {
                    var customer = _CustomerRepo.GetCustomer(id);
                    cmb_Subadmin.Invoke(new MethodInvoker(delegate
                    {
                        customer.CreatedBy = cmb_Subadmin.SelectedValue.ToString();
                        _CustomerRepo.ChangeCustomerCreator(customer);
                    }));

                    cmb_Subadmin.Invoke(new MethodInvoker(delegate
                    {
                        var customerTransactions = _TransactionRepo.GetAllTransactions().Where(x => x.CustomerId == id);
                        foreach (var customerTransaction in customerTransactions.ToList())
                        {
                            customerTransaction.CreatedBy = cmb_Subadmin.SelectedValue.ToString();
                            _TransactionRepo.ChangeTransactionCreator(customerTransaction);
                        }
                    }));
                }
                MessageBox.Show("Operation completed successfully!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (!bgw_PullCustomers.IsBusy)
                {
                    bgw_PullCustomers.RunWorkerAsync();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"{Utilities.ERRORMESSAGE} \n Error details: {ex.Message}", "Superior Investment!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }