forked from mattbuhagiar/SOFT130
/
account_view.cs
99 lines (78 loc) · 3.36 KB
/
account_view.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
namespace SOFT130Project
{
public partial class frmAccountView : Form
{
public frmAccountView(file this_fileClass)
{
InitializeComponent();
fileClass = this_fileClass;
}
bool showMainMenu = true;
file fileClass;
private void frmAccountView_Load(object sender, EventArgs e)
{
tmrDateTime_Tick(sender, e);
int currentCustomerNum = fileClass.getcurrentCustomerNum();
int currentAccountNum = fileClass.getcurrentAccountNum();
int currentTransactionNum = 0;
ArrayList returnedData = fileClass.readFile();
Customer thisCustomer = (Customer) returnedData[currentCustomerNum];
ArrayList accountList = thisCustomer.getaccountList();
Account thisAccount = (Account) accountList[currentAccountNum];
lblCustomer.Text = thisCustomer.getfirstName() + " " + thisCustomer.getsurname() + " - " + thisCustomer.getpostcode();
lblAccountNickName.Text = thisAccount.getnickName();
lblAccountNumber.Text = Convert.ToString(thisAccount.getaccountNumber());
lblAccountSortCode.Text = thisAccount.getsortCode();
lblAccountBalance.Text = String.Format("{0:c}", thisAccount.getcurrentBalance());
foreach (Transaction oneTransaction in thisAccount.gettransactionList())
{
DataGridViewRow dgvRow = new DataGridViewRow();
DataGridViewCell dgvCell = new DataGridViewTextBoxCell();
dgvCell.Value = currentTransactionNum;
dgvRow.Cells.Add(dgvCell);
dgvCell = new DataGridViewTextBoxCell();
dgvCell.Value = oneTransaction.getdate();
dgvRow.Cells.Add(dgvCell);
dgvCell = new DataGridViewTextBoxCell();
dgvCell.Value = oneTransaction.gettype();
dgvRow.Cells.Add(dgvCell);
dgvCell = new DataGridViewTextBoxCell();
dgvCell.Value = oneTransaction.getdescription();
dgvRow.Cells.Add(dgvCell);
dgvCell = new DataGridViewTextBoxCell();
dgvCell.Value = oneTransaction.getamount();
dgvRow.Cells.Add(dgvCell);
dgvCell = new DataGridViewTextBoxCell();
dgvCell.Value = oneTransaction.getbalanceAfter();
dgvRow.Cells.Add(dgvCell);
dgvTransactions.Rows.Add(dgvRow);
currentTransactionNum++;
}
dgvTransactions.Refresh();
}
private void frmAccountView_FormClosing(object sender, FormClosingEventArgs e)
{
if (showMainMenu)
{
frmMainMenu frmMainMenu = new frmMainMenu();
frmMainMenu.Show();
}
}
private void tmrDateTime_Tick(object sender, EventArgs e)
{
DateTime CurrTime = DateTime.Now;
lblDate.Text = CurrTime.ToString("D");
lblTime.Text = CurrTime.ToString("hh:mm:ss tt", CultureInfo.CreateSpecificCulture("en-US"));
}
}
}