/// <summary> /// Creates a new account for a user, as long as the username doesn't already exist. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_CreateAccount_MouseClick(object sender, MouseEventArgs e) { bool CanCreateAccount; bool UsernameExists = false; XMLChecker.ReadUserXMLForCreate(completePath, textbox_CreateUsername.Text, ref UsernameExists); CheckInputsAreValid(out CanCreateAccount); if (CanCreateAccount && !File.Exists(completePath) && !UsernameExists) { XMLMaker.CreateUserXML(completePath, textbox_CreateUsername.Text, textbox_CreatePassword.Text); MessageBox.Show("User added successfully.", "User Created", MessageBoxButtons.OK); textbox_CreateUsername.Clear(); textbox_CreatePassword.Clear(); textbox_ConfirmPassword.Clear(); } else if (CanCreateAccount && File.Exists(completePath) && !UsernameExists) { XMLMaker.AddUser(completePath, textbox_CreateUsername.Text, textbox_CreatePassword.Text); MessageBox.Show("User added successfully.", "User Created", MessageBoxButtons.OK); textbox_CreateUsername.Clear(); textbox_CreatePassword.Clear(); textbox_ConfirmPassword.Clear(); } else if (CanCreateAccount && UsernameExists) { MessageBox.Show("An account with this username already exists. Please use a different username or login.", "Account Creation Error", MessageBoxButtons.OK); } }
/// <summary> /// Searches for a password based on the information entered in the search textboxes. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_SearchForEntry_MouseClick(object sender, MouseEventArgs e) { if (textbox_GetProgramWebsite.TextLength > 0 && textbox_GetAccountUsername.TextLength > 0) { textbox_ReturnSearch.Text = XMLChecker.SearchAppInfoInUserInfoXML(completePath, textbox_GetAccountUsername.Text, textbox_GetProgramWebsite.Text); } }
/// <summary> /// Reads the user's information file and fills the rows in the table in the turtle word info form with the information it pulls. /// </summary> private void PopulateForm() { ResetTable(); int numRows = 0; Dictionary <int, List <string> > info; info = XMLChecker.ReadUserInfoXML(completePath, ref numRows); Parallel.Invoke(() => AddTableRowLabels(numRows, info[0], info[1], info[2]), () => AdjustEntryList(info[0], info[1], info[2], 1)); }
/// <summary> /// Checks the login information a user enters. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_Login_MouseClick(object sender, MouseEventArgs e) { bool isAnAccount = false; if (File.Exists(completePath)) { if (textbox_Username.Text.Length == 0 || textbox_Password.Text.Length == 0) { MessageBox.Show("A username and/or password has not been entered. Please re-enter your username and password", "Login Error", MessageBoxButtons.OK); } else { XMLChecker.ReadUserXMLForLogin(completePath, textbox_Username.Text, textbox_Password.Text, ref isAnAccount); if (isAnAccount) { //DoLoginStuff TurtleWordInfoForm passForm = new TurtleWordInfoForm(textbox_Username.Text); passForm.ChildFormClosed += OnChildFormClosed; this.Hide(); passForm.Show(); textbox_Username.Clear(); textbox_Password.Clear(); textbox_CreateUsername.Clear(); textbox_CreatePassword.Clear(); textbox_ConfirmPassword.Clear(); } else { MessageBox.Show("Username and/or password not found. Make sure you typed the information in correctly" + " and please try again.", "Login Error", MessageBoxButtons.OK); } } } else { MessageBox.Show("No users have been created for use in this program. Please create a user.", "Login Error", MessageBoxButtons.OK); } }