Ejemplo n.º 1
0
        public override WithdrawalTransaction Withdraw(Decimal amount)
        {
            var transaction = new WithdrawalTransaction(amount, this);

            transaction.Initiate();
            return(transaction);
        }
Ejemplo n.º 2
0
            public void Apply(WithdrawalTransaction d)
            {
                if (d.WithdrawalAmount > Balance)
                {
                    throw new InvalidOperationException("we make sure this never happens");
                }

                Balance = Balance - d.WithdrawalAmount;
            }
        public static void Main(string[] args)
        {
            var account     = new Account();
            var cashMachine = new Screen();

            var withdrawalTransaction = new WithdrawalTransaction(account, cashMachine);

            withdrawalTransaction.Execute();
        }
Ejemplo n.º 4
0
        private void buttonWithdraw_Click(object sender, EventArgs e)
        {
            toolStripStatusLabelInfoMessage.Text = "Enter a Withdrawal";
            DepositOrWithdrawDialog withdrawalDlg = new DepositOrWithdrawDialog();

            withdrawalDlg.Title = "Withdraw";
            Transaction transaction = new WithdrawalTransaction();

            doFullTransaction(transaction, withdrawalDlg);
        }
Ejemplo n.º 5
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                decimal.TryParse(txtAmount.Text, out amount);

                // Create a new transaction
                Transaction transaction = new WithdrawalTransaction(customer.Accounts[selectedAccount], amount);
                transaction.DoTransaction();

                // Add the transaction to the transaction history.
                this.customer.TransactionHistory.Add(transaction);

                // This will close the dialog with a positive result.
                this.DialogResult = DialogResult.OK;
            }
            catch (AccountInactiveException exception)
            {
                MessageBox.Show(exception.Message, "Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

            }
            catch (NoSufficientFundsException exception)
            {
                MessageBox.Show(exception.Message, "Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (InvalidTransactionAmtException exception)
            {
                // Make sure the input is numeric.
                if (!decimal.TryParse(txtAmount.Text, out amount))
                {
                    MessageBox.Show("Invalid amount. Please enter a numeric value.", "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    MessageBox.Show(exception.Message, "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
Ejemplo n.º 6
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                decimal.TryParse(txtAmount.Text, out amount);

                // Create a new transaction
                Transaction transaction = new WithdrawalTransaction(customer.Accounts[selectedAccount], amount);
                transaction.DoTransaction();

                // Add the transaction to the transaction history.
                this.customer.TransactionHistory.Add(transaction);

                // This will close the dialog with a positive result.
                this.DialogResult = DialogResult.OK;
            }
            catch (AccountInactiveException exception)
            {
                MessageBox.Show(exception.Message, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (NoSufficientFundsException exception)
            {
                MessageBox.Show(exception.Message, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (InvalidTransactionAmtException exception)
            {
                // Make sure the input is numeric.
                if (!decimal.TryParse(txtAmount.Text, out amount))
                {
                    MessageBox.Show("Invalid amount. Please enter a numeric value.", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    MessageBox.Show(exception.Message, "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }