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"); }