frmdeluser.cs

来自「学生宿舍管理系统 学生宿舍管理系统」· 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;
using System.Data.OleDb;

namespace 学生宿舍管理系统
{
    public partial class FrmDelUser : Form
    {
        public FrmDelUser()
        {
            InitializeComponent();
        }
        
        private void button1_Click(object sender, EventArgs e)
        {
            
            string s1 = "select * from 登录信息表 where 用户名='" + comboBox1.Text + "'";
            string passward="";
             MyData mydata = new MyData();
            OleDbDataReader dr = mydata.getDataReader(s1);
            while (dr.Read())
            {
                passward = dr["密码"].ToString().Trim();
            }
            if (comboBox1.Text == "") return;
            if (passward == textBox2.Text)
            {
                string s2 = "delete from 登录信息表 where 用户名='" + comboBox1.Text + "'";
                mydata.updateSql(s2);
                MessageBox.Show("用户删除成功!","提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                f();
                comboBox1.Text = "";
                textBox2.Text = "";
            }
            else
            {
                MessageBox.Show("密码错误,不允许删除!","警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox2.Text = "";
            }
            mydata.closeConnection();
        }

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

        private void FrmDelUser_Load(object sender, EventArgs e)
        {
            f();
        }
        public void f()
        {
            comboBox1.Items.Clear();            
            string s3 = "select 用户名 from 登录信息表 ";
            MyData mydata = new MyData();
            OleDbDataReader dr = mydata.getDataReader(s3);
            while (dr.Read())
            {
                comboBox1.Items.Add(dr["用户名"].ToString().Trim());
            }
            mydata.closeConnection();
        }
    }
}

⌨️ 快捷键说明

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