using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using EMIS.CommonLogic.SelectCourse; using EMIS.ViewModel; using EMIS.Web.Controls; using Bowin.Common.Data; using Bowin.Web.Controls.Mvc; using Bowin.Common.Mapping; using EMIS.ViewModel.SelectCourse; using EMIS.Utility.FormValidate; using Bowin.Common.Exceptions; using Bowin.Common.Utility; using Bowin.Common.Linq.Entity; using Bowin.Common.JSON; using EMIS.Utility; using EMIS.ViewModel.EnrollManage.SpecialtyManage; using EMIS.ViewModel.EducationManage; namespace EMIS.Web.Controllers.SelectCourseManage { [Authorization] public class ExecutableFreeSelectionCouseController : Controller { public IFreeSelectionCourseServices FreeSelectionCourseServices { get; set; } public IExecutableFreeSelectionCouseServices ExecutableFreeSelectionCouseServices { get; set; } public IFreeSelectionCourseApplyServices FreeSelectionCourseApplyServices { get; set; } /// /// 任选设定页面 /// /// public ActionResult List() { return View(); } /// /// 查询列表 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var campusID = pararms.getExtraGuid("CampusDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var departmentID = pararms.getExtraGuid("DepartmentDropdown"); var schoolyear = pararms.getExtraGuid("SchoolYearDropdown").ToString() == DropdownList.SELECT_ALL.ToString() ? null : pararms.getExtraGuid("SchoolYearDropdown"); //var schoolyearNum = pararms.getExtraInt("DictionarySchoolyearNum").ToString() == DropdownList.SELECT_ALL.ToString() ? null : pararms.getExtraInt("DictionarySchoolyearNum"); //var schoolcode = pararms.getExtraInt("DictionarySchoolcode").ToString() == DropdownList.SELECT_ALL.ToString() ? null : pararms.getExtraInt("DictionarySchoolcode"); var isOpen = pararms.getExtraInt("DictionaryIsOpen") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsOpen"); var Status = pararms.getExtraInt("DictionaryStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStatus"); return this.Json(ExecutableFreeSelectionCouseServices.GetExecutableFreeSelectionCouseViewGrid(configuretView, schoolyear, campusID, collegeID, departmentID, Status, isOpen, (int)pararms.page, (int)pararms.rows)); } /// /// 复制新增 /// /// /// public ActionResult CopyAdd(Guid sourceExecutableFreeSelectionCouseID) { ExecutableFreeSelectionCouseView executableFreeSelectionCouseView = new ExecutableFreeSelectionCouseView(); executableFreeSelectionCouseView = ExecutableFreeSelectionCouseServices.GetExecutableFreeSelectionCouseView(sourceExecutableFreeSelectionCouseID); return View("Edit", executableFreeSelectionCouseView); } /// /// 复制新增 /// /// /// [HttpPost] public ActionResult CopyAdd(ExecutableFreeSelectionCouseView ExecutableFreeSelectionCouse) { ExecutableFreeSelectionCouse.ExecutableFreeSelectionCouseID = Guid.Empty; return this.Edit(ExecutableFreeSelectionCouse); } /// /// 编辑 /// /// /// public ActionResult Edit(Guid? ExecutableFreeSelectionCouseID) { ExecutableFreeSelectionCouseView executableFreeSelectionCouseView = new ExecutableFreeSelectionCouseView(); executableFreeSelectionCouseView.HandleModeID = (int)EMIS.ViewModel.CF_HandleMode.SelectionCourse; executableFreeSelectionCouseView.DepartmentID = CustomPrincipal.Current.DepartmentID; if (ExecutableFreeSelectionCouseID.HasValue) executableFreeSelectionCouseView = ExecutableFreeSelectionCouseServices.GetExecutableFreeSelectionCouseView(ExecutableFreeSelectionCouseID); else { var staff = FreeSelectionCourseApplyServices.GetStaff(CustomPrincipal.Current.UserID); if (staff != null) { executableFreeSelectionCouseView.DepartmentID = staff.DepartmentID; ViewBag.DepartmentID = staff.DepartmentID; } } return View(executableFreeSelectionCouseView); } /// /// 编辑 /// /// /// [HttpPost] public ActionResult Edit(ExecutableFreeSelectionCouseView ExecutableFreeSelectionCouse) { int? type = 0; try { var teacherList = DataGrid.GetTableData("dgTeacherList"); var specialtyList = DataGrid.GetTableData("dgSpecialtyList"); var schedulingList = DataGrid.GetTableData("dgSchedulingList"); if (ExecutableFreeSelectionCouse.ExecutableFreeSelectionCouseID == null || ExecutableFreeSelectionCouse.ExecutableFreeSelectionCouseID == Guid.Empty) { ExecutableFreeSelectionCouseServices.ExecutableFreeSelectionCouseAdd(ExecutableFreeSelectionCouse, teacherList, specialtyList, schedulingList, out type); } else { ExecutableFreeSelectionCouseServices.ExecutableFreeSelectionCouseUpdate(ExecutableFreeSelectionCouse, teacherList, specialtyList, schedulingList, out type); } return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } catch (Exception ex) { //如果验证到排课冲突type返回1,页面js根据type弹出选择框,用户可选择继续保存或不保存,如果不返回1,弹出一般的错误提示框 if (type == 1) { return Json(new ReturnMessage() { Type = 1, IsSuccess = false, Message = "保存失败:" + ex.Message, }); } else return Json(new ReturnMessage() { IsSuccess = false, Type = 2, Message = "保存失败:" + ex.Message, }); } } /// /// 明细页面 /// /// /// public ActionResult Details(Guid? ExecutableFreeSelectionCouseID) { ExecutableFreeSelectionCouseView freeSelectCourseApplyView = new ExecutableFreeSelectionCouseView(); if (ExecutableFreeSelectionCouseID.HasValue) freeSelectCourseApplyView = ExecutableFreeSelectionCouseServices.GetExecutableFreeSelectionCouseView(ExecutableFreeSelectionCouseID); return View(freeSelectCourseApplyView); } public ActionResult TeacherEdit(Guid ExecutableFreeSelectionCouseID) { return View(); } /// /// 开放 /// /// /// [HttpPost] public ActionResult Open(string ExecutableFreeSelectionCouseIDs) { try { List list = new List(); for (int i = 0; i < ExecutableFreeSelectionCouseIDs.Split(',').Length; i++) { string id = ExecutableFreeSelectionCouseIDs.Split(',')[i]; if (!string.IsNullOrEmpty(id)) { Guid ExecutableFreeSelectionCouseID = new Guid(id); list.Add(ExecutableFreeSelectionCouseID); } } ExecutableFreeSelectionCouseServices.ExecutableFreeSelectionCouseOpen(list); return Json(new ReturnMessage() { IsSuccess = true, Message = "开放成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "开放失败,原因:" + ex.Message }); } } /// /// 取消 /// /// /// [HttpPost] public ActionResult Cancel(string ExecutableFreeSelectionCouseIDs) { try { List list = new List(); for (int i = 0; i < ExecutableFreeSelectionCouseIDs.Split(',').Length; i++) { string id = ExecutableFreeSelectionCouseIDs.Split(',')[i]; if (!string.IsNullOrEmpty(id)) { Guid ExecutableFreeSelectionCouseID = new Guid(id); list.Add(ExecutableFreeSelectionCouseID); } } ExecutableFreeSelectionCouseServices.ExecutableFreeSelectionCouseCancel(list); return Json(new ReturnMessage() { IsSuccess = true, Message = "取消成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "取消失败,原因:" + ex.Message }); } } /// /// 删除 /// /// /// [HttpPost] public ActionResult Delete(string ExecutableFreeSelectionCouseIDs) { try { List list = new List(); for (int i = 0; i < ExecutableFreeSelectionCouseIDs.Split(',').Length; i++) { string id = ExecutableFreeSelectionCouseIDs.Split(',')[i]; if (!string.IsNullOrEmpty(id)) { Guid ExecutableFreeSelectionCouseID = new Guid(id); list.Add(ExecutableFreeSelectionCouseID); } } ExecutableFreeSelectionCouseServices.ExecutableFreeSelectionCouseDelete(list); return Json(new ReturnMessage() { IsSuccess = true, Message = "删除成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "删除失败,原因:" + ex.Message }); } } /// /// 提交 /// /// /// [HttpPost] public ActionResult Submit(string executableFreeSelectionCouseIDs) { try { List list = new List(); for (int i = 0; i < executableFreeSelectionCouseIDs.Split(',').Length; i++) { if (!string.IsNullOrEmpty(executableFreeSelectionCouseIDs.Split(',')[i])) { Guid ID = new Guid(executableFreeSelectionCouseIDs.Split(',')[i]); list.Add(ID); } } ExecutableFreeSelectionCouseServices.ExecutableFreeSelectionCouseSubmit(list); return Json(new ReturnMessage() { IsSuccess = true, Message = "提交成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "提交失败,原因:" + ex.Message }); } } /// /// 导出Excel /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var campusID = Request.Form["CampusDropdown"].ParseStrTo(); var collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); var departmentID = Request.Form["DepartmentDropdown"].ParseStrTo(); var schoolyear = Request.Form["SchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["SchoolyearDropdown"].ParseStrTo(); //var schoolyearNum = Request.Form["DictionarySchoolyearNum"].ToString() == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["DictionarySchoolyearNum"]; //var schoolcode = Request.Form["DictionarySchoolcode"].ToString() == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["DictionarySchoolcode"]; var isOpen = Request.Form["DictionaryIsOpen"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsOpen"].ParseStrTo(); var Status = Request.Form["DictionaryStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStatus"].ParseStrTo(); var dt = ExecutableFreeSelectionCouseServices.GetExecutableFreeSelectionCouseViewList(configuretView, schoolyear, campusID, collegeID, departmentID, Status, isOpen).Select(x => new { //x.FreeSelectionCouseNo, x.SchoolyearName, x.DepartmentName, //x.CollegeName, x.DefaultClassName, x.WeekdayTimesSegmentName, //x.CourseCode, //x.CourseName, //x.CourseCategoryName, //x.CourseTypeName, //x.CourseQualityName, //x.Credit, //x.Totalhours, //x.SchoolweeksNum, //x.SchoolyearNumName, //x.SchoolcodeName, //x.StarttermName, x.TeacherNames, x.PeopleNumlower, x.PeopleNumlimit, x.CourseTypeName, x.IsNeedMaterialName, x.ApprovalStatusName }).ToTable(); string[] liststring = { //"选课编号", "学年学期", "教研室", //RSL.Get("College"), "选修任务班名称", //"课程代码", //"课程名称", "课程属性", "课程类型", "课程性质", "学分","总学时", //"上课周数", "学年数", "学期", "开课学期" "上课时间", "授课教师","人数下限","人数上限","选修类型","是否需要教材","审批状态"}; neh.Export(dt, liststring, "计划申请信息"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Content("~/ExecutableFreeSelectionCouse/List").AddMenuParameter() }); } public ActionResult GetFreeSelectionCourseView(Guid? freeSelectionCourseID) { FreeSelectionCourseView freeSelectionCourseView = new FreeSelectionCourseView(); if (freeSelectionCourseID.HasValue) freeSelectionCourseView = FreeSelectionCourseServices.GetFreeSelectionCourseView(freeSelectionCourseID); return base.Json(freeSelectionCourseView); } /// /// 获取任选课程已经存在在授课方式 /// /// /// [HttpPost] public ActionResult TeachingModeType(Guid? ExecutableFreeSelectionCouseID) { List list = new List(); if (ExecutableFreeSelectionCouseID.HasValue && ExecutableFreeSelectionCouseID != Guid.Empty) list = ExecutableFreeSelectionCouseServices.GetCourseTeachingModeType(ExecutableFreeSelectionCouseID); else list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory)); return base.Json(list.ConvertAll(x => x.ToString())); } /// /// 获取任选课程申请已经存在在授课方式 /// /// /// [HttpPost] public ActionResult CourseApplyTeachingModeType(Guid? freeSelectionCourseID) { List list = new List(); if (freeSelectionCourseID.HasValue && freeSelectionCourseID != Guid.Empty) list = ExecutableFreeSelectionCouseServices.GetCourseTeachingModeType(freeSelectionCourseID); else list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory)); return base.Json(list.ConvertAll(x => x.ToString())); } [HttpPost] public ActionResult GradeYear(Guid? ExecutableFreeSelectionCouseID) { List list = new List(); if (ExecutableFreeSelectionCouseID.HasValue && ExecutableFreeSelectionCouseID != Guid.Empty) list = ExecutableFreeSelectionCouseServices.GetCourseGradeYear(ExecutableFreeSelectionCouseID); return base.Json(list.ConvertAll(x => x.ToString())); } /// /// 列表查询 /// /// /// [HttpPost] public ActionResult SpecialtyList(Guid ExecutableFreeSelectionCouseID) { var specialtyList = this.ExecutableFreeSelectionCouseServices.GetExecutableFreeSelectionCouseSpecialtyListView(ExecutableFreeSelectionCouseID); return base.Json(new GridResultSet() { rows = specialtyList, total = specialtyList.Count }); } /// /// 列表查询 /// /// /// [HttpPost] public ActionResult TeacherList(Guid ExecutableFreeSelectionCouseID) { var teacherList = this.ExecutableFreeSelectionCouseServices.GetExecutableFreeSelectionCouseTeacherListView(ExecutableFreeSelectionCouseID); return base.Json(new GridResultSet() { rows = teacherList, total = teacherList.Count }); } [HttpPost] public ActionResult TeacherEdit(Guid ExecutableFreeSelectionCouseID, string addTeacherListJson) { try { var addTeacherList = addTeacherListJson.JsonToObject>(); ExecutableFreeSelectionCouseServices.SaveTeachers(ExecutableFreeSelectionCouseID, addTeacherList); return Json(new ReturnMessage { IsSuccess = true }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message }); } } [HttpPost] public ActionResult DefaultClassNo(Guid SchoolyearID, Guid freeSelectionCourseID, string StartWeeklyNum, string EndWeeklyNum) { try { var result = ExecutableFreeSelectionCouseServices.DefaultClassNo(SchoolyearID, freeSelectionCourseID, StartWeeklyNum, EndWeeklyNum); return base.Json(result); } catch (Exception ex) { return Json(""); } } public ActionResult GetSchedulingViewList(Guid ExecutableFreeSelectionCouseID) { var courseProcessList = this.ExecutableFreeSelectionCouseServices.GetSchedulingView(ExecutableFreeSelectionCouseID); return Json(new GridResultSet { rows = courseProcessList, total = courseProcessList.Count }); } /// /// 添加教室(排课检查) /// /// public ActionResult CourseProcessClassroomList() { return View(); } /// /// 添加节次(排课检查) /// /// public ActionResult CoursesTimeList() { return View(); } /// /// 列出课程进度中的可选教室 /// /// /// [HttpPost] public ActionResult GetCourseProcessClassroomList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); int? classroomType = pararms.getExtraString("ClassroomType").ParseStrTo() == DropdownList.SELECT_ALL ? null : pararms.getExtraString("ClassroomType").ParseStrTo(); string schedulingWeek = pararms.getExtraString("schedulingWeek"); int? weekday = pararms.getExtraString("weekDay").ParseStrTo() == DropdownList.SELECT_ALL ? null : pararms.getExtraString("weekDay").ParseStrTo(); var coursesTimeID = pararms.getExtraGuid("coursesTimeID") ?? Guid.Empty; //int? minSeatCount = pararms.getExtraString("MinSeatCount").ParseStrTo() == DropdownList.SELECT_ALL ? null : pararms.getExtraString("MinSeatCount").ParseStrTo(); //var collegeID = pararms.getExtraGuid("CollegeDropdown") ?? Guid.Empty; var buildingsID = pararms.getExtraInt("BuildingsDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraGuid("BuildingsDropdown"); return base.Json(ExecutableFreeSelectionCouseServices.GetAvailableClassroom(configuretView, buildingsID, schedulingWeek, weekday, coursesTimeID, classroomType, (int)pararms.page, (int)pararms.rows)); } } }