You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.4 KiB
75 lines
2.4 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Sql
|
|
{
|
|
public partial class Form51 : Form
|
|
{
|
|
public Form51()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void button4_Click(object sender, EventArgs e)
|
|
{
|
|
textBox1.Text = null;
|
|
}
|
|
|
|
private void button5_Click(object sender, EventArgs e)
|
|
{
|
|
textBox2.Text = null;
|
|
}
|
|
|
|
private void button6_Click(object sender, EventArgs e)
|
|
{
|
|
textBox3.Text = null;
|
|
}
|
|
|
|
private void button3_Click(object sender, EventArgs e)
|
|
{
|
|
if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "")
|
|
{
|
|
MessageBox.Show("不能有空项", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
}
|
|
else
|
|
{
|
|
|
|
string sql = "select * from Student where Name='" + textBox1.Text + "'";//查询学生表中姓名等于第一个框中所填的数据的学生行
|
|
Dao dao = new Dao();
|
|
IDataReader dr = dao.read(sql);
|
|
dr.Read(); //这一步非常重要,缺一不可,用于读取数据
|
|
string a;
|
|
a = dr["Password"].ToString();//读取对应姓名的学生的密码是否和第二个框中的旧密码一致
|
|
if ( textBox2.Text!=a)
|
|
{
|
|
MessageBox.Show("旧密码输入错误!");
|
|
}
|
|
else
|
|
{
|
|
string sq = "update Student set Password=" + textBox3.Text + " where Name='" + textBox1.Text + "'";//如果写的旧密码正确,那么执行更新操作
|
|
// MessageBox.Show(sq);
|
|
Dao da = new Dao();
|
|
da.Execute(sq); //执行更新对应用户名密码的功能
|
|
/* sq = "update Student set Password='" + textBox2.Text + "'";
|
|
da.Execute(sq);*/
|
|
MessageBox.Show("修改密码成功");
|
|
Close();
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
}
|
|
}
|