📄 manage_user.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.SqlClient;
namespace 超市信息管理系统.MarketSystem
{
public partial class Manage_User : Form
{
private string sql = "select * from sysuser";
public Manage_User()
{
InitializeComponent();
}
private void Manage_User_Load(object sender, EventArgs e)
{
sqlDataAdapter1.Fill(dataSet11);
}
private void button1_Click(object sender, EventArgs e)
{
string StrSql = "update Sysuser set userStyle='"+comboBox1.Text.Trim()+"' where userID='"+textBox1.Text.Trim()+"'";
SqlCommand com = new SqlCommand(StrSql,sqlConnection1);
sqlConnection1.Open();
com.ExecuteNonQuery();
sqlConnection1.Close();
sqlConnection1.Open();
com = new SqlCommand(sql,sqlConnection1);
sqlDataAdapter1.SelectCommand = com;
dataSet11.Clear();
sqlDataAdapter1.Fill(dataSet11);
sqlConnection1.Close();
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
string delete = "delete from sysuser where userID='"+textBox1.Text.Trim()+"'";
SqlCommand com = new SqlCommand(delete,sqlConnection1);
sqlConnection1.Open();
com.ExecuteNonQuery();
sqlConnection1.Close();
com = new SqlCommand(sql,sqlConnection1);
sqlConnection1.Open();
sqlDataAdapter1.SelectCommand = com;
dataSet11.Clear();
sqlDataAdapter1.Fill(dataSet11);
sqlConnection1.Close();
}
private void setNull()
{
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
}
private void setPassNUll()
{
textBox3.Text = "";
textBox4.Text = "";
}
private void button4_Click(object sender, EventArgs e)
{
if (textBox2.Text.Trim() == string.Empty || textBox3.Text.Trim() == string.Empty)
{
MessageBox.Show("管理员编号或密码不能全为空,请重新输入");
setNull();
return;
}
if (textBox3.Text.Trim() != textBox4.Text.Trim())
{
MessageBox.Show("两次输入的密码不相同,请重新输入");
setPassNUll();
return;
}
/*查找管理员编号是否唯一
*
* */
string str = "select * from sysUser where Userid='"+textBox2.Text.Trim()+"'";
if (DataBaseConnection.find(str) == true)
{
MessageBox.Show("管理员编号不唯一,请重新输入");
setNull();
return;
}
/*
* 插入
* */
str = "insert into sysUser values('" + textBox2.Text.Trim() + "','" + textBox3.Text.Trim() + "','" + comboBox2.Text.Trim() + "')";
DataBaseConnection.insert(str);
/*
* 更新数据集
* */
SqlCommand com = new SqlCommand(sql,sqlConnection1);
sqlConnection1.Open();
sqlDataAdapter1.SelectCommand = com;
dataSet11.Clear();
sqlDataAdapter1.Fill(dataSet11);
sqlConnection1.Close();
setNull();
MessageBox.Show("插入成功");
}
private void button6_Click(object sender, EventArgs e)
{
/*
* 找回密码
* */
string temp = "";
string str="select * from SysUser where userId='"+textBox5.Text.Trim()+"'";
if (DataBaseConnection.find(str) == true)
{
temp = DataBaseConnection.findPass(str);
MessageBox.Show(textBox5.Text.Trim()+"管理员,你的密码是:"+temp+",请保管好你的密码");
label9.Text = textBox5.Text.Trim() + "管理员,你的密码是:" + temp + ",请保管好你的密码";
return;
}
MessageBox.Show("对不起,你不是管理员成员");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -