Ejemplo n.º 1
0
        private void mnuItemEditTransaction_Click(object sender, EventArgs e)
        {
            //Retrieve selected transaction from grid
            Data.Transaction selectedTransaction = (Data.Transaction)gvwTransactions.SelectedRows[0].DataBoundItem;

            //Pass the retrieved transaction to a new transaction form and show the form
            using (frmTransaction transactionForm = new frmTransaction())
            {
                transactionForm.TransactionData = selectedTransaction;
                transactionForm.CustomerName    = CustomerData.Name;
                transactionForm.ShowDialog();
                if (transactionForm.DialogResult == DialogResult.OK)
                {
                    //Update any changes
                    CustomerData.UpdateToDatabase();
                    RefreshLedger();
                    UpdateInterface();
                }
            }
        }
Ejemplo n.º 2
0
        private void mnuItemAddDebit_Click(object sender, EventArgs e)
        {
            //Retrieve selected customer from grid
            Data.Customer selectedCustomer = (Data.Customer)gvwCustomers.SelectedRows[0].DataBoundItem;

            //Pass customer name to a new transaction form along with a new debit transaction
            using (frmTransaction transactionForm = new frmTransaction())
            {
                transactionForm.TransactionData = new Data.Transaction(Data.Transaction.TransactionType.Debit);
                transactionForm.CustomerName    = selectedCustomer.Name;
                transactionForm.ShowDialog();
                if (transactionForm.DialogResult == DialogResult.OK)
                {
                    //Add transaction to the customer's transactions
                    if (selectedCustomer.Transactions is null)
                    {
                        selectedCustomer.Transactions = new List <Data.Transaction>();
                    }
                    selectedCustomer.Transactions.Add(transactionForm.TransactionData);
                    selectedCustomer.UpdateToDatabase();
                    RefreshCustomers();
                }
            }
        }