if (!this.oldPwdBox1.Text.Equals(Class1.pwd))
{
MessageBox.Show("您输入的旧密码不正确,请从新输入");
this.oldPwdBox1.Text = "";
return;
} if (!this.pwdBox.Text.Equals(this.NewPwdBox.Text))
{
MessageBox.Show("您输入的新密码不一致,请从新输入");
this.pwdBox.Clear();
this.NewPwdBox.Clear();
return;
} try
{
string sql = string.Format(@"update [User] set [PassWord]='{0}'where [UserName]='{1}'",this.pwdBox.Text, Class1.name);
DBherpler.conn.Open();
SqlCommand comm = new SqlCommand(sql,DBherpler.conn);
int iret = comm.ExecuteNonQuery();
if (iret==1)
{
MessageBox.Show("修改成功");
}
else
{
MessageBox.Show("修改失败");
}
}
catch (Exception ex)
{ Console.WriteLine(ex.Message);
}
finally
{
DBherpler.conn.Close(); }
return;
{
MessageBox.Show("您输入的旧密码不正确,请从新输入");
this.oldPwdBox1.Text = "";
return;
} if (!this.pwdBox.Text.Equals(this.NewPwdBox.Text))
{
MessageBox.Show("您输入的新密码不一致,请从新输入");
this.pwdBox.Clear();
this.NewPwdBox.Clear();
return;
} try
{
string sql = string.Format(@"update [User] set [PassWord]='{0}'where [UserName]='{1}'",this.pwdBox.Text, Class1.name);
DBherpler.conn.Open();
SqlCommand comm = new SqlCommand(sql,DBherpler.conn);
int iret = comm.ExecuteNonQuery();
if (iret==1)
{
MessageBox.Show("修改成功");
}
else
{
MessageBox.Show("修改失败");
}
}
catch (Exception ex)
{ Console.WriteLine(ex.Message);
}
finally
{
DBherpler.conn.Close(); }
return;
那就是这句!this.oldPwdBox1.Text.Equals(Class1.pwd)返回的true