using EMIS.CommonLogic.SelectCourse.SelectCourseResult; using EMIS.ViewModel; using EMIS.Web.Controls; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Bowin.Common.Utility; using EMIS.ViewModel.SelectCourse; using EMIS.CommonLogic.SelectCourse; using Bowin.Web.Controls.Mvc; using Bowin.Common.Linq.Entity; using Bowin.Common.Data; using EMIS.ViewModel.Students; using EMIS.ViewModel.SelectCourse.SelectCourseResult; using EMIS.Utility; namespace EMIS.Web.Controllers.SelectCourseManage.SelectCourseResult { [Authorization] public class SelectCourseResultController : Controller { public ISelectCourseResultServices SelectCourseResultServices { get; set; } public IOptionalCourseSettingServices optionalCourseSettingServices { get; set; } public IExecutableFreeSelectionCouseServices ExecutableFreeSelectionCouseServices { get; set; } /// /// 选课结果页面 /// /// public ActionResult List() { return View(); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("SchoolYear"); var collegeID = pararms.getExtraGuid("CollegeComboGrid"); var coursematerialID = pararms.getExtraGuid("CoursematerialComboGrid"); var courseTypeID = pararms.getExtraInt("DictionaryCourseType") == -1 ? null : pararms.getExtraInt("DictionaryCourseType"); var selectCourseTypeID = pararms.getExtraInt("DictionarySelectCourseType") == -1 ? null : pararms.getExtraInt("DictionarySelectCourseType"); var isCreated = pararms.getExtraInt("DictionaryIsCreated") == -1 ? null : pararms.getExtraInt("DictionaryIsCreated"); var isOpen = pararms.getExtraInt("DictionaryIsOpen") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsOpen"); var result = SelectCourseResultServices.GetSelectCourseResultViewList(configuretView, schoolyearID, collegeID, coursematerialID, courseTypeID, selectCourseTypeID,isCreated,isOpen, (int)pararms.page, (int)pararms.rows); return Json(result); } /// /// 编辑 /// /// public ActionResult Edit(Guid? ID,string Type) { if (Type == "0") //限选 { OptionalCourseSettingView optionalCourseSettingView = new OptionalCourseSettingView(); if (ID.HasValue && ID != Guid.Empty) optionalCourseSettingView = optionalCourseSettingServices.GetOptionalCourseSettingView(ID); return View(optionalCourseSettingView); } else //任选 { OptionalCourseSettingView optionalCourseSettingView = new OptionalCourseSettingView(); if (ID.HasValue && ID != Guid.Empty) optionalCourseSettingView = optionalCourseSettingServices.GetOptionalCourseSettingView(ID); return View(optionalCourseSettingView); } } /// /// 保存修改 /// /// /// [HttpPost] public ActionResult Edit(OptionalCourseSettingView optionalCourseSettingView) { try { var teacherList = DataGrid.GetTableData("dgTeacherList"); SelectCourseResultServices.OptionalCourseSettingUpdate(optionalCourseSettingView, teacherList); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } /// /// 编辑 /// /// public ActionResult EditFreeSelection(Guid? ID, string Type) { ExecutableFreeSelectionCouseView executableFreeSelectionCouseView = new ExecutableFreeSelectionCouseView(); if (ID.HasValue && ID != Guid.Empty) executableFreeSelectionCouseView = ExecutableFreeSelectionCouseServices.GetExecutableFreeSelectionCouseView(ID); return View(executableFreeSelectionCouseView); } [HttpPost] public ActionResult EditFreeSelection(ExecutableFreeSelectionCouseView executableFreeSelectionCouseView) { try { var teacherList = DataGrid.GetTableData("dgTeacherList"); ExecutableFreeSelectionCouseServices.ExecutableFreeSelectionCouseUpdate(executableFreeSelectionCouseView, teacherList); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } /// /// 获取任务班授课老师 /// /// /// [HttpPost] public ActionResult TeacherList(Guid executableOptionalCourseID) { var teacherList = optionalCourseSettingServices.GetEducationMissionClassTeacherListViewList(executableOptionalCourseID); return Json(new GridResultSet() { rows = teacherList, total = teacherList.Count }); } public ActionResult StudentList(Guid ID, string Type) { ViewBag.ID = ID; ViewBag.Type = Type; return View(); } /// /// /// /// /// [HttpPost] public ActionResult StudentViewList(QueryParamsModel pararms) //QueryParamsModel pararms { var ID = Request["ID"].ParseStrTo(); var type = Request["Type"]; var result = SelectCourseResultServices.GetSelectCourseStudentViewGrid(ID.Value, type, 0, 0); return Json(result); } /// /// 学生名单 /// /// /// [HttpPost] public ActionResult StudentList(SelectCourseResultView selectCourseResult) { try { var studentList = DataGrid.GetTableData("dgStudentList"); //// var addTeacherList = addTeacherListJson.JsonToObject>(); SelectCourseResultServices.EditStudent(selectCourseResult, studentList); return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message }); } } /// /// 添加学生名单 /// /// public ActionResult StudentAdd() { return View(); } /// /// 学生选课名单Excel导出 /// /// [HttpPost] public ActionResult Excel_StudentList() { NpoiExcelHelper neh = new NpoiExcelHelper(); var ID = Request["ID"].ParseStrTo(); var type = Request["Type"]; var dt = SelectCourseResultServices.GetSelectCourseStudentViewList(ID.Value, type) .Select(x => new { x.SchoolYearCode, x.DefaultClassName, x.CoursematerialCode, x.CoursematerialName, x.CourseTypeName, x.LoginID, x.UserName, x.SexName, x.ClassmajorName, x.InSchoolStatusName, x.StudentStatusName }).ToTable(); string[] liststring = { "学年学期", "选修任务班名称", "课程代码", "课程名称", "课程类型", "学号", "姓名","性别", "班级名称","在校状态", "学籍状态" }; neh.Export(dt, liststring, "选课结果学生名单" + DateTime.Now.ToString("yyyyMMdd")); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Content("~/SelectCourseResult/List").AddMenuParameter() }); } [HttpPost] public ActionResult Excel() { //return View(); NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); //避开全选值 if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = ""; var schoolyearID = Request.Form["SchoolYear"].ParseStrTo(); var collegeID = Request.Form["CollegeComboGrid"].ParseStrTo(); var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo(); var courseTypeID = Request.Form["DictionaryCourseType"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryCourseType"].ParseStrTo(); var selectCourseTypeID = Request.Form["DictionarySelectCourseType"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySelectCourseType"].ParseStrTo(); var isCreated = Request.Form["DictionaryIsCreated"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsCreated"].ParseStrTo(); var isOpen = Request.Form["DictionaryIsOpen"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsOpen"].ParseStrTo(); var dt = SelectCourseResultServices.GetSelectCourseResultViewList(configuretView, schoolyearID, collegeID, coursematerialID, courseTypeID, selectCourseTypeID, isCreated,isOpen) .Select(x => new { x.SchoolYearCode, x.DefaultClassName, //x.CourseCode, x.CourseName, x.CourseTypeName, //x.CourseCategoryName, x.CourseQualityName, x.Credit, x.Totalhours, x.WeekdayTimesSegmentName, x.PeopleNumlower, x.PeopleNumlimit, x.StudentTotalNum, x.SelectCourseTypeName, //x.TeachingModeName, //x.SchoolcodeName, x.ClassroomName, x.TeacherName, x.DepartmentName, //x.IsOpenedDesc x.RecordStatusName }).ToTable(); string[] liststring = { "学年学期", "选修任务班名称", "课程名称", "课程类型", "课程性质", "学分", "总学时","上课时间", "人数下限", "人数上限", "已选人数", "选修类型", "教室信息", "教师姓名", "开课教研室", "状态" }; neh.Export(dt, liststring, "选课结果"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Content("~/SelectCourseResult/List").AddMenuParameter() }); } /// /// 生成任务班 /// /// [HttpPost] public ActionResult GenerateEducationMissionClassSubminit(string teachingPlanIDs, string Types) { try { List list = new List(); for (int i = 0; i < teachingPlanIDs.Split(',').Length; i++) { string id = teachingPlanIDs.Split(',')[i]; if (!string.IsNullOrEmpty(id)) { Guid teachingPlanID = new Guid(id); list.Add(teachingPlanID); } } SelectCourseResultServices.ChooseEducationMissionClass(list, Types); return Json(new ReturnMessage() { IsSuccess = true, Message = "开班成功,已生成教学任务班!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "生成任务班失败,原因:" + ex.Message }); } } /// /// 取消开班 /// /// [HttpPost] public ActionResult CancelEducationMissionClass(string teachingPlanIDs) { try { List list = new List(); for (int i = 0; i < teachingPlanIDs.Split(',').Length; i++) { string id = teachingPlanIDs.Split(',')[i]; if (!string.IsNullOrEmpty(id)) { Guid teachingPlanID = new Guid(id); list.Add(teachingPlanID); } } SelectCourseResultServices.CancelEducationMissionClass(list); return this.Json("取消开班成功!"); } catch (Exception ex) { return this.Json("取消开班失败,原因:" + ex.Message); } } [HttpPost] public ActionResult CheckEnouthNum(string IDs) { try { List list = new List(); for (int i = 0; i < IDs.Split(',').Length; i++) { string id = IDs.Split(',')[i]; if (!string.IsNullOrEmpty(id)) { Guid ID = new Guid(id); list.Add(ID); } } var result = SelectCourseResultServices.CheckEnouthNum(list); return Json(new ReturnMessage() { IsSuccess = true, Data = result }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = true, Message = "检查任务班生成情况失败:" + ex.Message }); } } //[HttpPost] //public ActionResult CheckHaveTeacherOrClassroom(string IDs) //{ // try // { // List list = new List(); // for (int i = 0; i < IDs.Split(',').Length; i++) // { // string id = IDs.Split(',')[i]; // if (!string.IsNullOrEmpty(id)) // { // Guid ID = new Guid(id); // list.Add(ID); // } // } // var result = SelectCourseResultServices.CheckEnouthNum(list); // return Json(new ReturnMessage() // { // IsSuccess = true, // Data = result // }); // } // catch (Exception ex) // { // return Json(new ReturnMessage() // { // IsSuccess = true, // Message = "检查任务班生成情况失败:" + ex.Message // }); // } //} } }