📄 frmdeluser.cs
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -