WinFormsApp1/登录页面.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.CodeDom;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinFormsApp1
{
    public partial class winform_log : Form
    {
        public winform_log()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)//登录按钮
        {
            if (textBox1.Text == null || textBox1.Text == string.Empty || textBox2.Text == null || textBox2.Text == string.Empty)
            {
                MessageBox.Show("请输入登录信息");
                return;
            }
            var Role = radioButton_admin.Checked ? AccountRole.Admin : AccountRole.Student;// 选择的身份
            try
            {
                var _temp = LibraryDbContext.Shared.Accounts.Single(acc =>
                    acc.ID == textBox1.Text && acc.Password == Encryptor.SHA256Encrypt(textBox2.Text + "X") && acc.Role == Role);

                if (_temp != null && _temp.ID == textBox1.Text)//复核登录
                {
                    Global.account = _temp;
                    switch (_temp.Role)
                    {
                        case AccountRole.Admin:
                            new winform_admin().Show();
                            this.Hide();
                            break;
                        case AccountRole.Student:
                            new winform_stu().Show();
                            this.Hide();
                            break;
                        default:
                            throw new Exception("账户角色错误");
                    }

                    _temp = null;
                }
                else
                {
                    MessageBox.Show("账号或密码错误");
                }
            }
            catch (InvalidOperationException ex)
            {
后面还有 34 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。