Csharpsss 2018-06-13 02:23 采纳率: 50%
浏览 902
已采纳

求类似案例源码!!winform用户登陆只能查看自己的信息 并且不可修改

管理员可查看所有人 可以修改指定用户指定权限

满足标题就可以了

  • 写回答

7条回答 默认 最新

  • dabocaiqq 2018-06-13 03:04
    关注
     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;
            }
        }
    }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(6条)

报告相同问题?