Doan_Assignment3/.vs/Doan_Assignment3/v16/.suo
Doan_Assignment3/App.config
Doan_Assignment3/BankAccount.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Doan_Assignment3
{
public class BankAccount : IPrintable
{
public string AccountNumber { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public virtual string Owner { get; }
public decimal? Balance { get; }
public BankAccount()
{
}
public BankAccount(string acountNumber, string firstName, string lastName)
{
FirstName = firstName;
LastName = lastName;
AccountNumber = acountNumber;
Owner = "Account #" + acountNumber + " " + firstName + " " + lastName;
Balance = GetBalanceInfo();
}
private decimal? GetBalanceInfo()
{
return 100;
}
public virtual string PrintStatement()
{
string message = "Statement Date as of Today’s date for " + Owner + " \n" +
"Checking Account Balance is $ " + Balance + " \n" +
"Amount of OverDraft Fee for the month is $ x, xxx.xx \n" +
"The number of overdrafts for the month is xxxx \n";
return message;
}
public virtual string ShowBalance()
{
return "Customer " + FirstName + " " + LastName + " has " + 100 + " in Checking Account";
}
public void DepositAmount(decimal value)
{
try
{
Save deposite value here
}
catch (Exception)
{
throw new Exception("Deposit ammount is not submitted !! Please try again");
}
}
public bool WithdrawalAmount(decimal withdrawalAmount, CheckingAccountType? checkingAccount)
{
if (checkingAccount != null)
if (CheckingAccountType.Premier == checkingAccount.Value)
{
return true;
}
if (withdrawalAmount < 0)
{
throw new Exception("No negative withdrawal amounts are allowed. Please enter a valid amount.");
}
if (withdrawalAmount > 300)
{
throw new Exception("Your daily maximum withdrawal is $300 dollars or less. Please enter a smaller amount.");
}
if (withdrawalAmount > 400)
{
throw new Exception("Insufficient funds. Please enter a smaller amount.");
}
return false;
}
}
}
Doan_Assignment3/BankForm.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
Your name: Ngoc Doan
Description: Customer bank account - Create a Windows application that shows a customer account information
Date Created: 09/21/2021
namespace Doan_Assignment3
{
public partial class BankForm : Form
{
private string firstName;
private string lastName;
private string accountNumber;
public BankForm()
{
InitializeComponent();
}
three methods
private void PopulateCombo()
{
AccComBox.Items.Add("--Select an Account Type --");
AccComBox.Items.Add("Checking");
AccComBox.Items.Add("Savings");
AccComBox.Items.Add("Money Market");
AccComBox.Items.Add("Certificate of Deposit ");
AccComBox.SelectedIndex = 0;
}
private void ClearUI()
{
AccComBox.SelectedIndex = 0;
FirstNameTxtBox.Text = "";
LastNameTxtBox.Text = "";
AccountNumber.Text = "";
WithdrawTxtBox.Text = "";
DepositTxtBox.Text = "";
disable transaction box and the following functions (Deposit, Withdrawal, Show Balance and Print Statements), enable customer box before click welcome button
TransactionBox.Enabled = false;
Deposit.Enabled = false;
Withdraw.Enabled = false;
Balance.Enabled = false;
Print.Enabled = false;
CustomerBox.Enabled = true;
}
Form_Load events
private void BankAccount_Load(object sender, EventArgs e)
{
PopulateCombo();
disable transaction box and the following functions (Deposit, Withdrawal, Show Balance and Print Statements) before click welcome button
TransactionBox.Enabled = false;
Deposit.Enabled = false;
Withdraw.Enabled = false;
Balance.Enabled = false;
Print.Enabled = false;
}
The Welcome button perform the following functions (Deposit, Withdrawal, Show Balance and Print Statements)
after an account has been selected and the required fields (account #, first and last name) have been entered and verified against the UI validation rules.
private void Welcome_Click(object sender, EventArgs e)
{
try
{
if ((AccComBox.SelectedIndex == 0))
{
MessageBox.Show("No account selected. Please select an account", "E
or", MessageBoxButtons.OK, MessageBoxIcon.E
or);
}
else
{
if (string.IsNullOrEmpty(AccountNumber.Text))
{
MessageBox.Show("Customer Account Number is blank", "E
or", MessageBoxButtons.OK, MessageBoxIcon.E
or);
}
else if (string.IsNullOrEmpty(FirstNameTxtBox.Text) || string.IsNullOrEmpty(LastNameTxtBox.Text))
{
MessageBox.Show("Cusomter Name is blank.", "E
or", MessageBoxButtons.OK, MessageBoxIcon.E
or);
}
else
{
var selectedText = AccComBox.SelectedItem.ToString().ToLower();
if (selectedText.ToLower().Equals("checking".ToLower()) || selectedText.ToLower().Equals("savings".ToLower()))
{
EnableUI();
this.firstName = FirstNameTxtBox.Text;
this.lastName = LastNameTxtBox.Text;
this.accountNumber = AccountNumber.Text;
}
else
{
MessageBox.Show("Customer " + FirstNameTxtBox.Text + " " + LastNameTxtBox.Text + " does not have an " + selectedText + " account.");
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void ShowInfoMessage(string message)
{
MessageBox.Show(message, "Meramec On-Line Banking System", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void EnableUI()
{
TransactionBox.Enabled = true;
Deposit.Enabled = true;
Withdraw.Enabled = true;
Balance.Enabled = true;
Print.Enabled = true;
CustomerBox.Enabled = false;
}
private void Deposit_Click(object sender, EventArgs e)
{
try
{
string depositAmmount = DepositTxtBox.Text.ToString();
if (string.IsNullOrEmpty(depositAmmount))
{
MessageBox.Show("Please enter deposit amount");
return;
}
decimal dValue = Convert.ToDecimal(depositAmmount);
var selectedText = AccComBox.SelectedItem.ToString().ToLower();
switch (selectedText)
{
case "checking":
CheckingAccount checkingAccount = new CheckingAccount(accountNumber, firstName, lastName);
checkingAccount.DepositAmount(dValue);
ShowInfoMessage("Ammount deposit successfully");
eak;
case "savings":
SavingsAccount savingsAccount = new SavingsAccount(accountNumber, firstName, lastName);
savingsAccount.DepositAmount(dValue);
ShowInfoMessage("Ammount deposit successfully");
eak;
default:
eak;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "E
or", MessageBoxButtons.OK, MessageBoxIcon.E
or);
}
}
private void Withdraw_Click(object sender, EventArgs e)
{
try
{
string withdrawalAmmount = WithdrawTxtBox.Text.ToString();
if (string.IsNullOrEmpty(withdrawalAmmount))
{
MessageBox.Show("Please enter withdrawal amount");
return;
}
decimal dValue = Convert.ToDecimal(withdrawalAmmount);
var selectedText = AccComBox.SelectedItem.ToString().ToLower();
switch (selectedText)
{
case "checking":
CheckingAccount checkingAccount = new CheckingAccount(accountNumber, firstName, lastName);
checkingAccount.WithdrawalAmount(dValue);
ShowInfoMessage("Ammount withdrawal successfully");
eak;
case "savings":
SavingsAccount savingsAccount = new SavingsAccount(accountNumber, firstName, lastName);
savingsAccount.WithdrawalAmount(dValue);
ShowInfoMessage("Ammount withdrawal successfully");
eak;
default:
eak;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "E
or", MessageBoxButtons.OK, MessageBoxIcon.E
or);
}
}
private void Print_Click(object sender, EventArgs e)
{
try
{
var selectedText = AccComBox.SelectedItem.ToString().ToLower();
switch (selectedText)
{
case "checking":
CheckingAccount checkingAccount = new CheckingAccount(accountNumber, firstName, lastName);
ShowInfoMessage(checkingAccount.PrintStatement());
eak;
case "savings":
SavingsAccount savingsAccount = new SavingsAccount(accountNumber, firstName, lastName);
ShowInfoMessage(savingsAccount.PrintStatement());
eak;
default:
eak;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "E
or", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void Clear_Click(object sender, EventArgs e)
{
ClearUI();
}
private void Exit_Click(object sender, EventArgs e)
{
this.Close();
}
private void Balance_Click(object sender, EventArgs e)
{
try
{
var selectedText = AccComBox.SelectedItem.ToString().ToLower();
switch (selectedText)
{
case "checking":
CheckingAccount checkingAccount = new CheckingAccount(accountNumber, firstName, lastName);
ShowInfoMessage(checkingAccount.ShowBalance());
eak;
case "savings":
SavingsAccount savingsAccount = new SavingsAccount(accountNumber, firstName, lastName);
ShowInfoMessage(savingsAccount.ShowBalance());
eak;
default:
eak;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "E
or", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void WithdrawTxtBox_TextChanged(object sender, EventArgs e)
{
}
private void DepositTxtBox_TextChanged(object sender, EventArgs e)
{
}
}
}
Doan_Assignment3/BankForm.Designer.cs
namespace Doan_Assignment3
{
partial class BankForm
{
Required designer variable.
summary
private System.ComponentModel.IContainer components = null;
Clean up any resources being used.
summary
true if managed resources should be disposed; otherwise, false.
param
protected ove
ide void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
Required method for Designer support - do not modify
the contents of this method with the code editor.
summary
private void InitializeComponent()
{
this.CustomerBox = new System.Windows.Forms.GroupBox();
this.AccountNumber = new System.Windows.Forms.MaskedTextBox();
this.AccComBox = new System.Windows.Forms.ComboBox();
this.LastNameTxtBox = new System.Windows.Forms.TextBox();
this.FirstNameTxtBox = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.TransactionBox = new System.Windows.Forms.GroupBox();
this.DepositTxtBox = new System.Windows.Forms.TextBox();
this.WithdrawTxtBox = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.Welcome = new System.Windows.Forms.Button();
this.Exit = new System.Windows.Forms.Button();
this.Clear = new System.Windows.Forms.Button();
this.Print = new System.Windows.Forms.Button();
this.Balance = new System.Windows.Forms.Button();
this.Withdraw = new System.Windows.Forms.Button();
this.Deposit = new System.Windows.Forms.Button();
this.CustomerBox.SuspendLayout();
this.TransactionBox.SuspendLayout();
this.SuspendLayout();
CustomerBox
this.CustomerBox.Controls.Add(this.AccountNumber);
this.CustomerBox.Controls.Add(this.AccComBox);
this.CustomerBox.Controls.Add(this.LastNameTxtBox);
this.CustomerBox.Controls.Add(this.FirstNameTxtBox);
this.CustomerBox.Controls.Add(this.label4);
this.CustomerBox.Controls.Add(this.label3);
this.CustomerBox.Controls.Add(this.label2);
this.CustomerBox.Controls.Add(this.label1);
this.CustomerBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F,...