|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- using Learun.Util;
- using System.Data;
- using Learun.Application.TwoDevelopment.EducationalAdministration;
- using System.Web.Mvc;
- using System.Collections.Generic;
- using System.Linq;
-
- namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创 建:超级管理员
- /// 日 期:2019-08-26 16:58
- /// 描 述:选修合班设置
- /// </summary>
- public class ElectiveMergeController : MvcControllerBase
- {
- private ElectiveMergeIBLL electiveMergeIBLL = new ElectiveMergeBLL();
- private LessonInfoIBLL lessonInfoIbll = new LessonInfoBLL();
- private OpenLessonPlanOfElectiveIBLL openLessonPlanOfElectiveIbll = new OpenLessonPlanOfElectiveBLL();
-
- #region 视图功能
-
- /// <summary>
- /// 主页面
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Index()
- {
- return View();
- }
- /// <summary>
- /// 表单页
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Form()
- {
- 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 = electiveMergeIBLL.GetPageList(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 ElectiveMergeData = electiveMergeIBLL.GetElectiveMergeEntity(keyValue);
- var jsonData = new
- {
- ElectiveMerge = ElectiveMergeData,
- };
- return Success(jsonData);
- }
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult DeleteForm(string keyValue)
- {
- electiveMergeIBLL.DeleteEntity(keyValue);
- return Success("取消成功!");
- }
-
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveForm(string keyValue, string strEntity)
- {
- ElectiveMergeEntity entity = strEntity.ToObject<ElectiveMergeEntity>();
- electiveMergeIBLL.SetStuNumMax(keyValue, entity.StuNumMax.Value);
- return Success("设置成功!");
- }
-
- [HttpPost]
- [AjaxOnly]
- public ActionResult Merge(string AcademicYearNo, string Semester, string LessonNo, string EmpNo, string keyValue, string F_SchoolId)
- {
- var keyValueArr = keyValue.Split(',');
- if (AcademicYearNo.Split(',').Distinct().Count() == 1 &&
- Semester.Split(',').Distinct().Count() == 1 &&
- LessonNo.Split(',').Distinct().Count() == 1 && EmpNo.Split(',').Distinct().Count() == 1)
- {
- var lesson = lessonInfoIbll.GetLessonInfoEntityByLessonNo(LessonNo.Split(',')[0]);
- if (lesson == null)
- {
- return Fail("合班失败!课程库和排课数据不匹配,请检查。");
- }
- ElectiveMergeEntity emMergeEntity = new ElectiveMergeEntity();
- emMergeEntity.Create();
- emMergeEntity.AcademicYearNo = AcademicYearNo.Split(',')[0];
- emMergeEntity.Semester = Semester.Split(',')[0];
- emMergeEntity.F_SchoolId = F_SchoolId.Split(',')[0];
- emMergeEntity.LessonId = lesson.LessonId;
- emMergeEntity.LessonNo = lesson.LessonNo;
- emMergeEntity.LessonName = lesson.LessonName;
- List<ElectiveMergeItemEntity> listElectiveMergeItemEntity = new List<ElectiveMergeItemEntity>();
- foreach (var item in keyValueArr)
- {
- ElectiveMergeItemEntity emItemEntity = new ElectiveMergeItemEntity();
- emItemEntity.Create();
- emItemEntity.EmId = emMergeEntity.EMId;
- emItemEntity.OLPOEId = item;
- var olpoe = openLessonPlanOfElectiveIbll.GetOpenLessonPlanOfElectiveEntity(item);
- emItemEntity.LessonSection = olpoe.LessonSection;
- emItemEntity.LessonTime = olpoe.LessonTime;
- emItemEntity.EmpNo = olpoe.EmpNo;
- emItemEntity.EmpName = olpoe.EmpName;
- emItemEntity.ClassRoomNo = olpoe.ClassRoomNo;
- emItemEntity.ClassRoomName = olpoe.ClassRoomName;
- listElectiveMergeItemEntity.Add(emItemEntity);
- }
-
- if (listElectiveMergeItemEntity.Select(m=>m.LessonSection.Substring(0,1)).Distinct().Count()>1)
- {
- return Fail("合班失败!请确认所选课程是否为同一天课程。");
- }
- electiveMergeIBLL.SaveEntity(null, emMergeEntity, listElectiveMergeItemEntity);
- return Success("合班成功!");
- }
- else
- return Fail("合班失败!请确认所选课程是否为可合并课程。");
- }
- #endregion
-
- }
- }
|