BXXT/Controllers/LoginController.cs
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BXXT.Models;
using System.Diagnostics;//调试的时候用的
namespace BXXT.Controllers
{
public class LoginController : Controller
{
private DataDataContext Dc = new DataDataContext();//创建数据控制器对象
/// <summary>
/// 返回登录主页面
/// </summary>
/// <returns></returns>
public ActionResult Index()
{
//为view分配登录类型对应枚举值
ViewData["StudentLogin"] =(int) LoginType.StudentLogin;
ViewData["GuyLogin"] = (int)LoginType.GuyLogin;
ViewData["AdminLogin"] = (int)LoginType.AdminLogin;
return View();
}
/// <summary>
/// 验证用户登录接口
/// </summary>
/// <returns>返回的是json数据</returns>
public ActionResult OnLogin()
{
JsonResult RetJson = new JsonResult();//创建返回的json对象
LoginRetMsg RetMsg = new LoginRetMsg();//创建返回消息对象
LoginMsg Msg = new LoginMsg();//创建登录消息实例
UpdateModel(Msg,Request.Form.AllKeys);//用表单数据跟新登录消息模型
RetMsg.Ret = false;//设置默认请求失败
RetMsg.RetMsg = "数据错误";
if (Msg.UserName.Length>0 && Msg.Password.Length>5)//判断用户名和密码长度是否符合要求
{
switch (Msg.LoginType)//判断请求登录类型
{
case (int)LoginType.StudentLogin://学生帐号登录
var QueryStudent = from Student in Dc.学生
where Student.学号 == Msg.UserName && Student.密码 == Msg.Password
select Student.学号;//查询学生
if (QueryStudent.Count() == 1)
{
//找到一个符合条件的学生
Session["UserType"] = (int)LoginType.StudentLogin;//设置登录类型为学生
Session["UserName"] = Msg.UserName;//设置登录用户名
RetMsg.Ret = true;//设置返回登录状态为成功
RetMsg.RetMsg = "学生登录成功";//设置登录返回消息
}
else
{
//没有查询出符合条件的学生
RetMsg.RetMsg = "学号或者密码错误";
}
break;
case (int)LoginType.GuyLogin://维修工帐号登录
var QueryGuy = from Guy in Dc.维修工
后面还有 46 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。