管理员可查看所有人 可以修改指定用户指定权限
满足标题就可以了
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Q691926
{
public partial class LoginDialog : Form
{
public LoginDialog()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var db = new Q691926DBClassDataContext();
if (db.UserInfos.Any(x => x.username == textBox1.Text && x.pwd == textBox2.Text))
{
this.Hide();
Session.UserName = textBox1.Text;
var f = new MainForm();
f.FormClosed += new FormClosedEventHandler(f_FormClosed);
f.Show();
}
else
{
MessageBox.Show("wrong password!");
}
}
void f_FormClosed(object sender, FormClosedEventArgs e)
{
this.Show();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Q691926
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void MainForm_Load(object sender, EventArgs e)
{
var db = new Q691926DBClassDataContext();
string query = db.UserInfos.First(x => x.username == Session.UserName).info;
label1.Text = query;
}
}
}
做好登录,用对象存储用户身份就行了,然后依据身份读取自己的或者所有人的信息
你这个应该很简单的。等会登陆你显示用户自己的信息。管理员登陆时,查询所有咯,管理员可以指定用户权限,这个是就相当于修改了。权限字段。
然后相应功能,sql里条件加权限咯。也可以给你写个简单列子。
完整代码:https://download.csdn.net/download/dabocaiqq/10475944
求采纳,谢谢。
权限也给你做了
下载:https://download.csdn.net/download/dabocaiqq/10476038
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Q691926
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void MainForm_Load(object sender, EventArgs e)
{
var db = new Q691926DBClassDataContext();
string query = db.UserInfos.First(x => x.username == Session.UserName).info;
label1.Text = query;
if (db.UserInfos.First(x => x.username == Session.UserName).isadmin)
{
panel1.Visible = true;
comboBox1.Items.Clear();
foreach (var item in db.UserInfos)
{
comboBox1.Items.Add(item.username);
}
comboBox1.TextChanged += new EventHandler(comboBox1_TextChanged);
}
else
{
panel1.Visible = false;
}
}
void comboBox1_TextChanged(object sender, EventArgs e)
{
var db = new Q691926DBClassDataContext();
if (db.UserInfos.Any(x => x.username == comboBox1.Text))
{
textBox1.Text = db.UserInfos.First(x => x.username == comboBox1.Text).info;
}
}
private void button1_Click(object sender, EventArgs e)
{
var db = new Q691926DBClassDataContext();
if (db.UserInfos.Any(x => x.username == comboBox1.Text))
{
var u = db.UserInfos.First(x => x.username == comboBox1.Text);
u.info = textBox1.Text;
db.SubmitChanges();
}
}
}
}