/// <summary> /// Saves new account if possible. /// </summary> /// <param name="sender">Contains a reference to the control that raised the event.</param> /// <param name="e">Contains the event data.</param> private void buttonSave_Click(object sender, EventArgs e) { string Username = textBoxUsername.Text; string Password = textBoxPassword.Text; if (string.IsNullOrWhiteSpace(textBoxUsername.Text) || string.IsNullOrWhiteSpace(textBoxPassword.Text)) { MessageBox.Show("Username or Password can't be whitespace!!!"); return; } else { if (bs.GetUser(Username) == null) { bs.AddUser(Username, Form_Login.EncryptString(Password)); MessageBox.Show("Account Added"); dataGridView1.Rows.Clear(); LoadDataGridViewInUsersSection(); } else { MessageBox.Show("Username already exists. Try with another one."); } } }
/// <summary> /// Creates new user. /// </summary> /// <param name="sender">Contains a reference to the control that raised the event.</param> /// <param name="e">Contains the event data.</param> private void button_Register_Click(object sender, EventArgs e) { string Username = textBox_Username.Text; string password = textBox_Password.Text; if (string.IsNullOrWhiteSpace(textBox_Username.Text) || string.IsNullOrWhiteSpace(textBox_Password.Text)) { MessageBox.Show("Username or Password can't be whitespace!!!"); return; } else { if (business.GetUser(Username) == null) { EncryptString(password); business.AddUser(Username, EncryptString(password)); MessageBox.Show("You can now log in your account!"); } else { MessageBox.Show("Username already exists. Try again."); } } }