mod.cs

来自「这是一个考勤系统大家多多指教」· CS 代码 · 共 82 行

CS
82
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace kaoqin
{
    public partial class Mod : Form
    {
        public Mod()
        {
            InitializeComponent();
        }

        private void Mod_Load(object sender, EventArgs e)
        {
            string sql = "select * from [user] where name='" + DB.userName + "'";
            DataTable dt = DB.getTable(sql);
            this.textBox4.Text = dt.Rows[0]["realName"].ToString().Trim();
        }

        private void mod()
        {
            string name = DB.userName;
            string sql = "update [user] set pwd='"+this.textBox2.Text.Trim()+"',realName='"+this.textBox4.Text.Trim()+"' where name='"+name+"'";
            if (DB.executeSql(sql))
            {
                MessageBox.Show("操作成功!");
            }
            else
            {
                MessageBox.Show("操作失败!");
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text.Trim() == "")
            {
                MessageBox.Show("请输入原密码!");
                this.textBox1.Focus();
                return;
            }
            if (this.textBox2.Text.Trim() == "")
            {
                MessageBox.Show("请输入新密码!");
                this.textBox2.Focus();
                return;
            }
            if (this.textBox3.Text.Trim() == "")
            {
                MessageBox.Show("请输入确认密码!");
                this.textBox3.Focus();
                return;
            }
            if (this.textBox2.Text.Trim() != this.textBox3.Text.Trim())
            {
                MessageBox.Show("密码不一致!");
                this.textBox2.Focus();
                return;
            }
            if (this.textBox4.Text.Trim() == "")
            {
                MessageBox.Show("请输入用户姓名!");
                this.textBox4.Focus();
                return;
            }
            string sql = "select * from [user] where name='"+DB.userName+"'";
            DataTable dt = DB.getTable(sql);
            if (dt.Rows.Count == 0)
            {
                MessageBox.Show("原密码不正确!");
                this.textBox1.Focus();
                return;
            }
            mod();
        }
    }
}

⌨️ 快捷键说明

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