mirror of
https://github.com/Alvin-Zilverstand/ict-algemeen-opdrachten.git
synced 2026-03-06 13:23:58 +01:00
Enhance Bankrekening methods to accept transaction descriptions and update MainForm to include a description input field
This commit is contained in:
@@ -19,13 +19,13 @@ class Bankrekening
|
|||||||
transacties = new List<Transactie>();
|
transacties = new List<Transactie>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method to deposit money into the account
|
// Method to deposit money into the account with a description
|
||||||
public void Storten(decimal bedrag)
|
public void Storten(decimal bedrag, string beschrijving)
|
||||||
{
|
{
|
||||||
if (bedrag > 0)
|
if (bedrag > 0)
|
||||||
{
|
{
|
||||||
saldo += bedrag;
|
saldo += bedrag;
|
||||||
transacties.Add(new Transactie(bedrag, "Storting"));
|
transacties.Add(new Transactie(bedrag, beschrijving));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -33,13 +33,13 @@ class Bankrekening
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method to withdraw money from the account
|
// Method to withdraw money from the account with a description
|
||||||
public void Opnemen(decimal bedrag)
|
public void Opnemen(decimal bedrag, string beschrijving)
|
||||||
{
|
{
|
||||||
if (bedrag > 0 && bedrag <= saldo)
|
if (bedrag > 0 && bedrag <= saldo)
|
||||||
{
|
{
|
||||||
saldo -= bedrag;
|
saldo -= bedrag;
|
||||||
transacties.Add(new Transactie(-bedrag, "Opname"));
|
transacties.Add(new Transactie(-bedrag, beschrijving));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -86,6 +86,7 @@ public class MainForm : Form
|
|||||||
private Bankrekening mijnRekening; // Bank account instance
|
private Bankrekening mijnRekening; // Bank account instance
|
||||||
private Label saldoLabel; // Label to display balance
|
private Label saldoLabel; // Label to display balance
|
||||||
private TextBox bedragTextBox; // TextBox to input amount
|
private TextBox bedragTextBox; // TextBox to input amount
|
||||||
|
private TextBox beschrijvingTextBox; // TextBox to input transaction description
|
||||||
private Button stortenButton; // Button to deposit money
|
private Button stortenButton; // Button to deposit money
|
||||||
private Button opnemenButton; // Button to withdraw money
|
private Button opnemenButton; // Button to withdraw money
|
||||||
private Button transactieGeschiedenisButton; // Button to view transaction history
|
private Button transactieGeschiedenisButton; // Button to view transaction history
|
||||||
@@ -114,12 +115,24 @@ public class MainForm : Form
|
|||||||
Font = new Font("Arial", 14),
|
Font = new Font("Arial", 14),
|
||||||
BackColor = Color.White,
|
BackColor = Color.White,
|
||||||
ForeColor = Color.Black,
|
ForeColor = Color.Black,
|
||||||
BorderStyle = BorderStyle.FixedSingle
|
BorderStyle = BorderStyle.FixedSingle,
|
||||||
|
PlaceholderText = "Aantal" // Placeholder text
|
||||||
|
};
|
||||||
|
beschrijvingTextBox = new TextBox()
|
||||||
|
{
|
||||||
|
Top = 100,
|
||||||
|
Left = 20,
|
||||||
|
Width = 260,
|
||||||
|
Font = new Font("Arial", 14),
|
||||||
|
BackColor = Color.White,
|
||||||
|
ForeColor = Color.Black,
|
||||||
|
BorderStyle = BorderStyle.FixedSingle,
|
||||||
|
PlaceholderText = "Beschrijving" // Placeholder text
|
||||||
};
|
};
|
||||||
stortenButton = new Button()
|
stortenButton = new Button()
|
||||||
{
|
{
|
||||||
Text = "Storten",
|
Text = "Storten",
|
||||||
Top = 100,
|
Top = 140,
|
||||||
Left = 20,
|
Left = 20,
|
||||||
Width = 260,
|
Width = 260,
|
||||||
Height = 50, // Adjusted height
|
Height = 50, // Adjusted height
|
||||||
@@ -131,7 +144,7 @@ public class MainForm : Form
|
|||||||
opnemenButton = new Button()
|
opnemenButton = new Button()
|
||||||
{
|
{
|
||||||
Text = "Opnemen",
|
Text = "Opnemen",
|
||||||
Top = 160,
|
Top = 200,
|
||||||
Left = 20,
|
Left = 20,
|
||||||
Width = 260,
|
Width = 260,
|
||||||
Height = 50, // Adjusted height
|
Height = 50, // Adjusted height
|
||||||
@@ -143,7 +156,7 @@ public class MainForm : Form
|
|||||||
transactieGeschiedenisButton = new Button()
|
transactieGeschiedenisButton = new Button()
|
||||||
{
|
{
|
||||||
Text = "Transactiegeschiedenis",
|
Text = "Transactiegeschiedenis",
|
||||||
Top = 220,
|
Top = 260,
|
||||||
Left = 20,
|
Left = 20,
|
||||||
Width = 260,
|
Width = 260,
|
||||||
Height = 50, // Adjusted height
|
Height = 50, // Adjusted height
|
||||||
@@ -161,6 +174,7 @@ public class MainForm : Form
|
|||||||
// Add controls to the form
|
// Add controls to the form
|
||||||
Controls.Add(saldoLabel);
|
Controls.Add(saldoLabel);
|
||||||
Controls.Add(bedragTextBox);
|
Controls.Add(bedragTextBox);
|
||||||
|
Controls.Add(beschrijvingTextBox); // Add the new TextBox to the form
|
||||||
Controls.Add(stortenButton);
|
Controls.Add(stortenButton);
|
||||||
Controls.Add(opnemenButton);
|
Controls.Add(opnemenButton);
|
||||||
Controls.Add(transactieGeschiedenisButton);
|
Controls.Add(transactieGeschiedenisButton);
|
||||||
@@ -177,7 +191,8 @@ public class MainForm : Form
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
decimal bedrag = decimal.Parse(bedragTextBox.Text);
|
decimal bedrag = decimal.Parse(bedragTextBox.Text);
|
||||||
mijnRekening.Storten(bedrag);
|
string beschrijving = beschrijvingTextBox.Text;
|
||||||
|
mijnRekening.Storten(bedrag, beschrijving);
|
||||||
saldoLabel.Text = $"Saldo: €{mijnRekening.ControleerSaldo():N2}";
|
saldoLabel.Text = $"Saldo: €{mijnRekening.ControleerSaldo():N2}";
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -192,7 +207,8 @@ public class MainForm : Form
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
decimal bedrag = decimal.Parse(bedragTextBox.Text);
|
decimal bedrag = decimal.Parse(bedragTextBox.Text);
|
||||||
mijnRekening.Opnemen(bedrag);
|
string beschrijving = beschrijvingTextBox.Text;
|
||||||
|
mijnRekening.Opnemen(bedrag, beschrijving);
|
||||||
saldoLabel.Text = $"Saldo: €{mijnRekening.ControleerSaldo():N2}";
|
saldoLabel.Text = $"Saldo: €{mijnRekening.ControleerSaldo():N2}";
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -224,8 +240,8 @@ class Program
|
|||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
var mijnRekening = new Bankrekening("NL01BANK0123456789", 1000);
|
var mijnRekening = new Bankrekening("NL01BANK0123456789", 1000);
|
||||||
mijnRekening.Storten(100.00m);
|
mijnRekening.Storten(100.00m, "Initial deposit");
|
||||||
mijnRekening.Opnemen(50.00m);
|
mijnRekening.Opnemen(50.00m, "ATM withdrawal");
|
||||||
|
|
||||||
Console.WriteLine("Transactiegeschiedenis:");
|
Console.WriteLine("Transactiegeschiedenis:");
|
||||||
foreach (var transactie in mijnRekening.GetTransactieGeschiedenis())
|
foreach (var transactie in mijnRekening.GetTransactieGeschiedenis())
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Bankrekening")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("Bankrekening")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+fd28e1a375b6eae866ea0240eaf196c1223efab2")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1de1230437a6adbf29a45e54436a13fd85317a76")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("Bankrekening")]
|
[assembly: System.Reflection.AssemblyProductAttribute("Bankrekening")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("Bankrekening")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("Bankrekening")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
0c34e76bda4e4d6e48fb3434c0cdb52fb67f3cfdd67f8a9433843c2f79e2732d
|
c05f8d3fe11decb89b97aa547778688959ab836daef184a25d6bb4759a57bc9c
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
|||||||
{"documents":{"C:\\Users\\steen\\Desktop\\Alvin\\ict-algemeen-opdrachten\\*":"https://raw.githubusercontent.com/Alvin-Zilverstand/ict-algemeen-opdrachten/fd28e1a375b6eae866ea0240eaf196c1223efab2/*"}}
|
{"documents":{"C:\\Users\\steen\\Desktop\\Alvin\\ict-algemeen-opdrachten\\*":"https://raw.githubusercontent.com/Alvin-Zilverstand/ict-algemeen-opdrachten/1de1230437a6adbf29a45e54436a13fd85317a76/*"}}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user