|
private void button1_Click(object sender, EventArgs e)
{
try
{
conn = new SqlConnection();
conn.ConnectionString = "server=.; database=小区物业管理系统;uid=sa;pwd=qwe123!;";
conn.Open();
string sql = "select * from userTable where userid='"+this.comboBox1.Text.ToString()+ "'";
sda = new SqlDataAdapter(sql, conn);
dataset = new DataSet();
sda.Fill(dataset, "userTable");
conn.Close();
if (dataset.Tables["userTable"].Rows[0][1].ToString() == this.textBox1.Text.ToString())
{
if (this.textBox3.Text.ToString() == this.textBox2.Text.ToString())
{
conn.Open();
string sq = "UPDATE userTable SET userpwd = '" + this.textBox2.Text.ToString() + "' where userid='" + this.comboBox1.Text.ToString() + "'";
sda = new SqlDataAdapter(sq, conn);
dataset = new DataSet();
sda.Fill(dataset, "userTable");
conn.Close();
MessageBox.Show("修改成功!!");
}
else
{
MessageBox.Show("两次输入的密码不一致!!");
}
}
else
{
MessageBox.Show("旧密码不对!!");
}
}
catch (Exception ee)
{
MessageBox.Show(ee.Message.ToString());
}
finally
{
conn.Close();
}
}
|
|