Metaphor_1
Metaphor_1
采纳率50%
2019-12-05 17:30

求助,很简单的C#问题

老师要求做一个成绩管理系统,要求实现分类登入,可是这个cheng'xu如果用户是学生,即使comboBox不选学生也能顺利登入,admin就没这个问题,请教大佬是为什么?

private void button1_Click(object sender, EventArgs e)
    {
        string sUser = txtUser.Text.ToString();
        string sPassword = txtPassword.Text.ToString();

        if (sUser == "admin" && sPassword == "1234" && comboBoxLeixing.Text == "管理员")
        {
            Menuadmin main = new Menuadmin();
            main.Show();
            this.Hide();
        }

            if (sUser == "徐光睿" || sUser == "曹广" || sUser == "曹子岳" || sUser == "陈思佳" || sUser == "陈旭" || sUser == "黄文广" ||
               sUser == "雷章树" || sUser == "刘晴晴" || sUser == "齐世勐" || sUser == "沈彬" || sUser == "帅兴" || sUser == "孙权伟" ||
               sUser == "王恒" || sUser == "王瑞" || sUser == "向猛" || sUser == "张国梁" || sUser == "张宗友" || sUser == "张舒敏"
               && sPassword == "1234" && comboBoxLeixing.Text == "学生")
            {
                Menustudent main = new Menustudent();
                main.Show();
                this.Hide();
            }

            if (sUser == "刘兆良" || sUser == "龙隆" || sUser == "冯伟" || sUser == "刘善勇" ||
               sUser == "印森林" || sUser == "程乐利" || sUser == "刘岩" || sUser == "赵俊威"
               && sPassword == "1234" && comboBoxLeixing.Text== "教师")
            {
                Menuteacher main = new Menuteacher();
                main.Show();
                this.Hide();
            }

        else
            label3.Text = "用户名或密码错误,请重新输入!";
    }
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • qq_43276730 qq_43276730 2年前
            if ((sUser == "徐光睿" || sUser == "曹广" || sUser == "曹子岳" || sUser == "陈思佳" || sUser == "陈旭" || sUser == "黄文广" ||
               sUser == "雷章树" || sUser == "刘晴晴" || sUser == "齐世勐" || sUser == "沈彬" || sUser == "帅兴" || sUser == "孙权伟" ||
               sUser == "王恒" || sUser == "王瑞" || sUser == "向猛" || sUser == "张国梁" || sUser == "张宗友" || sUser == "张舒敏")
               && sPassword == "1234" && comboBoxLeixing.Text == "学生")
                            多打一对括号,如果没猜错,你的教师登陆也是这样,只要sUSer输对了,直接跳转界面了
                            ||:这个符号是左右两边只要有一个满足就进入下一步了
                            &&:这个是两边都满足
    
    点赞 3 评论 复制链接分享

相关推荐