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; using WindowsFormsApp1.db; using WindowsFormsApp1.mod; namespace WindowsFormsApp1.form { public partial class UserChangeP : Form { public UserChangeP() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { this.Close(); } private void button1_Click(object sender, EventArgs e) { if(string.IsNullOrEmpty(textBox1.Text)|| string.IsNullOrEmpty(textBox2.Text)|| string.IsNullOrEmpty(textBox3.Text)) { MessageBox.Show("新旧密码不能为空!"); return; } if (textBox1.Text != Init.t_User.password) { MessageBox.Show("原密码不正确!"); return; } if (textBox2.Text != textBox3.Text) { MessageBox.Show("两次新密码不一致!"); return; } Init.t_User.password = textBox2.Text; SQLiteHelper userHelper = new SQLiteHelper(); var result = userHelper.Update(Init.t_User); if (!result.Success) { MessageBox.Show("密码修改失败!"); return; } MessageBox.Show("密码修改成功"); this.Close(); } } }