|
- using Learun.Util;
- using System.Data;
- using Learun.Application.TwoDevelopment.EducationalAdministration;
- using System.Web.Mvc;
- using System.Collections.Generic;
- using System;
- using System.Linq;
- using Learun.Application.Base.SystemModule;
-
- namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创 建:超级管理员
- /// 日 期:2019-05-14 10:02
- /// 描 述:选修课课程信息
- /// </summary>
- public class OpenLessonPlanOfElectiveController : MvcControllerBase
- {
- private OpenLessonPlanOfElectiveIBLL openLessonPlanOfElectiveIBLL = new OpenLessonPlanOfElectiveBLL();
- private StuSelectLessonListOfElectiveIBLL stuSelectLessonListOfElectiveIBLL = new StuSelectLessonListOfElectiveBLL();
- private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL();
- private ClassInfoIBLL classInfoIBLL = new ClassInfoBLL();
- private ElectiveMajorIBLL electiveMajorIBLL = new ElectiveMajorBLL();
- CdMajorIBLL CdMajorIBLL = new CdMajorBLL();
- private StuSelectLessonListOfElectivePreIBLL stuSelectLessonListOfElectivePreIBLL = new StuSelectLessonListOfElectivePreBLL();
- private OpenLessonPlanOfElectiveChangeIBLL openLessonPlanOfElectiveChangeIBLL = new OpenLessonPlanOfElectiveChangeBLL();
- private DataSourceIBLL dataSourceIBLL = new DataSourceBLL();
-
- #region 视图功能
-
- /// <summary>
- /// 主页面
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Index()
- {
- return View();
- }
-
- [HttpGet]
- public ActionResult MergeIndex()
- {
- return View();
- }
- /// <summary>
- /// 表单页
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Form()
- {
- return View();
- }
-
- /// <summary>
- /// 学子在线-选课中心
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult StudentIndex()
- {
- var loginuser = LoginUserInfo.Get();
- var studentinfo = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginuser.account);
- if (studentinfo != null)
- {
- ViewBag.StuMajorNo = CdMajorIBLL.GetCdMajorEntityByMajorNo(studentinfo.MajorNo)?.ID;
- ViewBag.StuGrade = studentinfo.Grade;
- }
- ViewBag.WebApiUrl = Config.GetValue("WebApi");
- return View();
- }
- /// <summary>
- /// 表单页
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult ModifyForm()
- {
- return View();
- }
- #endregion
-
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表数据
- /// <summary>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetPageList(string pagination, string queryJson)
- {
- Pagination paginationobj = pagination.ToObject<Pagination>();
- var data = openLessonPlanOfElectiveIBLL.GetPageList(paginationobj, queryJson);
- var jsonData = new
- {
- rows = data,
- total = paginationobj.total,
- page = paginationobj.page,
- records = paginationobj.records
- };
- return Success(jsonData);
- }
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetPageListOfMerge(string pagination, string queryJson)
- {
- Pagination paginationobj = pagination.ToObject<Pagination>();
- var data = openLessonPlanOfElectiveIBLL.GetPageListOfMerge(paginationobj, queryJson);
- var jsonData = new
- {
- rows = data,
- total = paginationobj.total,
- page = paginationobj.page,
- records = paginationobj.records
- };
- return Success(jsonData);
- }
- /// <summary>
- /// 获取表单数据
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetFormData(string keyValue)
- {
- var OpenLessonPlanOfElectiveData = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(keyValue);
- var jsonData = new
- {
- OpenLessonPlanOfElective = OpenLessonPlanOfElectiveData,
- };
- return Success(jsonData);
- }
- /// <summary>
- /// 获取页面显示列表数据【学子在线-选课中心】
- /// <summary>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetPageListOfStudent(string pagination, string queryJson)
- {
- Pagination paginationobj = pagination.ToObject<Pagination>();
- var data = openLessonPlanOfElectiveIBLL.GetPageListOfStudent(paginationobj, queryJson).OrderByDescending(x => x.AcademicYearNo).ThenByDescending(x => x.Semester).ThenBy(x => x.LessonNo).ThenBy(x => x.EmpNo);
- var jsonData = new
- {
- rows = data,
- total = paginationobj.total,
- page = paginationobj.page,
- records = paginationobj.records
- };
- return Success(jsonData);
- }
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult DeleteForm(string keyValue)
- {
- openLessonPlanOfElectiveIBLL.DeleteEntity(keyValue);
- return Success("删除成功!");
- }
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveForm(string keyValue, string strEntity)
- {
- var loginUserInfo = LoginUserInfo.Get();
-
- OpenLessonPlanOfElectiveEntity entity = strEntity.ToObject<OpenLessonPlanOfElectiveEntity>();
- entity.ModifyTime = DateTime.Now;
- entity.ModifyUserId = loginUserInfo.userId;
-
- entity.ModifyUserName = loginUserInfo.realName;
- openLessonPlanOfElectiveIBLL.SaveEntity(keyValue, entity);
- return Success("保存成功!");
- }
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveModifyForm(string keyValue, string strEntity)
- {
- OpenLessonPlanOfElectiveChangeEntity entity = strEntity.ToObject<OpenLessonPlanOfElectiveChangeEntity>();
- if (string.IsNullOrEmpty(entity.AfterLessonNo) && string.IsNullOrEmpty(entity.AfterEmpNo) && string.IsNullOrEmpty(entity.AfterClassRoomNo))
- {
- return Fail("未选择新课程、新教师、新教室!");
- }
- if (!string.IsNullOrEmpty(entity.AfterLessonNo) && !string.IsNullOrEmpty(entity.AfterEmpNo) && !string.IsNullOrEmpty(entity.AfterClassRoomNo) && entity.AfterLessonNo == entity.LessonNo && entity.AfterEmpNo == entity.EmpNo && entity.AfterClassRoomNo == entity.ClassRoomNo)
- {
- return Fail("未改变新课程、新教师、新教室!");
- }
-
- var loginUserInfo = LoginUserInfo.Get();
- var model = new OpenLessonPlanOfElectiveChangeEntity();
- model.CreateTime = DateTime.Now;
- model.CreateUserId = loginUserInfo.userId;
- model.CreateUserName = loginUserInfo.realName;
- model.OLPEId = keyValue;
- model.BeforeLessonNo = entity.LessonNo;
- model.AfterLessonNo = entity.LessonNo;
- model.BeforeEmpNo = entity.EmpNo;
- model.AfterEmpNo = entity.EmpNo;
- model.BeforeClassRoomNo = entity.ClassRoomNo;
- model.AfterClassRoomNo = entity.ClassRoomNo;
- if (!string.IsNullOrEmpty(entity.AfterLessonNo))
- {
- model.AfterLessonNo = entity.AfterLessonNo;
- var lesson = dataSourceIBLL.GetDataTable("LessonInfo", "t.lessonno='" + entity.AfterLessonNo + "'");
- if (lesson != null && lesson.Rows.Count > 0)
- {
- model.AfterLessonName = lesson.Rows[0]["lessonname"].ToString();
- }
- }
- else
- {
- var lesson = dataSourceIBLL.GetDataTable("LessonInfo", "t.lessonno='" + entity.LessonNo + "'");
- if (lesson != null && lesson.Rows.Count > 0)
- {
- model.AfterLessonName = lesson.Rows[0]["lessonname"].ToString();
- }
- }
-
- if (!string.IsNullOrEmpty(entity.AfterEmpNo))
- {
- model.AfterEmpNo = entity.AfterEmpNo;
-
- var emp = dataSourceIBLL.GetDataTable("EmpInfo", "t.empno='" + entity.AfterEmpNo + "'");
- if (emp != null && emp.Rows.Count > 0)
- {
- model.AfterEmpName = emp.Rows[0]["empname"].ToString();
- }
- }
- else
- {
- var emp = dataSourceIBLL.GetDataTable("EmpInfo", "t.empno='" + entity.EmpNo + "'");
- if (emp != null && emp.Rows.Count > 0)
- {
- model.AfterEmpName = emp.Rows[0]["empname"].ToString();
- }
- }
-
- if (!string.IsNullOrEmpty(entity.AfterClassRoomNo))
- {
- model.AfterClassRoomNo = entity.AfterClassRoomNo;
-
- var classRoom = dataSourceIBLL.GetDataTable("ClassRoomInfo", "t.classroomno='" + entity.AfterClassRoomNo + "'");
- if (classRoom != null && classRoom.Rows.Count > 0)
- {
- model.AfterClassRoomName = classRoom.Rows[0]["classroomname"].ToString();
- }
- }
- else
- {
- var classRoom = dataSourceIBLL.GetDataTable("ClassRoomInfo", "t.classroomno='" + entity.ClassRoomNo + "'");
- if (classRoom != null && classRoom.Rows.Count > 0)
- {
- model.AfterClassRoomName = classRoom.Rows[0]["classroomname"].ToString();
- }
- }
-
- openLessonPlanOfElectiveChangeIBLL.SaveEntity("", model);
-
- //修改选修课相关表
- openLessonPlanOfElectiveIBLL.DoElectiveChange(model);
-
- return Success("保存成功!");
- }
-
- #endregion
-
- #region 扩展数据
-
- /// <summary>
- /// 判断选课是否开始
- /// </summary>
- /// <returns></returns>
- public ActionResult IsSelectElectiveLesson()
- {
- var entity = openLessonPlanOfElectiveIBLL.GetEADateArrangeEntityAboutElective();
- if (entity != null)
- {
- return Fail("选课已经开始!");
- }
-
- return Success("选课还未开始!");
- }
-
- /// <summary>
- /// 取消报名
- /// </summary>
- /// <param name="keyvalue"></param>
- /// <returns></returns>
- public ActionResult CancelApply(string keyvalue)
- {
- var loginUserInfo = LoginUserInfo.Get();
- //学员信息
- var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.enCode);
- if (stuInfoBasicEntity == null)
- {
- return Fail("当前学员不存在!");
- }
- //课程信息
- var olpeEntity = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(keyvalue);
- if (olpeEntity == null)
- {
- return Fail("当前课程不存在!");
- }
- //当前学员是否已经报名该课程
- var sslleEntity = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveEntityByStuNo(loginUserInfo.enCode, keyvalue);
- if (sslleEntity != null)
- {
- if (sslleEntity.Status != 2)
- {
- stuSelectLessonListOfElectiveIBLL.DeleteEntity(sslleEntity.Id);
- return Success("取消成功");
- }
- else
- {
- return Fail("取消失败,当前课程已报名成功!");
- }
- }
- else
- {
- return Fail("当前课程未报名,无需取消!");
- }
- }
-
- /// <summary>
- /// 选修课报名:弃用
- /// </summary>
- /// <param name="keyvalue"></param>
- /// <returns></returns>
- public ActionResult ElectiveLessonApply(string keyvalue)
- {
- var loginUserInfo = LoginUserInfo.Get();
- //学员信息
- var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.enCode);
- if (stuInfoBasicEntity == null)
- {
- return Fail("当前学员不存在!");
- }
- //课程信息
- var olpeEntity = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(keyvalue);
- if (olpeEntity == null)
- {
- return Fail("当前课程不存在!");
- }
- //所选课程的报名人数是否已满
- //if (olpeEntity.StuNum >= olpeEntity.StuNumMax)
- //{
- // return Fail("当前课程报名人数已满,请选择其他课程!");
- //}
-
- //模式二:
- var aa = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveListByOLPEId(olpeEntity.Id);
- var aaa = aa.Where(x => x.Status == 1 || x.Status == 2).Count();
- if (aaa >= olpeEntity.StuNumMax)
- {
- return Fail("当前课程报名人数已满,请选择其他课程!");
- }
-
- //当前学员本学期是否有报名课程
- var sslleEntity = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveEntityByStuNo(loginUserInfo.enCode, "");
- if (sslleEntity != null)
- {
- if (sslleEntity.OLPEId != keyvalue && sslleEntity.Status != 3)
- {
- return Fail("已存在报名课程,每学期只能选择一门选修课!如需报名其他课程请先取消。");
- }
- if (sslleEntity.Status == 1)
- {
- return Fail("报名审核中,请耐心等待!");
- }
- else if (sslleEntity.Status == 2)
- {
- return Fail("已存在报名成功的课程,只能选择一门选修课!");
- }
- else if (sslleEntity.Status == 3)//移除报名失败的数据
- {
- stuSelectLessonListOfElectiveIBLL.DeleteEntity(sslleEntity.Id);
- }
-
- }
-
- //新增报名数据
- var model = new StuSelectLessonListOfElectiveEntity()
- {
- OLPEId = olpeEntity.Id,
- NoticeBookNo = stuInfoBasicEntity.NoticeNo,
- StuNo = stuInfoBasicEntity.StuNo,
- DeptNo = stuInfoBasicEntity.DeptNo,
- MajorNo = stuInfoBasicEntity.MajorNo,
- ClassNo = stuInfoBasicEntity.ClassNo,
- MajorDetailNo = stuInfoBasicEntity.MajorDetailNo,
- MajorDetailName = stuInfoBasicEntity.MajorDetailName,
- StuName = stuInfoBasicEntity.StuName,
- GenderNo = stuInfoBasicEntity.GenderNo,
- Grade = stuInfoBasicEntity.Grade,
- AcademicYearNo = olpeEntity.AcademicYearNo,
- Semester = olpeEntity.Semester,
- LessonNo = olpeEntity.LessonNo,
- LessonName = olpeEntity.LessonName,
- LessonSortNo = olpeEntity.LessonSortNo,
- LessonSection = olpeEntity.LessonSection,
- LessonTime = olpeEntity.LessonTime,
- EmpNo = olpeEntity.EmpNo,
- EmpName = olpeEntity.EmpName,
- ClassRoomNo = olpeEntity.ClassRoomNo,
- ClassRoomName = olpeEntity.ClassRoomName,
- StudyScore = olpeEntity.StudyScore,
- StartWeek = olpeEntity.StartWeek,
- EndWeek = olpeEntity.EndWeek,
- StartDate = olpeEntity.StartDate,
- EndDate = olpeEntity.EndDate,
- CreateTime = DateTime.Now,
- Status = 1,
- OrdinaryScoreScale = 1,
- TermInScoreScale = 1,
- TermEndScoreScale = 1,
- OtherScoreScale = 1
- };
- stuSelectLessonListOfElectiveIBLL.SaveEntity("", model);
-
- return Success("报名成功");
- }
-
- /// <summary>
- /// 判断登录学生是否可以选课
- /// </summary>
- /// <returns></returns>
- public ActionResult IsCanApplyElectiveLesson()
- {
- var loginUserInfo = LoginUserInfo.Get();
- var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.account);
- if (stuInfoBasicEntity == null)
- {
- return Fail("学籍信息不存在!");
- }
- var classInfoEntity = classInfoIBLL.GetClassInfoEntityByClassNo(stuInfoBasicEntity.ClassNo);
-
- //var yearAndSemester = Common.GetSemesterAndYear();
- //var electiveMajorList = electiveMajorIBLL.GetList(yearAndSemester.AcademicYearShort, yearAndSemester.Semester).ToList();
- //if (electiveMajorList.Any()) //有设置选修专业,进行专业判断;没有设置选修专业,都可以选课
- //{
- // var majorList = electiveMajorList.Select(x => x.MajorNo);
- // if (!majorList.Contains(classInfoEntity?.MajorNo))
- // {
- // return Fail("不可以选课!");
- // }
- //}
-
-
- //todo:
-
- return Success("可以选课!");
- }
-
- /// <summary>
- /// 判断队列结果
- /// </summary>
- /// <returns></returns>
- public ActionResult GetApplyResult(string keyvalue)
- {
- var loginUserInfo = LoginUserInfo.Get();
- //学员信息
- var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.enCode);
- if (stuInfoBasicEntity == null)
- {
- return Success("当前学员不存在!");
- }
- //课程信息
- var olpeEntity = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(keyvalue);
- if (olpeEntity == null)
- {
- return Success("当前课程不存在!");
- }
-
- //当前学员本学期是否有报名课程:每学期一门
- //var sslleEntity = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveEntityByStuNo(loginUserInfo.enCode, "");
- //if (sslleEntity != null)
- //{
- // if (sslleEntity.OLPEId != keyvalue && sslleEntity.Status != 3)
- // {
- // return Success("已存在报名课程,每学期只能选择一门选修课!如需报名其他课程请先取消。");
- // }
- // if (sslleEntity.Status == 1)
- // {
- // return Success("报名审核中,请耐心等待!");
- // }
- // else if (sslleEntity.Status == 2)
- // {
- // return Success("已存在报名成功的课程,只能选择一门选修课!");
- // }
-
- //}
- //else
- //{
- // //所选课程的报名人数是否已满
- // var aa = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveListByOLPEId(keyvalue);
- // var aaa = aa.Count(x => x.Status == 1 || x.Status == 2);
- // if (aaa >= olpeEntity.StuNumMax)
- // {
- // return Success("当前课程报名人数已满,请选择其他课程!");
- // }
- //}
-
- //每学期两门
- var sslleEntity = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveEntityByStuNo(loginUserInfo.enCode, keyvalue);
- if (sslleEntity != null)
- {
- if (sslleEntity.Status == 1)
- {
- return Success("当前课程报名审核中,请耐心等待!");
- }
- else if (sslleEntity.Status == 2)
- {
- return Success("当前课程已报名成功!");
- }
- }
- else
- {
- //所选课程的报名人数是否已满
- var aa = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveListByOLPEId(keyvalue);
- var aaa = aa.Count(x => x.Status == 1 || x.Status == 2);
- if (aaa >= olpeEntity.StuNumMax)
- {
- return Success("当前课程报名人数已满,请选择其他课程!");
- }
- //每学期最多两门
- var sslleList = stuSelectLessonListOfElectiveIBLL.GetStuSelectLessonListOfElectiveListByStuNo(loginUserInfo.enCode);
- var sslleListOfNow = sslleList.Where(x => x.AcademicYearNo == olpeEntity.AcademicYearNo && x.Semester == olpeEntity.Semester);
- var sslleListOfNow1 = sslleListOfNow.Where(x => x.Status == 1 || x.Status == 2);
- //if (sslleListOfNow1.Count() >= 2)
- if (sslleListOfNow1.Count() >= Config.GetValue("ElectiveLessonApplyMax").ToInt())
- {
- return Success("每学期最多选择" + Config.GetValue("ElectiveLessonApplyMax").ToInt() + "门选修课!");
- }
- //相同时间不能报名
- if (sslleListOfNow1.Where(x => x.LessonSection == olpeEntity.LessonSection).Any())
- {
- //相同时间不能报名
- return Success("本学期此时间段已有报名的选修课!");
- }
-
- }
-
- return Fail("正在提交,请等待!");
- }
-
-
- /// <summary>
- /// 取消报名(预)
- /// </summary>
- /// <param name="keyvalue"></param>
- /// <returns></returns>
- public ActionResult CancelApplyPre(string keyvalue)
- {
- var loginUserInfo = LoginUserInfo.Get();
- //学员信息
- var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.enCode);
- if (stuInfoBasicEntity == null)
- {
- return Fail("当前学员不存在!");
- }
- //课程信息
- var olpeEntity = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(keyvalue);
- if (olpeEntity == null)
- {
- return Fail("当前课程不存在!");
- }
- //当前学员是否已经报名该课程
- var sslleEntity = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreEntityByStuNo(loginUserInfo.enCode, keyvalue);
- if (sslleEntity != null)
- {
- if (sslleEntity.Status != 2)
- {
- stuSelectLessonListOfElectivePreIBLL.DeleteEntity(sslleEntity.Id);
- return Success("取消成功");
- }
- else
- {
- return Fail("取消失败,当前课程已报名成功!");
- }
- }
- else
- {
- return Fail("当前课程未报名,无需取消!");
- }
- }
-
- /// <summary>
- /// 选修课报名(预)
- /// </summary>
- /// <param name="keyvalue"></param>
- /// <returns></returns>
- public ActionResult ElectiveLessonApplyPre(string keyvalue)
- {
- var loginUserInfo = LoginUserInfo.Get();
- //学员信息
- var stuInfoBasicEntity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(loginUserInfo.enCode);
- if (stuInfoBasicEntity == null)
- {
- return Fail("当前学员不存在!");
- }
- //课程信息
- var olpeEntity = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(keyvalue);
- if (olpeEntity == null)
- {
- return Fail("当前课程不存在!");
- }
- //所选课程的报名人数是否已满
- var aa = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreListByOLPEId(olpeEntity.Id);
- var aaa = aa.Where(x => x.Status == 2).Count();
- if (aaa >= olpeEntity.StuNumMax)
- {
- return Fail("当前课程报名人数已满,请选择其他课程!");
- }
- //当前学员本学期是否有报名课程:每学期一门
- //var sslleEntity = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreEntityByStuNo(loginUserInfo.enCode, "");
- //if (sslleEntity != null)
- //{
- // if (sslleEntity.OLPEId != keyvalue && sslleEntity.Status != 3)
- // {
- // return Fail("已存在报名课程,每学期只能选择一门选修课!如需报名其他课程请先取消。");
- // }
- // if (sslleEntity.Status == 1)
- // {
- // return Fail("报名审核中,请耐心等待!");
- // }
- // else if (sslleEntity.Status == 2)
- // {
- // return Fail("已存在报名成功的课程,只能选择一门选修课!");
- // }
- // else if (sslleEntity.Status == 3)//移除报名失败的数据
- // {
- // stuSelectLessonListOfElectivePreIBLL.DeleteEntity(sslleEntity.Id);
- // }
-
- //}
-
- //每学期两门
- var sslleList = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreListByStuNo(loginUserInfo.enCode);
- var sslleListOfNow = sslleList.Where(x => x.AcademicYearNo == olpeEntity.AcademicYearNo && x.Semester == olpeEntity.Semester);
- var sslleListOfNow1 = sslleListOfNow.Where(x => x.Status == 1 || x.Status == 2);
- var sslleListOfNow2 = sslleListOfNow.Where(x => x.Status == 3);
- if (sslleListOfNow1.Count() >= Config.GetValue("ElectiveLessonApplyMax").ToInt())
- {
- return Fail("每学期最多选择" + Config.GetValue("ElectiveLessonApplyMax").ToInt() + "门选修课!");
- }
- else
- {
- var m = sslleListOfNow1.FirstOrDefault(x => x.OLPEId == olpeEntity.Id);
- if (m != null)
- {
- if (m.Status == 1)
- {
- return Fail("当前课程报名审核中,请耐心等待!");
- }
- else if (m.Status == 2)
- {
- return Fail("当前课程已报名成功!");
- }
- }
- }
- if (sslleListOfNow2.Count() > 0)
- {
- foreach (var item in sslleListOfNow2)
- {
- stuSelectLessonListOfElectivePreIBLL.DeleteEntity(item.Id);
- }
- }
-
-
- //新增报名数据
- var model = new StuSelectLessonListOfElectivePreEntity()
- {
- OLPEId = olpeEntity.Id,
- NoticeBookNo = stuInfoBasicEntity.NoticeNo,
- StuNo = stuInfoBasicEntity.StuNo,
- DeptNo = stuInfoBasicEntity.DeptNo,
- MajorNo = stuInfoBasicEntity.MajorNo,
- ClassNo = stuInfoBasicEntity.ClassNo,
- MajorDetailNo = stuInfoBasicEntity.MajorDetailNo,
- MajorDetailName = stuInfoBasicEntity.MajorDetailName,
- StuName = stuInfoBasicEntity.StuName,
- GenderNo = stuInfoBasicEntity.GenderNo,
- Grade = stuInfoBasicEntity.Grade,
- AcademicYearNo = olpeEntity.AcademicYearNo,
- Semester = olpeEntity.Semester,
- LessonNo = olpeEntity.LessonNo,
- LessonName = olpeEntity.LessonName,
- LessonSortNo = olpeEntity.LessonSortNo,
- LessonSection = olpeEntity.LessonSection,
- LessonTime = olpeEntity.LessonTime,
- EmpNo = olpeEntity.EmpNo,
- EmpName = olpeEntity.EmpName,
- ClassRoomNo = olpeEntity.ClassRoomNo,
- ClassRoomName = olpeEntity.ClassRoomName,
- StudyScore = olpeEntity.StudyScore,
- StartWeek = olpeEntity.StartWeek,
- EndWeek = olpeEntity.EndWeek,
- StartDate = olpeEntity.StartDate,
- EndDate = olpeEntity.EndDate,
- CreateTime = DateTime.Now,
- Status = 1,
- OrdinaryScoreScale = 1,
- TermInScoreScale = 1,
- TermEndScoreScale = 1,
- OtherScoreScale = 1,
- F_SchoolId = olpeEntity.F_SchoolId
- };
- stuSelectLessonListOfElectivePreIBLL.SaveEntity("", model);
-
- return Success("报名成功");
- }
- #endregion
-
- }
- }
|