123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539 |
- 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; }
- /// <summary>
- /// 任选设定页面
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- return View();
- }
- /// <summary>
- /// 查询列表
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [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));
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="specialtyCourseID"></param>
- /// <returns></returns>
- public ActionResult CopyAdd(Guid sourceExecutableFreeSelectionCouseID)
- {
- ExecutableFreeSelectionCouseView executableFreeSelectionCouseView = new ExecutableFreeSelectionCouseView();
- executableFreeSelectionCouseView = ExecutableFreeSelectionCouseServices.GetExecutableFreeSelectionCouseView(sourceExecutableFreeSelectionCouseID);
- return View("Edit", executableFreeSelectionCouseView);
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="ExecutableFreeSelectionCouse"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CopyAdd(ExecutableFreeSelectionCouseView ExecutableFreeSelectionCouse)
- {
- ExecutableFreeSelectionCouse.ExecutableFreeSelectionCouseID = Guid.Empty;
- return this.Edit(ExecutableFreeSelectionCouse);
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="ExecutableFreeSelectionCouseID"></param>
- /// <returns></returns>
- 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);
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="ExecutableFreeSelectionCouse"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(ExecutableFreeSelectionCouseView ExecutableFreeSelectionCouse)
- {
- int? type = 0;
- try
- {
- var teacherList = DataGrid.GetTableData<ExecutableFreeSelectionCouseTeacherListView>("dgTeacherList");
- var specialtyList = DataGrid.GetTableData<ExecutableFreeSelectionCouseSpecialtyListView>("dgSpecialtyList");
- var schedulingList = DataGrid.GetTableData<ExecutableFreeSelectionCouseSchedulingView>("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,
- });
- }
- }
- /// <summary>
- /// 明细页面
- /// </summary>
- /// <param name="ExecutableFreeSelectionCouseID"></param>
- /// <returns></returns>
- 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();
- }
- /// <summary>
- /// 开放
- /// </summary>
- /// <param name="ExecutableFreeSelectionCouseIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Open(string ExecutableFreeSelectionCouseIDs)
- {
- try
- {
- List<Guid?> list = new List<Guid?>();
- 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
- });
- }
- }
- /// <summary>
- /// 取消
- /// </summary>
- /// <param name="ExecutableFreeSelectionCouseIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Cancel(string ExecutableFreeSelectionCouseIDs)
- {
- try
- {
- List<Guid?> list = new List<Guid?>();
- 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
- });
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="ExecutableFreeSelectionCouseIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string ExecutableFreeSelectionCouseIDs)
- {
- try
- {
- List<Guid?> list = new List<Guid?>();
- 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
- });
- }
- }
- /// <summary>
- /// 提交
- /// </summary>
- /// <param name="executableFreeSelectionCouseIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Submit(string executableFreeSelectionCouseIDs)
- {
- try
- {
- List<Guid> list = new List<Guid>();
- 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
- });
- }
- }
- /// <summary>
- /// 导出Excel
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
- var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
- var departmentID = Request.Form["DepartmentDropdown"].ParseStrTo<Guid>();
- var schoolyear = Request.Form["SchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
- //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<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsOpen"].ParseStrTo<int>();
- var Status = Request.Form["DictionaryStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStatus"].ParseStrTo<int>();
- 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);
- }
- /// <summary>
- /// 获取任选课程已经存在在授课方式
- /// </summary>
- /// <param name="freeSelectionCourseID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult TeachingModeType(Guid? ExecutableFreeSelectionCouseID)
- {
- List<int> list = new List<int>();
- 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()));
- }
- /// <summary>
- /// 获取任选课程申请已经存在在授课方式
- /// </summary>
- /// <param name="freeSelectionCourseID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CourseApplyTeachingModeType(Guid? freeSelectionCourseID)
- {
- List<int> list = new List<int>();
- 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<int> list = new List<int>();
- if (ExecutableFreeSelectionCouseID.HasValue && ExecutableFreeSelectionCouseID != Guid.Empty)
- list = ExecutableFreeSelectionCouseServices.GetCourseGradeYear(ExecutableFreeSelectionCouseID);
- return base.Json(list.ConvertAll(x => x.ToString()));
- }
- /// <summary>
- /// 列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult SpecialtyList(Guid ExecutableFreeSelectionCouseID)
- {
- var specialtyList = this.ExecutableFreeSelectionCouseServices.GetExecutableFreeSelectionCouseSpecialtyListView(ExecutableFreeSelectionCouseID);
- return base.Json(new GridResultSet<SpecialtyView>() { rows = specialtyList, total = specialtyList.Count });
- }
- /// <summary>
- /// 列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult TeacherList(Guid ExecutableFreeSelectionCouseID)
- {
- var teacherList = this.ExecutableFreeSelectionCouseServices.GetExecutableFreeSelectionCouseTeacherListView(ExecutableFreeSelectionCouseID);
- return base.Json(new GridResultSet<ExecutableFreeSelectionCouseTeacherListView>() { rows = teacherList, total = teacherList.Count });
- }
- [HttpPost]
- public ActionResult TeacherEdit(Guid ExecutableFreeSelectionCouseID, string addTeacherListJson)
- {
- try
- {
- var addTeacherList = addTeacherListJson.JsonToObject<List<ExecutableFreeSelectionCouseTeacherListView>>();
- 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<ExecutableFreeSelectionCouseSchedulingView> { rows = courseProcessList, total = courseProcessList.Count });
- }
- /// <summary>
- /// 添加教室(排课检查)
- /// </summary>
- /// <returns></returns>
- public ActionResult CourseProcessClassroomList()
- {
- return View();
- }
- /// <summary>
- /// 添加节次(排课检查)
- /// </summary>
- /// <returns></returns>
- public ActionResult CoursesTimeList()
- {
- return View();
- }
- /// <summary>
- /// 列出课程进度中的可选教室
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetCourseProcessClassroomList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- int? classroomType = pararms.getExtraString("ClassroomType").ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : pararms.getExtraString("ClassroomType").ParseStrTo<int>();
- string schedulingWeek = pararms.getExtraString("schedulingWeek");
- int? weekday = pararms.getExtraString("weekDay").ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : pararms.getExtraString("weekDay").ParseStrTo<int>();
- var coursesTimeID = pararms.getExtraGuid("coursesTimeID") ?? Guid.Empty;
- //int? minSeatCount = pararms.getExtraString("MinSeatCount").ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : pararms.getExtraString("MinSeatCount").ParseStrTo<int>();
- //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));
- }
- }
- }
|