コード例 #1
0
        private void Newaccount_btn_Click(object sender, EventArgs e)
        {
            // get textbox value
            string account_name = account_textbox.ForeColor == Color.Black ? account_textbox.Text : "";

            // verify that a name is given
            if ("".Equals(account_name))
            {
                ErrorMessenger.EmptyField("Account name");
                return;
            }

            // verify that a user is selected
            if (CURRENT_USER.Equals(""))
            {
                ErrorMessenger.Error("User must be selected to attribute account to!");
                return;
            }

            // verify if user already has same name account
            if (new List <String>(CURRENT_USER_ACCOUNTS.Keys).Contains(account_name))
            {
                ErrorMessenger.Error("User already has an account with the same name!");
                return;
            }

            // insert new account into 'money_accounts' and 'users_money_accounts' tables
            DB_API.InsertMoneyAccount(CURRENT_USER, account_name);

            Populate_moneyAccounts_listBox(CURRENT_USER);
        }