Esempio n. 1
0
        // Method runs when window is loaded
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Current Accounts (First Name, Last Name, Account Number, Balance, Account Type)
            CurrentAccount ca1 = new CurrentAccount("Jane", "Jones", 45748275, 1500, "Current Account");
            CurrentAccount ca2 = new CurrentAccount("John", "Smith", 679569, 30000, "Current Account");

            // Savings Accounts (First Name, Last Name, Account Number, Balance, Account Type)
            SavingsAccount sa1 = new SavingsAccount("Joe", "Murphy", 95684, 4000, "Savings Account");
            SavingsAccount sa2 = new SavingsAccount("Jess", "Walsh", 7535737, 9999, "Savings Account");

            // Adds 4 objects to ObservableCollection<Account> Accounts
            Accounts.Add(ca1);
            Accounts.Add(ca2);
            Accounts.Add(sa1);
            Accounts.Add(sa2);

            listBox.ItemsSource = Accounts;
        }
Esempio n. 2
0
        // Code for selecting accounts from list
        private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            CurrentAccount selectedCA      = listBox.SelectedItem as CurrentAccount;
            SavingsAccount selectedSA      = listBox.SelectedItem as SavingsAccount;
            Account        accountEmployee = (Account)listBox.SelectedItem;

            // If Current Account is pressed - this if statement runs and data is displayed
            if (selectedCA != null)
            {
                textBlockFirstName.Text   = selectedCA.FirstName;
                textBlockLastName.Text    = selectedCA.LastName;
                textBlockBalance.Text     = selectedCA.Balance.ToString();
                textBlockAccountType.Text = selectedCA.Type;
            }

            // If Savings Account is pressed - this if statement runs and data is displayed
            else if (selectedSA != null)
            {
                textBlockFirstName.Text   = selectedSA.FirstName;
                textBlockLastName.Text    = selectedSA.LastName;
                textBlockBalance.Text     = selectedSA.Balance.ToString();
                textBlockAccountType.Text = selectedSA.Type;
            }
        }