예제 #1
0
        /// <summary>
        ///     Deletes an account from the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            AccountObject account = new AccountObject();

            account = businessLogicLayer.CheckAccountsByName(accountNameInput.Text.ToLower());
            try
            {
                if (accountNameInput.Text.Equals(""))
                {
                    MessageBox.Show("Please input the text box.");
                    accountNameInput.Focus();
                    return;
                }
                else if (!accountNameInput.Text.ToLower().Equals(account.name))
                {
                    MessageBox.Show("An account with that name does not exist.");
                    accountNameInput.Focus();
                    return;
                }
                else
                {
                    account = businessLogicLayer.DeleteCurrentAccount(accountNameInput.Text.ToLower());
                    MessageBox.Show(accountNameInput.Text + " has been deleted from the system.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString());
            }
        }