changepassword.cs

来自「人事管理系统」· CS 代码 · 共 52 行

CS
52 行
字号
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 + =
减小字号Ctrl + -
显示快捷键?