I HAVE A PROJECT OF C# ABOUT THE BANK ACCOUNT. SOMEONE CAN HELP ME? THANK YOU Ac
ID: 3815967 • Letter: I
Question
I HAVE A PROJECT OF C# ABOUT THE BANK ACCOUNT. SOMEONE CAN HELP ME? THANK YOU
Account List
Remove the existing list box from the account list. Replace it with a DataGridView. The grid view will have the following columns.
Account number
Account name
Current balance, properly formatted
Checking indicator (checkbox)
Enable the following features for the grid.
Dock the grid such that it fills the entire window (except the menu).
Double clicking a row in the grid will automatically open the product for editing using the existing Edit Product form.
Disable the ability to add, edit or delete from the grid. There is no inline editing in this application.
Hide the row header.
Freeze the account number column such that it is visible even if the user scrolls to the right.
Sort the products by account number.
Allow single row selection.
Use a binding source to bind the data to the grid. Remember that refreshing the binding source requires that the DataSource property be changed.
Update any code that previously used the selected list box item to now use the selected item from the grid.
Update the code to refresh the list to properly update the grid instead.
Add/Edit Account Command
Update the form(s) to support validation. The validation logic is already implemented by the business library and simply needs to be enforced in the UI.
Add an ErrorProvider to the form.
Whenever focus leaves a control the error provider should validate the content and report errors accordingly.
Required fields should be flagged as required.
Invalid balance should be flagged as invalid.
When the user clicks Add the validation in the UI should be run along with any validation defined by the Product class. If validation fails then do not attempt to save the product and close the form.
When saving the data to the store ensure any exceptions thrown by the store are captured and reported to the user.
If the save fails then return the user to the form so they may fix their mistakes. Note that is OK to close the form and then reopen to allow reusing the existing code.
Clicking the Cancel button does not do any validation and simply closes the form as usual.
Explanation / Answer
using System;
public class BankAccount {
protected double interestRate;
protected string ownerName;
protected decimal balance;
public BankAccount(string o, decimal b, double ir) {
this.interestRate = ir;
this.ownerName = o;
this.balance = b;
}
public BankAccount(string o, double ir):
this(o, 0.0M, ir) {
}
public virtual decimal Balance {
get {return balance;}
}
public virtual void Withdraw (decimal amount) {
balance -= amount;
}
public virtual void Deposit (decimal amount) {
balance += amount;
}
public virtual void AddInterests() {
balance += balance * (Decimal)interestRate;
}
public override string ToString() {
return ownerName + "'s account holds " +
+ balance + " kroner";
}
}
using System;
public class CheckAccount: BankAccount {
public CheckAccount(string o, double ir):
base(o, 0.0M, ir) {
}
public CheckAccount(string o, decimal b, double ir):
base(o, b, ir) {
}
public override void Withdraw (decimal amount) {
balance -= amount;
if (amount < balance)
interestRate = -0.10;
}
public override string ToString() {
return ownerName + "'s check account holds " +
+ balance + " kroner";
}
}
using System;
public class SavingsAccountDtlsDtls: BankAccount {
public SavingsAccountDtls(string o, double ir):
base(o, 0.0M, ir) {
}
public SavingsAccountDtls(string o, decimal b, double ir):
base(o, b, ir) {
}
public override void Withdraw (decimal amount) {
if (amount < balance)
balance -= amount;
else
throw new Exception("Cannot withdraw");
}
public override void AddInterests() {
balance = balance + balance * (decimal)interestRate
- 100.0M;
}
public override string ToString() {
return ownerName + "'s savings account holds " +
+ balance + " kroner";
}
}
using System;
public class LotteryAccountDts: BankAccount {
private static Lottery lottery = Lottery.Instance(20);
public LotteryAccountDts(string o, decimal b):
base(o, b, 0.0) {
}
public override void AddInterests() {
int luckyNumber = lottery.DrawLotteryNumber;
balance = balance + lottery.AmountWon(luckyNumber);
}
public override string ToString() {
return ownerName + "'s lottery account holds " +
+ balance + " kroner";
}
}
using System;
public class LotteryTest{
private static Random rdm =
new Random(unchecked((int)DateTime.Now.Ticks));
private int difficulty;
private readonly int winningNumber;
private readonly decimal amountWon;
private static LotteryTest uniqueInstance = null;
private LotteryTest(int difficulty){
this.difficulty = difficulty;
this.winningNumber = rdm.Next(difficulty);
this.amountWon = 500000.00M;
}
public static LotteryTest Instance(int difficulty){
if (uniqueInstance == null)
uniqueInstance = new Lottery(difficulty);
return uniqueInstance;
}
public int DrawLotteryNumber{
get {return rdm.Next(difficulty);}
}
public decimal AmountWon(int luckyNumber){
decimal res;
if (WinningNumber(luckyNumber))
res = amountWon;
else
res = 0.0M;
return res;
}
private bool WinningNumber(int n){
return n == winningNumber;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.