private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "") { MessageBox.Show("输入有为空,请重新确认", "警告", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (!sm.CheckStaffIsExistsByJobIDandPassword(jobid, textBox1.Text.Trim())) { MessageBox.Show("原密码输入错误,请重新确认", "警告", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox1.Text = null; textBox2.Text = null; textBox3.Text = null; } else { if (textBox2.Text == textBox3.Text) { if (sm.ChangePassword(jobid, textBox3.Text.Trim()) > 0) { if (MessageBox.Show("确认修改密码?", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK) { MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox1.Text = null; textBox2.Text = null; textBox3.Text = null; Form5 form5 = new Form5(jobid); form5.Show(); this.Hide(); } } else { MessageBox.Show("修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox1.Text = null; textBox2.Text = null; textBox3.Text = null; } } else { MessageBox.Show("两次密码不一致,请检查", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox3.Text = null; } } } }
private void button1_Click(object sender, EventArgs e) { #region 旧方法 /* string sql = "select *from staffmessage where jobID='"+jobid+"'and password='******' "; * Dao dao = new Dao(); * IDataReader dr = dao.read(sql); * if(textBox1.Text==""|| textBox2.Text == "" || textBox3.Text == "") * { * MessageBox.Show("输入有为空,请重新确认", "警告", MessageBoxButtons.OK, MessageBoxIcon.Information); * } * else * { * if (!dr.Read()) * { * MessageBox.Show("原密码输入错误,请重新确认", "警告", MessageBoxButtons.OK, MessageBoxIcon.Information); * textBox1.Text = null; * textBox2.Text = null; * textBox3.Text = null; * } * else * { * if (textBox2.Text == textBox3.Text) * { * string sq = "update staffmessage set password='******'where jobID='" + jobid + "'"; * Dao dao1 = new Dao(); * dao1.Excute(sq); * MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); * textBox1.Text = null; * textBox2.Text = null; * textBox3.Text = null; * Form4 form4 = new Form4(); * form4.Show(); * this.Hide(); * } * else * { * MessageBox.Show("两次密码不一致,请检查", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); * textBox3.Text = null; * } * } * }*/ #endregion if (textBox2.Text == textBox3.Text) { #region 旧方法 /*string sq = "update staffmessage set password='******'where jobID='" + jobid + "'"; * Dao dao1 = new Dao(); * dao1.Excute(sq);*/ #endregion sm.ChangePassword(jobid, textBox2.Text.Trim()); MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox2.Text = null; textBox3.Text = null; Form4 form4 = new Form4(); form4.Show(); this.Hide(); } else { MessageBox.Show("两次密码不一致,请检查", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox3.Text = null; } }