Esempio n. 1
0
        private void addTransactionButton_Click(object sender, EventArgs e)
        {
            if (accountBindingSource.Count < 1)
            {
                MessageBox.Show("Create an account first.");
                return;
            }
            var newTransaction = databaseDataSet.Transaction.NewTransactionRow();

            newTransaction.AccountID = (int)((DataRowView)accountBindingSource.Current).Row["AccountID"];
            newTransaction.Amount    = 0.0f;
            newTransaction.Memo      = "No memo";
            newTransaction.Category  = TransactionCategory.Uncategorized;
            newTransaction.Date      = DateTime.Now;
            databaseDataSet.Transaction.Rows.Add(newTransaction);
            transactionTableAdapter.Update(databaseDataSet.Transaction);
            var transactionID = newTransaction.TransactionID;
            var position      = transactionBindingSource.Find("TransactionID", transactionID);

            transactionBindingSource.Position = position;

            var transactionForm = new TransactionForm(newTransaction.TransactionID);

            transactionForm.ShowDialog();

            transactionTableAdapter.Fill(databaseDataSet.Transaction);
            position = transactionBindingSource.Find("TransactionID", transactionID);
            transactionBindingSource.Position = position;
            transactionBindingSource.ResetCurrentItem();
        }
Esempio n. 2
0
        private void editTransactionButton_Click(object sender, EventArgs e)
        {
            if (transactionBindingSource.Count < 1)
            {
                addTransactionButton_Click(sender, e);
                return;
            }
            var selectedIndex   = transactionGridView.SelectedRows[0].Index;
            var transactionID   = (int)transactionGridView.CurrentRow.Cells[0].Value;
            var transactionForm = new TransactionForm(transactionID);

            transactionForm.ShowDialog();

            transactionTableAdapter.Fill(databaseDataSet.Transaction);
            var position = transactionBindingSource.Find("TransactionID", transactionID);

            transactionBindingSource.Position = position;
            transactionBindingSource.ResetCurrentItem();
            transactionGridView.ClearSelection();
            transactionGridView.Rows[selectedIndex].Selected = true;
        }