private void button2_Click(object sender, EventArgs e)
湖北有哪些市 {
//button2 : “确认”按钮
//修改密码
if (textBox1.Text == "")
{
MessageBox.Show("请输入原密码");
}
else if (textBox2.Text == "")
{
MessageBox.Show("请输入新密码");
}
else if (textBox3.Text == "")
{
MessageBox.Show("请确认新密码");
}
else if (textBox4.Text == "")
{
专科考研条件 MessageBox.Show("请输入验证码");
}
else if (textBox4.Text.Trim() != label5.Text)
{
MessageBox.Show("验证码输入错误");
label5_Click(null, null); //调用label5_Click事件
textBox4.Text = "";
}
else
{
MyConnection conn = new MyConnection(); //数据库地址自己写
SqlConnection myCon = conn.GetConnection();
SqlCommand myCom = myCon.CreateCommand();
myCom.CommandText = "select 密码 from Table_用户 where 学号='" + PublicData.id + "'"; //具体的字段名和表名自己改变
SqlDataAdapter myAdapter = new SqlDataAdapter();
myAdapter.SelectCommand = myCom;
DataSet mySet = new DataSet();
string yuanmima = myAdapter.Fill(mySet, "Table_用户").ToString();
if (textBox1.Text != yuanmima)
{
MessageBox.Show("原密码错误,请重新输入", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
textBox1.Text = "";
textBox1.Focus();
}
else
{
if (textBox2.Text.Trim() != textBox3.Text.Trim())
{
MessageBox.Show("两次输入的密码不一致,请重新输入!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
textBox2.Text = "";
textBox3.Text = "";
textBox2.Focus();
}
else
{
SqlCommand myCom1 = myCon.CreateCommand();
myCom1.CommandText = "update Table_用户 set 密码='" + textBox2.Text + "' where 学号='" + PublicData.id + "'";
myCon.Open();
性格 myCom1.ExecuteNonQuery();
myCom1.Dispose();
myCon.Close();
MessageBox.Show("修改成功!");
}
}
}
}
private void label5_Click(object sender, EventArgs e)
{
//生成随机验证码
母亲节红包发多少合适 string VcArray = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
string[] yanzhenma = VcArray.Split(',');
string VNum = "";
Random rand = new Random();
for (int i = 0; i < 4; i++)
{
int t = rand.Next(61);
VNum += yanzhenma[t];
}
迢迢牵牛星原文 label5.Text = VNum;
#region(生成随即验证码字体)
Random z = new Random();
int zi = z.Next(8);
switch (zi)
{
case 0:
label5.Font = new Font("华文彩云", label5.Font.Size, label5.Font.Style | FontStyle.Bold);
break;
case 1:
label5.Font = new Font("华文行楷", label5.Font.Size, label5.Font.Style | FontStyle.Bold);
break;
case 2:
label5.Font = new Font("宋体", label5.Font.Size, label5.Font.Style | FontStyle.Bold);
break;
case 3:
label5.Font = new Font("方正舒体", label5.Font.Size, label5.Font.Style | FontStyle.Bold);
break;
case 4:
看云识天气谚语 label5.Font = new Font("华文彩云", label5.Font.Size, label5.Font.Style);
break;
case 5:
label5.Font = new Font("华文行楷", label5.Font.Size, label5.Font.Style);
break;
case 6:
label5.Font = new Font("宋体", label5.Font.Size, label5.Font.Style);
break;
case 7:
label5.Font = new Font("方正舒体", label5.Font.Size, label5.Font.Style);
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论