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

求类似案例源码!!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条)

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作