-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard.cs
88 lines (70 loc) · 2.24 KB
/
dashboard.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
using UITimer = System.Windows.Forms.Timer;
namespace Banking_App
{
public partial class Dashboard : Form
{
private Dictionary<string, string> user;
private readonly UITimer updateTimer;
private bool isUpdateRunning = false;
public Dashboard(Dictionary<string, string> loggedInUser)
{
user = loggedInUser;
InitializeComponent();
updateTimer = new UITimer
{
Interval = 1000
};
updateTimer.Tick += UpdateTimerTick;
updateTimer.Start();
}
private void UpdateTimerTick(object? sender, EventArgs e)
{
if (isUpdateRunning)
return;
isUpdateRunning = true;
Update_balance_r();
isUpdateRunning = false;
}
private void Update_balance_r()
{
var userRows = FileSystemCus.FindOne("users", user["id"]);
if (userRows.Count == 0)
return;
user = userRows;
Update_balance(user["balance"]);
}
private void Dashboard_Load(object sender, EventArgs e)
{
user_label.Text = user["full_name"];
card_value.Text = user["card_number"];
expiry_value.Text = "02/" + user["expiry"];
cvc_value.Text = user["cvc"];
Update_balance(user["balance"]);
}
public void Update_balance(string amount)
{
var amountCr = double.Parse(amount);
amount_label.Text = $"{amountCr:N0}";
}
private void Add_money_button_Click(object sender, EventArgs e)
{
new AddMoney(user, Show).Show();
Hide();
}
private void Send_money_button_Click(object sender, EventArgs e)
{
new SendMoney(user, Show).Show();
Hide();
}
private void Transactions_button_Click(object sender, EventArgs e)
{
new Transactions(user, Show).Show();
Hide();
}
private void Withdraw_money_button_Click(object sender, EventArgs e)
{
new WithdrawMoney(user, Show).Show();
Hide();
}
}
}