⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frm-passmodify.cs

📁 这是我个人写的一个实例用于登记公司的电脑信息
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace 计算机及IP管理
{
    public partial class frm_passModify : Form
    {
        UserCls cls = new UserCls();
        DataSet myds;
        public frm_passModify()
        {
            InitializeComponent();
        }
        private void btnModify_Click(object sender, EventArgs e)
        {
            if (txtName.Text.Trim() == string.Empty)
            {
                MessageBox.Show("帐号不能为空!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtName.Focus();
                return;
            }
            if (txtoldpass.Text.Trim() == string.Empty)
            {
                MessageBox.Show("原密码不能为空!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtoldpass.Focus();
                return;
            }
            if (txtnewpass.Text.Trim() == string.Empty)
            {
                MessageBox.Show("新密码不能为空!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtnewpass.Focus();
                return;
            }
            if (txtnewfirm.Text.Trim() == string.Empty)
            {
                MessageBox.Show("新密码确认不能为空!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtnewfirm.Focus();
                return;
            }
            if (!txtnewpass.Text.Trim().Equals(txtnewfirm.Text.Trim()))
            {
                MessageBox.Show("确认密码与新密码不同!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);              
                txtnewfirm.Focus();
                return;
            }
            string strselec = "select * from t_user where name='" + txtName.Text.Trim() + "'and psw='" + txtoldpass.Text.Trim() + "'";
            myds = cls.GetDataSet(strselec, "t_user");
            if (myds.Tables[0].Rows.Count > 0)
            {
                string strupdate = "update t_user set psw='" + txtnewfirm.Text.Trim() + "'where psw='" + txtoldpass.Text.Trim() + "'and name='" + txtName.Text.Trim() + "'";
                if (cls.ExecSqlString(strupdate))
                {
                    MessageBox.Show("修改成功", "OK", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("用户名或密码有误", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }                
            
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -