I am new to C#. I am trying to enter a password in textbox1 to login to my form. This login button enables certain controls. This works. Here is where the problem starts. I have made a change password section also where I enter the old password in textbox2, new password in textbox3 and confirm password in text box4. What I want is for the password to update from textbox3 or textbox4 and then be set as the password. So whatever was entered in textbox3 or textbox 4 is now the password. And when I enter this new changed password in textbox1 it logs in. I have tried everything I can think of with no solution. Here is the code I am using.
private void button14_Click(object sender, EventArgs e) // Main Screen Password Login Button
{
String passWord;
passWord = "login";
if (textBox1.Text == passWord)
{
passWord = textBox3.Text;
// textBox1.Clear();
button1.Enabled = false;
button2.Enabled = false;
button3.Enabled = true;
button4.Enabled = true;
button5.Enabled = true;
button6.Enabled = true;
button7.Enabled = true;
button8.Enabled = true;
button9.Enabled = true;
button10.Enabled = true;
button11.Enabled = true;
button12.Enabled = false;
button16.Enabled = true;
button16.Visible = true;
button20.Enabled = true;
numericUpDown1.Enabled = true;
numericUpDown2.Enabled = true;
button14.Click += ResetTimer;
}
else
{
MessageBox.Show("Password is Incorrect");
textBox1.Clear();
}
}
private void button19_Click(object sender, EventArgs e) // Admin Confirm Old Password Button
{
// String passWord;
// passWord = textBox2.Text;
if (textBox1.Text == textBox2.Text)
{
//MessageBox.Show("Password is Correct");
textBox3.Enabled = true;
textBox4.Enabled = true;
}
else
{
MessageBox.Show("Password is Incorrect");
}
private void button17_Click(object sender, EventArgs e) // Admin Update New password Button
{
String passWord;
//passWord = textBox3.Text;
// passWord = textBox3.Text;
// passWord = textBox4.Text;
if(textBox3.Text == textBox4.Text)
{
passWord = textBox3.Text;
MessageBox.Show("Password Changed");
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox3.Enabled = false;
textBox4.Enabled = false;
}
else
{
MessageBox.Show("Password Does Not Match");
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox3.Enabled = false;
textBox4.Enabled = false;
}
button17.Click += ResetTimer;
}
So when I click button17 I want the password to change to whatever is entered in textbox3 or textbox4. This new password will then be used to login at textbox1. I hope I described my problem correctly. Any help will be much appreciated. Thank you. Jennifer.