/// <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> /// Removes the entry specified in the add/remove entry textboxes. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_RemoveEntry_MouseClick(object sender, MouseEventArgs e) { if (textbox_AddPassword.TextLength > 0 && textbox_AddProgramWebsite.TextLength > 0 && textbox_AddUsername.TextLength > 0) { XMLMaker.RemoveInfoFromAccountInformationXML(completePath, textbox_AddUsername.Text, textbox_AddPassword.Text, textbox_AddProgramWebsite.Text); } AdjustEntryList(new List <string>() { textbox_AddProgramWebsite.Text }, new List <string>() { textbox_AddUsername.Text }, new List <string>() { textbox_AddPassword.Text }, -1); ResetTable(); ReenterTableEntries(); textbox_AddPassword.Clear(); textbox_AddProgramWebsite.Clear(); textbox_AddUsername.Clear(); }
//SELECT結果をXMLで返します。ノード名は指定可能、属性名はカラム名固定です。 public static XmlDocument SelectToXml(string nodeName, string sql) { XMLMaker maker = new XMLMaker(nodeName + "s"); DBHelper.Select(sql).ForEach(delegate(DataRowAccessor row) { XMLMaker.XmlMaterial xm = new XMLMaker.XmlMaterial(nodeName); foreach (DataColumn col in row.Columns) { xm.Attrs[col.ColumnName] = row[col.ColumnName]; } maker.Add(xm); }); return(maker); }
/// <summary> /// Adds an entry into the user's application username/password information. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_AddEntry_MouseClick(object sender, MouseEventArgs e) { if (textbox_AddProgramWebsite.Text.Length > 0 && textbox_AddUsername.Text.Length > 0 && textbox_AddPassword.Text.Length > 0) { Parallel.Invoke(() => AddTableRowLabels(1, new List <string>() { textbox_AddProgramWebsite.Text }, new List <string>() { textbox_AddUsername.Text }, new List <string>() { textbox_AddPassword.Text }), () => AdjustEntryList(new List <string>() { textbox_AddProgramWebsite.Text }, new List <string>() { textbox_AddUsername.Text }, new List <string>() { textbox_AddPassword.Text }, 1)); if (!File.Exists(completePath)) { Task.Run(() => XMLMaker.CreateAccountInformationXML(completePath, infoFormOwner, textbox_AddProgramWebsite.Text, textbox_AddUsername.Text, textbox_AddPassword.Text)); } else { XMLMaker.AddInfoToAccountInformationXML(completePath, textbox_AddProgramWebsite.Text, textbox_AddUsername.Text, textbox_AddPassword.Text); } textbox_AddProgramWebsite.Clear(); textbox_AddUsername.Clear(); textbox_AddPassword.Clear(); } }