DAL/LoginService.cs
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using Model;
namespace DAL
{
public class LoginService
{
//验证管理员账户是否正确
public bool yanZheng(string _userName, string _userPwd)
{
//获取连接
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=AutumnSky;Integrated Security=True"))
{
//打开连接
conn.Open();
//SQL语句参数化,为了防止注入
string sql = "select 1 from Admininfo where userName=@userName and userPwd=@userPwd";
//执行SQL语句
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
cmd.Parameters.Add(new SqlParameter("userName", _userName));
cmd.Parameters.Add(new SqlParameter("userPwd", _userPwd));
SqlDataReader reader = cmd.ExecuteReader();
if (reader.Read())
return true;
return false;
}
}
}
//验证教师账户是否正确
public bool yanZheng3(int _userName, string _userPwd)
{
//获取连接
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=AutumnSky;Integrated Security=True"))
{
//打开连接
conn.Open();
//SQL语句参数化,为了防止注入
string sql = "select 1 from Teacherinfo where TeacherNum=@userName and TeacherPwd=@userPwd";
//执行SQL语句
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
cmd.Parameters.Add(new SqlParameter("userName", _userName));
cmd.Parameters.Add(new SqlParameter("userPwd", _userPwd));
SqlDataReader reader = cmd.ExecuteReader();
if (reader.Read())
return true;
return false;
}
}
}
//验证学生账号是否存在
public static student getUserInfo(int userName, string userPwd)
{
string sql = $"select * from Studentinfo where StudentNum='{userName}' and StudentPwd='{userPwd}'";
后面还有 75 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。