//考生登陆 //考生登陆 public int StuLogIn(string sId, string stuName, string examId, ref string errorInfo) { int res = 0; //判断考生是否存在 int count = db.Student.Count(t => t.StudentId == sId); if (count <= 0) { errorInfo = "该考生不存在!"; return(res); } //判断学号与姓名是否匹配 int number = db.Student.Count(t => t.StudentId == sId && t.StudentName == stuName); if (number != 1) { errorInfo = "学号与姓名不匹配!"; return(res); } if (examBll.StueIsHaveSumbitPaper(sId, examId)) { errorInfo = "该考生已交卷!"; return(res); } //判断考生是否通过审核 int state = int.Parse(db.Student.First(t => t.StudentId == sId).StudentState.ToString()); if (state != (int)(StudentBLL.StudentState.PassAudit)) { if (state == (int)(StudentBLL.StudentState.WaitAudit)) { errorInfo = "该考生待审核!"; } else { errorInfo = "该考生未通过审核!"; } return(res); } if (GetStuExam(sId, examId) != null) { if (GetStuExam(sId, examId).Score < 0) { errorInfo = "该考生考试作弊,不能继续考试!"; return(res); } } //判断考生是否已经登记 int examState = int.Parse(db.Student.First(t => t.StudentId == sId).StuExamState.ToString()); //登记了 但还未开始考试过 if (examState == 1) { ////判断Ip地址 //if (!JudgeIp(sId, examId)) //{ // errorInfo = "IP地址不合法"; // return res; //} } else if (examBll.GetStuExamByExamId(sId, examId) == null && examState == 0) { errorInfo = "请先在该考场监考老师处登记!"; return(res); } else //未登记 正在考试 已交卷 { //判断是否有相关考试记录 无则是未登记 if (examBll.GetStuExamByExamId(sId, examId) == null) { errorInfo = "请先在该考场监考老师处登记!"; return(res); } else { //判断是否已交卷 if (examBll.StueIsHaveSumbitPaper(sId, examId)) { errorInfo = "该考生已交卷!"; return(res); } else //正在考试 { //判断Ip地址 if (!JudgeIp(sId, examId)) { errorInfo = "IP地址不合法!"; return(res); } } } } res = 1; return(res); }