private void btnDelete_Click(object sender, EventArgs e)
 {
     BankTransactionsList trans = new BankTransactionsList();
     foreach (DataGridViewRow row in TransHistoryGrid.SelectedRows)
     {
         trans.Add((BankTransaction)row.DataBoundItem);
     }
     BankAccounts.DeleteTransactions(trans);
     RecalcAllInterest();
     DisplayData();
 }
Exemplo n.º 2
0
 public static BankTransactionsList GetAccountTransactions(int accountID)
 {
     BankTransactionsList retVal = new BankTransactionsList();
     EMMADataSet.BankTransactionDataTable table = new EMMADataSet.BankTransactionDataTable();
     bankTransactionTableAdapter.FillByAny(table, accountID, 0, false);
     foreach (EMMADataSet.BankTransactionRow trans in table)
     {
         retVal.Add(new BankTransaction(trans));
     }
     return retVal;
 }
        private void DisplayData()
        {
            try
            {
                _accountExists = _oldCorpData != null;

                if (cmbOwner.SelectedValue != null && (_oldOwner == 0 || _oldCorpData == null))
                {
                    long newOwner = ((CharCorp)cmbOwner.SelectedValue).ID;
                    //if (_lastOwner > 0 && _lastOwner != newOwner && _lastCorp > 0)
                    //{
                    //    BankAccounts.DeleteAccount(_lastCorp, _lastOwner);
                    //}
                    _corp.OwnerID = newOwner;
                    //_corp.ReloadBankAccountDetails();
                }

                _lastOwner = _corp.OwnerID;

                if ((_oldCorpData == null || _oldOwner <= 0) && _corp.ID > 0 && _corp.OwnerID > 0)
                {
                    // Account does not exist, we must create it.
                    BankAccounts.StoreAccount(_corp, UserAccount.CurrentGroup.ID, _corp.OwnerID);
                    _accountExists = true;
                }

                if (_accountExists)
                {
                    btnDeposit.Enabled = true;
                    btnWithdraw.Enabled = true;
                    btnRecalcInterest.Enabled = true;
                    btnAdjust.Enabled = true;
                    btnDelete.Enabled = true;

                    lblBalance.Text = new IskAmount(_corp.AmountInAccount).ToString();
                    lblInterest.Text = new IskAmount(_corp.TotalInterest).ToString();

                    _trans = BankAccounts.GetAccountTransactions(_corp.BankAccountID);
                    _bindingSource.DataSource = _trans;
                    SetFilter();

                    DataGridViewCellStyle iskStyle = new DataGridViewCellStyle(AmountColumn.DefaultCellStyle);
                    iskStyle.Format = IskAmount.FormatString();
                    AmountColumn.DefaultCellStyle = iskStyle;

                    TransHistoryGrid.AutoGenerateColumns = false;
                    DateColumn.DataPropertyName = "Date";
                    AmountColumn.DataPropertyName = "Change";
                    TypeColumn.DataPropertyName = "TypeDescription";
                    TransHistoryGrid.DataSource = _bindingSource;

                    DataGridViewColumn sortColumn = DateColumn;
                    ListSortDirection sortDirection = ListSortDirection.Descending;
                    if (TransHistoryGrid.SortedColumn != null) { sortColumn = TransHistoryGrid.SortedColumn; }
                    if (TransHistoryGrid.SortOrder == SortOrder.Ascending)
                    {
                        sortDirection = ListSortDirection.Ascending;
                    }
                    TransHistoryGrid.Sort(sortColumn, sortDirection);
                }
                else
                {
                    btnDeposit.Enabled = false;
                    btnWithdraw.Enabled = false;
                    btnRecalcInterest.Enabled = false;
                    btnAdjust.Enabled = false;
                    btnDelete.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                EMMAException emmaEx = ex as EMMAException;
                if (emmaEx == null)
                {
                    emmaEx = new EMMAException(ExceptionSeverity.Error, "Problem refreshing " +
                        "bank account window", ex);
                }
                MessageBox.Show("Problem refreshing bank account window: " + ex.Message, "Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Exemplo n.º 4
0
        public static void DeleteTransactions(BankTransactionsList transactions)
        {
            EMMADataSet.BankTransactionDataTable table = new EMMADataSet.BankTransactionDataTable();
            bankTransactionTableAdapter.ClearBeforeFill = false;

            foreach (BankTransaction trans in transactions)
            {
                bankTransactionTableAdapter.FillByID(table, trans.ID);
                EMMADataSet.BankTransactionRow row = table.FindByTransactionID(trans.ID);
                if (row != null) { row.Delete(); }
            }

            bankTransactionTableAdapter.Update(table);
            bankTransactionTableAdapter.ClearBeforeFill = true;
        }