Exemplo n.º 1
0
        /// <summary>
        ///     Add new account to the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddButton_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 this name already exists.");
                    accountNameInput.Focus();
                    return;
                }
                else
                {
                    account = businessLogicLayer.InsertNewAccount(accountNameInput.Text.ToLower());
                    MessageBox.Show(accountNameInput.Text + " has been added to 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());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Edits an account in the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EditButton_Click(object sender, RoutedEventArgs e)
        {
            AccountObject account;
            AccountObject accountCurrent;
            AccountObject accountNew;

            accountCurrent = businessLogicLayer.CheckAccountsByName(currentAccountNameInput.Text.ToLower());
            accountNew     = businessLogicLayer.CheckAccountsByName(newAccountNameInput.Text.ToLower());
            try
            {
                if (currentAccountNameInput.Text.Equals("") || newAccountNameInput.Text.Equals(""))
                {
                    MessageBox.Show("Please input all the text boxes.");
                    currentAccountNameInput.Focus();
                    return;
                }
                else if (!currentAccountNameInput.Text.ToLower().Equals(accountCurrent.name))
                {
                    MessageBox.Show("The 'Current Account Name' does not exist.");
                    currentAccountNameInput.Focus();
                    return;
                }
                else if (newAccountNameInput.Text.ToLower().Equals(accountNew.name))
                {
                    MessageBox.Show("The 'New Account Name' already exists.");
                    newAccountNameInput.Focus();
                    return;
                }
                else
                {
                    account = businessLogicLayer.EditCurrentAccount(newAccountNameInput.Text.ToLower(), currentAccountNameInput.Text.ToLower());
                    MessageBox.Show(currentAccountNameInput.Text + " has been updated.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occurred, please contact your administrator." + "\n\n" + "The error message is: " + "\n\n" + ex.ToString());
            }
        }