コード例 #1
0
        public Admin Login(string adminName, string adminPass)
        {
            Admin admin = db.Queryable <Admin>().First(a => a.AdminName == adminName);

            if (admin != null)
            {
                string password = MD5Encrypt.GetStrMD5(DESDEncrypt.Encrypt(adminPass));
                if (password == admin.AdminPass.ToString())
                {
                    return(admin);
                }
                else
                {
                    throw new Exception("密码不正确,请重新输入");
                }
            }
            else
            {
                throw new Exception("账户不存在,请重新输入");
            }
        }