public bool TryLogin(string username, string password, out string hashCode)
        {
            AccountManager accountManager = new AccountManager(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString, ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);
            bool loginSuccess = accountManager.TryLogin(username, password, out hashCode);

            return loginSuccess;
        }
        protected void ButtonOk_Click(object sender, EventArgs e)
        {
            AccountManager accountManager = new AccountManager(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString,
                ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);

            TextBox UsernameTextBox = LoginView.FindControl("UsernameTextBox") as TextBox;
            TextBox PasswordTextBox = LoginView.FindControl("PasswordTextBox") as TextBox;
            Label UsernameExistsLabel = LoginView.FindControl("UsernameExistsLabel") as Label;

            if (Page.IsValid)
            {
                try
                {
                    accountManager.InsertUser(UsernameTextBox.Text, PasswordTextBox.Text);
                    Response.Redirect("~/AccountCreated.aspx");
                }
                catch (SqlException)
                {
                    UsernameExistsLabel.Text = "Username exists, choose a different one.";
                }
            }
        }
        protected void ButtonLoginOk_Click(object sender, EventArgs e)
        {
            AccountManager accountManager = new AccountManager(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString,
               ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);

            TextBox UsernameTextBox = LoginView.FindControl("UsernameTextBox") as TextBox;
            TextBox PasswordTextBox = LoginView.FindControl("PasswordTextBox") as TextBox;
            Label WrongUsernamePasswordLabel = LoginView.FindControl("WrongUsernamePasswordLabel") as Label;

            if (Page.IsValid)
            {
                int userId = accountManager.GetUserIdByUsernameAndPassword(UsernameTextBox.Text, PasswordTextBox.Text);

                if (userId < 1)
                {
                    WrongUsernamePasswordLabel.Text = "Wrong username or password.";
                }
                else
                {
                    Session["UserId"] = userId;
                    FormsAuthentication.RedirectFromLoginPage(UsernameTextBox.Text, false);
                }
            }
        }