-
Notifications
You must be signed in to change notification settings - Fork 0
/
Manager.master.cs
123 lines (108 loc) · 3.96 KB
/
Manager.master.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Manager : System.Web.UI.MasterPage
{
Bank BankSys1;
private DAL2 DAL;
private Account a;
private Customer c;
private string pin;
protected void Page_Load(object sender, EventArgs e)
{
//retrieving pin from the session
pin = Session["pin"].ToString();
if (Session["Bank"] == null)
{
//sends the user back to the main menu
Response.Redirect("~/Index.aspx");
}
else
{
//retrieving bank from the session
BankSys1 = (Bank)Session["Bank"];
//filling the labels with designated data
lblExchRate.Text = "Exchange Rate: " + BankSys1.getexchangerate().ToString();
lblTimeUsed.Text = "Times Used: "+BankSys1.gettimeused().ToString();
lblFailedLogins.Text = "Failed logins: "+BankSys1.getfailedlogins().ToString();
lblCardsret.Text = "Cards Retained: "+BankSys1.getCardsRet().ToString();
LblTotalBal.Text = "Total Balance: "+BankSys1.gettotalbal().ToString();
LblAmountWithdrawn.Text = "Amount Withdrawn: "+BankSys1.getwithdrawls().ToString();
}
}
protected void lBtnStartup_Click(object sender, EventArgs e)
{
//sends the user back to the main menu
Response.Redirect("~/Index.aspx");
DAL.retrieveAllAccountData();
}
protected void lBtnMaintenance_Click(object sender, EventArgs e)
{
//making relevant content box show and the shutdown button invisible
CPHContent.Visible = true;
Shutdown.Visible = false;
}
protected void lBtnShutdown_Click(object sender,EventArgs e)
{
//making relevant text boxes visible and others disappear
LblAmountWithdrawn.Visible = false;
lblCardsret.Visible = false;
lblErrorMSG.Visible = false;
lblExchRate.Visible = false;
lblTimeUsed.Visible = false;
LblTotalBal.Visible = false;
lBtnExchRate.Visible = false;
TxtRate.Visible = false;
lblFailedLogins.Visible = false;
Shutdown.Visible = true;
}
protected void lBtnManagerHome_Click(object sender, EventArgs e)
{
}
protected void lBtnExchRate_Click(object sender,EventArgs e)
{
if (TxtRate.ToString() != "")
{
decimal exchRate;
//getting exchrate from the text box and converting it to deciamal
exchRate = Convert.ToDecimal(TxtRate.Text);
//set the banks exchangerate to exchrate
BankSys1.setexchangerate(exchRate);
//save banksys1 to the session
Session["Bank"] = BankSys1;
//display the current exch rate in the box
lblExchRate.Text = "Exchange Rate: " + BankSys1.getexchangerate().ToString();
}
else
{
//error message
lblErrorMSG.Text = "Error";
}
}
protected void Shutdown_Click(object sender, EventArgs e)
{
//retrieving bank from the session
Bank BankSys1 = (Bank)Session["Bank"];
string pin = (string)Session["pin"];
//for each loop to insert all Customers accounts in the customers accounts dictionary into the database
DAL = new DAL2();
//loop through each each customer
foreach (KeyValuePair<string, Customer> kvp in BankSys1.getcustomerData())
{
c = kvp.Value;
//loop through cust account
foreach (KeyValuePair<string, Account> kvp1 in c.getAccounts())
{
//run update acc from the DAL
DAL.updateAccountData(kvp1.Value);
}
}
//Abandoning session and redirecting user the index
Session.Abandon();
Response.Redirect("..\\Index.aspx");
}
}