📄 form8.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.Odbc;
namespace ming
{
public partial class Form8 : Form
{
public Form8()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
if (textBox4.Text == "")
{
MessageBox.Show("用户名不能为空!");
textBox4.Select();
}
else if (textBox5.Text == "")
{
MessageBox.Show("密码不能为空!");
textBox5.Select();
}
else if (textBox6.Text == "")
{
MessageBox.Show("密码不能为空!");
textBox6.Select();
}
else if (textBox5.Text == textBox6.Text)
{
MessageBox.Show("两次输入密码一致,请重新输入!");
}
else
{
string username = this.textBox4.Text.ToString();
string pwd = this.textBox5.Text.ToString();
string pwd2 = this.textBox6.Text.ToString();
string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" +
"SERVER=localhost;" +
"DATABASE=user_imformation;" +
"UID=root;" +
"PASSWORD=123;" +
"OPTION=3";
OdbcConnection MyConnection = new OdbcConnection(MyConString);
MyConnection.Open();
OdbcCommand MyCommand = MyConnection.CreateCommand();
MyCommand.CommandText = "Select * from user_imformation where username='" + username + "'";
OdbcDataReader MyReader = MyCommand.ExecuteReader();
if (MyReader.Read())
{
if (MyReader["password"].ToString().Trim() == pwd)
{
OdbcCommand cmd = new OdbcCommand("UPDATE user_imformation SET password = '" + pwd2 + "' where username='" + username + "'", MyConnection);
cmd.ExecuteNonQuery();
MessageBox.Show("修改成功");
Close();
}
else
{
MessageBox.Show("密码错误");
}
}
else
{
MessageBox.Show("没有此用户");
}
MyConnection.Close();
MyReader.Close();
}
}
private void button4_Click(object sender, EventArgs e)
{
Close();
}
private void tabPage1_Click(object sender, EventArgs e)
{
}
private void Form8_Load(object sender, EventArgs e)
{
textBox6.UseSystemPasswordChar = true;
textBox5.UseSystemPasswordChar = true;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -