📄 changepassword.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.SqlClient;
namespace 人事管理
{
public partial class changepassword : Form
{
data da = new data();
login login = new login();
public changepassword()
{
InitializeComponent();
}
//确定
private void yesbtn_Click(object sender, EventArgs e)
{
if (newpasswordtxt.Text != repasswordbtn.Text)
{
MessageBox.Show("确认密码错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else if (oldpasswordtxt.Text != login.passwordtxt.Text)
{
MessageBox.Show("旧密码错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
SqlDataAdapter sqlda = new SqlDataAdapter("select * from Worker", da.link());
SqlCommand sqlcomm = new SqlCommand("update Worker set WorkerPassword=@WorkerPassword where WorkerLogin='" + login.loginnametxt.Text + "' and WorkerPassword='" + login.passwordtxt.Text + "'", da.link());
sqlcomm.Parameters.AddWithValue("@WorkerPassword", newpasswordtxt.Text);
sqlda.UpdateCommand = sqlcomm;
sqlda.UpdateCommand.ExecuteNonQuery();
MessageBox.Show("修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.Close();
}
}
//取消
private void outbtn_Click(object sender, EventArgs e)
{
DialogResult sss = MessageBox.Show("请确认要退出!", "请确认要退出!", MessageBoxButtons.YesNo);
if (sss == DialogResult.Yes)
{
this.Close();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -