public void openCurrentAccount(long accountId) { CurrentAccount currentAccount = new CurrentAccount(); currentAccount.id = accountId; currentAccount.CustomerNumber = accountId.ToString(); currentAccount.OverdraftAmount = 0; currentAccount.Balance = 0; SystemDB.DBInstance.currentAccounts.Add(currentAccount); bankAccount.SaveBankAccount(); }
private SystemDB() { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(@"Data/BankAccounts.xml"); foreach (XmlNode node in xmlDoc.DocumentElement.ChildNodes) { switch (node.Attributes["AccountType"].InnerText) { case "Savings": SavingsAccount savingsAccount = new SavingsAccount(); foreach (XmlNode childNode in node.ChildNodes) { switch (childNode.Name) { case "ID": savingsAccount.id = Convert.ToInt64(childNode.InnerText); break; case "CustomerNumber": savingsAccount.CustomerNumber = childNode.InnerText; break; case "Balance": savingsAccount.Balance = Convert.ToInt64(childNode.InnerText); break; } } savingsAccounts.Add(savingsAccount); bankAccountIDs.Add(savingsAccount.id); break; case "Current": CurrentAccount currentAccount = new CurrentAccount(); foreach (XmlNode childNode in node.ChildNodes) { switch (childNode.Name) { case "ID": currentAccount.id = Convert.ToInt64(childNode.InnerText); break; case "CustomerNumber": currentAccount.CustomerNumber = childNode.InnerText; break; case "Balance": currentAccount.Balance = Convert.ToInt64(childNode.InnerText); break; case "OverdraftAmount": currentAccount.OverdraftAmount = Convert.ToInt64(childNode.InnerText); break; } } currentAccounts.Add(currentAccount); bankAccountIDs.Add(currentAccount.id); break; } } }