Esempio n. 1
0
        /// <summary>
        /// Button action for edting an existing account
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Change_Click(object sender, RoutedEventArgs e)
        {
            // Make sure the sure the user has selected an item in the listview
            if (lvAccounts.SelectedItem == null)
            {
                MessageBox.Show("Markera ett konto att ändra", "Inget valt konto");
                return;
            }

            // Initilize a new window for editing a customer
            AccountGUI.AccountManager accountManager = new AccountGUI.AccountManager(SelectedAccount);

            // Show the window
            accountManager.ShowDialog();

            // If the users presses OK, update the item
            if (accountManager.DialogResult.Equals(true))
            {
                // Update the database context
                AccountManagement.Instance.UpdateAccount();
            }
            else
            {
                // The user pressed cancel, revert changes
                AccountManagement.Instance.ResetAccount(SelectedAccount);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Button action for adding a new account
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            // Initilize a new window for adding a new account
            AccountGUI.AccountManager accountManager = new AccountGUI.AccountManager();

            // Show the window
            accountManager.ShowDialog();

            // If the users presses OK, add the new user
            if (accountManager.DialogResult.Equals(true))
            {
                // Add the user to the database
                AccountManagement.Instance.CreateAccount(accountManager.Account);
            }
        }