config.cs

来自「data structure c 学校管理系统」· CS 代码 · 共 70 行

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

namespace schoolManager
{
    public partial class config : Form
    {
        public config(string pass)
        {
            InitializeComponent();
            oldpass = pass;
        }
        public string oldpass;
        private void button1_Click(object sender, EventArgs e)
        {
            DataMessager change = new DataMessager(Application.StartupPath);
            if (textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "")
            { //更新系统密码
                if (oldpass != textBox2.Text) 
                {
                    MessageBox.Show("原始密码不匹配!","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
                    return;
                }
                string sqlstr = "update users set pass = '"+textBox3.Text+"'  where id = 1";               
                if (change.modify(sqlstr))
                { 
                    MessageBox.Show("更新成功!");
                    this.DialogResult = DialogResult.Yes; 
                }                
            }
        }

        private void textBox4_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (this.textBox4.Text.Trim() != this.textBox3.Text.Trim())
            {
                this.Text ="---密码输入不完整";
            }
            else
            {
                this.Text ="---密码验证完毕";
            }
        }

        private void textBox2_MouseClick(object sender, MouseEventArgs e)
        {
            this.textBox2.Text = "";
        }

        private void textBox3_MouseClick(object sender, MouseEventArgs e)
        {
            this.textBox3.Text = "";
        }

        private void textBox4_MouseClick(object sender, MouseEventArgs e)
        {
            this.textBox4.Text = "";
        }

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

⌨️ 快捷键说明

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