using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Bowin.Web.Controls.Mvc; using Bowin.Common.Linq.Entity; using Bowin.Common.JSON; using Bowin.Common.Utility; using Bowin.Common.Data; using EMIS.CommonLogic.EducationManage; using EMIS.ViewModel.EducationManage; using EMIS.CommonLogic.EducationSchedule; using EMIS.ViewModel; using EMIS.ViewModel.EducationSchedule; using EMIS.CommonLogic.SystemServices; using EMIS.Utility.FormValidate; using EMIS.CommonLogic.SchedulingManage.ScheduleApproval; using EMIS.Web.Controls; using EMIS.CommonLogic.CalendarManage; namespace EMIS.Web.Controllers.EducationSchedule { [Authorization] public class EducationScheduleController : Controller { public IEducationSchedulingClassServices EducationSchedulingClassServices { get; set; } public IEducationSchedulingAdjustmentServices EducationSchedulingAdjustmentServices { get; set; } public IEducationSchedulingStopServices EducationSchedulingStopServices { get; set; } public EMIS.CommonLogic.EducationSchedule.IScheduleServices ScheduleServices { get; set; } public ICollegeScheduleApprovalServices CollegeScheduleApprovalServices { get; set; } public IParameterServices ParameterServices { get; set; } public IUserServices UserServices { get; set; } public ISchoolYearServices SchoolYearServices { get; set; } public EMIS.CommonLogic.SchedulingManage.SchedulingSettings.ICollegePriorityServices CollegePriorityServices { get; set; } protected override JsonResult Json(object data, string contentType, System.Text.Encoding contentEncoding, JsonRequestBehavior behavior) { return new JsonResult() { Data = data, ContentType = contentType, ContentEncoding = contentEncoding, JsonRequestBehavior = behavior, MaxJsonLength = Int32.MaxValue }; } public ActionResult List() { return View(); } public ActionResult DepartmentList() { return View(); } public ActionResult Edit() { return View(); } public ActionResult DepartmentEdit() { return View(); } public ActionResult Setting() { return View(); } public ActionResult SelectGroup() { return View(); } [HttpGet] public ActionResult Submit() { return View(); } public ActionResult WeekModify() { return View(); } public ActionResult ClassroomScheduleView() { return View(); } public ActionResult ClassroomModify() { return View(); } public ActionResult SetTeacher() { return View(); } public ActionResult PreSelectWeeks() { return View(); } [HttpPost] public ActionResult TeacherList(QueryParamsModel pararms) { var educationSchedulingID = new Guid(Request["EducationSchedulingID"]); var teacherList = this.ScheduleServices.GetEducationSchedulingTeacherViewList(educationSchedulingID); return Json(new GridResultSet { rows = teacherList, total = teacherList.Count }); } [HttpPost] public ActionResult Submit(CollegeSubmitView collegeSubmitView) { try { ScheduleServices.Submit(collegeSubmitView.CollegeID.Value); return Json(new ReturnMessage() { IsSuccess = true, Message = "提交成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "提交失败:" + ex.Message }); } } public ActionResult Adjustment() { return View(); } public ActionResult AdjustmentList() { ViewBag.StartStatusID = this.EducationSchedulingAdjustmentServices.GetStartStatus(); ViewBag.BackpointIDs = this.EducationSchedulingAdjustmentServices.GetBackpointStatus().ToJson(); return View(); } [HttpPost] public ActionResult AdjustmentList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("ddlSchoolyear"); var coursematerialID = pararms.getExtraGuid("cgbCoursematerial"); var collegeID = pararms.getExtraGuid("ddlCollege"); var teacherID = pararms.getExtraGuid("cgbTeacher"); var classroomID = pararms.getExtraGuid("cbgClassroom"); var applyUserID = pararms.getExtraGuid("cgbApplyUser"); var startTime = pararms.getExtraDateTime("txtStartTime"); var endTime = pararms.getExtraDateTime("txtEndTime"); var recordStatus = pararms.getExtraInt("ddlRecordStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlRecordStatus"); var result = EducationSchedulingAdjustmentServices.GetScheduleAdjustmentViewList(configuretView, schoolyearID, coursematerialID, collegeID, teacherID, classroomID, applyUserID, startTime, endTime, recordStatus, (int)pararms.page, (int)pararms.rows); return Json(result); } [HttpPost] public ActionResult Adjustment(QueryParamsModel pararms) { var schoolyearID = pararms.getExtraGuid("ddlSchoolyear"); var userID = pararms.getExtraGuid("cgbTeacher"); var coursematerialID = pararms.getExtraGuid("cgbCoursematerial"); var educationMissionClassID = pararms.getExtraGuid("cgbEducationMissionClass"); var weekNum = pararms.getExtraInt("ddlWeekNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlWeekNum"); var weekday = pararms.getExtraInt("ddlWeekDay") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlWeekDay"); var courseTimesID = pararms.getExtraGuid("ddlCourseTimes"); var classroomID = pararms.getExtraGuid("cgbClassroom"); if (!userID.HasValue) { return Json(new GridResultSet { rows = new List(), total = 0 }); } var scheduleAdjustmentViewList = this.ScheduleServices.GetTeacherScheduleAdjustmentViewList(schoolyearID ?? Guid.Empty, userID.Value, coursematerialID, educationMissionClassID, weekNum, weekday, courseTimesID, classroomID); return Json(new GridResultSet { rows = scheduleAdjustmentViewList, total = scheduleAdjustmentViewList.Count }); } [HttpPost] public ActionResult Stop(QueryParamsModel pararms) { var schoolyearID = pararms.getExtraGuid("ddlSchoolyear"); var userID = pararms.getExtraGuid("cgbTeacher"); var coursematerialID = pararms.getExtraGuid("cgbCoursematerial"); var educationMissionClassID = pararms.getExtraGuid("cgbEducationMissionClass"); var weekNum = pararms.getExtraInt("ddlWeekNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlWeekNum"); var weekday = pararms.getExtraInt("ddlWeekDay") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlWeekDay"); var courseTimesID = pararms.getExtraGuid("ddlCourseTimes"); var classroomID = pararms.getExtraGuid("cgbClassroom"); if (!userID.HasValue) { return Json(new GridResultSet { rows = new List(), total = 0 }); } var scheduleAdjustmentViewList = this.ScheduleServices.GetTeacherScheduleStopViewList(schoolyearID ?? Guid.Empty, userID.Value, coursematerialID, educationMissionClassID, weekNum, weekday, courseTimesID, classroomID); return Json(new GridResultSet { rows = scheduleAdjustmentViewList, total = scheduleAdjustmentViewList.Count }); } public ActionResult AdjustmentEdit(Guid? EducationSchedulingAdjustmentID, Guid? EducationSchedulingWeekNumID, Guid? UserID) { if (EducationSchedulingWeekNumID.HasValue) { var scheduleAdjustmentView = this.ScheduleServices.GetScheduleAdjustmentView(EducationSchedulingWeekNumID.Value); var user = this.UserServices.GetUserByID(UserID.Value); scheduleAdjustmentView.ToClassroomTypeID = scheduleAdjustmentView.ClassroomTypeID; scheduleAdjustmentView.UserID = user.UserID; scheduleAdjustmentView.ToUserID = scheduleAdjustmentView.UserID; scheduleAdjustmentView.UserName = user.Name; return View(scheduleAdjustmentView); } else { var scheduleAdjustmentView = this.EducationSchedulingAdjustmentServices.GetScheduleAdjustmentEditView(EducationSchedulingAdjustmentID.Value); return View(scheduleAdjustmentView); } } public ActionResult AdjustmentBatchEdit(int? classroomTypeID, string educationSchedulingWeekNumIDs) { ViewBag.EducationSchedulingWeekNumIDs = educationSchedulingWeekNumIDs; ViewBag.WeekNumDropdownItemList = SchoolYearServices.GetCurrentSchoolyearWeekNumList() .Select(x => new DropdownListItem { Text = x.ToString(), Value = x.ToString() }) .ToList(); return View(); } [HttpPost] public ActionResult AdjustmentBatchEdit(string educationSchedulingWeekNumIDs, Guid fromUserID, int? toWeekNum, int? toWeekday, Guid? toUserID, Guid? toCoursesTimeID, int? toClassroomType, Guid? toClassroom) { try { var educationSchedulingWeekNumIDList = educationSchedulingWeekNumIDs.Split(',') .Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); this.EducationSchedulingAdjustmentServices.BatchSave(educationSchedulingWeekNumIDList, fromUserID, toWeekNum, toWeekday, toUserID, toCoursesTimeID, toClassroomType, toClassroom); return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } [HttpPost] public ActionResult AdjustmentEdit(ScheduleAdjustmentEditView scheduleAdjustment) { try { this.EducationSchedulingAdjustmentServices.Save(scheduleAdjustment); return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } [HttpPost] public ActionResult AdjustmentDelete(string educationSchedulingAdjustmentIDs) { try { var adjustmentIDList = educationSchedulingAdjustmentIDs.Split(',') .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); this.EducationSchedulingAdjustmentServices.Delete(adjustmentIDList); return Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + ex.Message }); } } [HttpPost] public ActionResult AdjustmentSubmit(string educationSchedulingAdjustmentIDs) { try { var adjustmentIDList = educationSchedulingAdjustmentIDs.Split(',') .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); this.EducationSchedulingAdjustmentServices.Submit(adjustmentIDList, CustomPrincipal.Current.UserID); return Json(new ReturnMessage { IsSuccess = true, Message = "提交成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "提交失败:" + ex.Message }); } } [HttpPost] public ActionResult AdjustmentExcel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var selectedID = Request.Form["hidEducationSchedulingAdjustmentID"] ?? ""; var schoolyearID = Request.Form["ddlSchoolyear"].ParseStrTo(); var coursematerialID = Request.Form["cgbCoursematerial"].ParseStrTo(); var collegeID = Request.Form["ddlCollege"].ParseStrTo(); var teacherID = Request.Form["cgbTeacher"].ParseStrTo(); var classroomID = Request.Form["cbgClassroom"].ParseStrTo(); var applyUserID = Request.Form["cgbApplyUser"].ParseStrTo(); var startTime = Request.Form["txtStartTime"].ParseStrTo(); var endTime = Request.Form["txtEndTime"].ParseStrTo(); var recordStatus = Request.Form["ddlRecordStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlRecordStatus"].ParseStrTo(); List result; if (!string.IsNullOrEmpty(selectedID)) { var adjustmentIDList = selectedID.Split(',') .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); result = EducationSchedulingAdjustmentServices.GetScheduleAdjustmentViewList(adjustmentIDList); } else { result = EducationSchedulingAdjustmentServices.GetScheduleAdjustmentViewList(configuretView, schoolyearID, coursematerialID, collegeID, teacherID, classroomID, applyUserID, startTime, endTime, recordStatus); } var dt = result.Select(x => new { x.SchoolyearCode, x.CourseCode, x.CourseName, x.EducationMissionClassName, x.TeacherNames, x.TimeDetail, x.ClassroomName, x.ToTeacherNames, x.ToTimeDetail, x.ToClassroomName, x.ApplyUserName, ApplyTime = x.ApplyTime.HasValue ? x.ApplyTime.Value.ToString("yyyy-MM-dd") : "", x.RecordStatusName }).ToTable(); string[] liststring = { "学年学期", "课程代码", "课程名称", "任务班名称", "原任课老师", "原上课时间","原教室", "任课老师", "上课时间", "教室", "申请人", "申请时间", "状态"}; neh.Export(dt, liststring, "课程调整信息"); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } public ActionResult AdjustmentApprove() { ViewBag.DefaultApproveStatusID = EducationSchedulingAdjustmentServices.GetApproveStatusViewList().Select(x => x.ID).FirstOrDefault(); return View(); } [HttpPost] public ActionResult AdjustmentApproveList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("ddlSchoolyear"); var coursematerialID = pararms.getExtraGuid("cgbCoursematerial"); var collegeID = pararms.getExtraGuid("ddlCollege"); var teacherID = pararms.getExtraGuid("cgbTeacher"); var classroomID = pararms.getExtraGuid("cbgClassroom"); var applyUserID = pararms.getExtraGuid("cgbApplyUser"); var startTime = pararms.getExtraDateTime("txtStartTime"); var endTime = pararms.getExtraDateTime("txtEndTime"); var recordStatus = pararms.getExtraInt("ddlRecordStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlRecordStatus"); var result = EducationSchedulingAdjustmentServices.GetScheduleAdjustmentViewApproveList(configuretView, schoolyearID, coursematerialID, collegeID, teacherID, classroomID, applyUserID, startTime, endTime, recordStatus, (int)pararms.page, (int)pararms.rows); return Json(result); } [HttpPost] public ActionResult AdjustmentApprove(string educationSchedulingAdjustmentIDs, Guid actionID, string comment) { var adjustmentIDList = educationSchedulingAdjustmentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); var curUserID = CustomPrincipal.Current.UserID; if (adjustmentIDList.Count == 0) { return Json(new ReturnMessage { IsSuccess = false, Message = "请选择至少一条记录进行审核。" }); } try { this.EducationSchedulingAdjustmentServices.Approve(adjustmentIDList, curUserID, actionID, comment); return Json(new ReturnMessage { IsSuccess = true, Message = "审核成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "审核失败:" + ex.Message }); } } [HttpPost] public ActionResult AdjustmentApproveExcel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var selectedID = Request.Form["hidEducationSchedulingAdjustmentID"] ?? ""; var schoolyearID = Request.Form["ddlSchoolyear"].ParseStrTo(); var coursematerialID = Request.Form["cgbCoursematerial"].ParseStrTo(); var collegeID = Request.Form["ddlCollege"].ParseStrTo(); var teacherID = Request.Form["cgbTeacher"].ParseStrTo(); var classroomID = Request.Form["cbgClassroom"].ParseStrTo(); var applyUserID = Request.Form["cgbApplyUser"].ParseStrTo(); var startTime = Request.Form["txtStartTime"].ParseStrTo(); var endTime = Request.Form["txtEndTime"].ParseStrTo(); var recordStatus = Request.Form["ddlRecordStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlRecordStatus"].ParseStrTo(); List result; if (!string.IsNullOrEmpty(selectedID)) { var adjustmentIDList = selectedID.Split(',') .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); result = EducationSchedulingAdjustmentServices.GetScheduleAdjustmentViewApproveList(adjustmentIDList); } else { result = EducationSchedulingAdjustmentServices.GetScheduleAdjustmentViewApproveList(configuretView, schoolyearID, coursematerialID, collegeID, teacherID, classroomID, applyUserID, startTime, endTime, recordStatus); } var dt = result.Select(x => new { x.SchoolyearCode, x.CourseCode, x.CourseName, x.EducationMissionClassName, x.TeacherNames, x.TimeDetail, x.ClassroomName, x.ToTeacherNames, x.ToTimeDetail, x.ToClassroomName, x.ApplyUserName, ApplyTime = x.ApplyTime.HasValue ? x.ApplyTime.Value.ToString("yyyy-MM-dd") : "", x.RecordStatusName }).ToTable(); string[] liststring = { "学年学期", "课程代码", "课程名称", "任务班名称", "原任课老师", "原上课时间","原教室", "任课老师","上课时间","教室", "申请人", "申请时间", "状态"}; neh.Export(dt, liststring, "课程调整信息"); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } public ActionResult StopList() { ViewBag.StartStatusID = this.EducationSchedulingStopServices.GetStartStatus(); ViewBag.BackpointIDs = this.EducationSchedulingStopServices.GetBackpointStatus().ToJson(); return View(); } public ActionResult StopScheduling() { return View(); } [HttpPost] public ActionResult StopScheduling(string educationSchedulingStopIDs, Guid? UserID) { try { var stopIDList = educationSchedulingStopIDs.Split(',') .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); this.EducationSchedulingStopServices.StopSave(stopIDList, UserID); return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } public ActionResult StopEdit(Guid? EducationSchedulingStopID, Guid? EducationSchedulingID, Guid? UserID) { if (EducationSchedulingID.HasValue) { var scheduleAdjustmentView = this.ScheduleServices.GetEducationSchedulingStopView(EducationSchedulingID.Value); var user = this.UserServices.GetUserByID(UserID.Value); scheduleAdjustmentView.UserID = user.UserID; return View(scheduleAdjustmentView); } else { var scheduleAdjustmentView = this.EducationSchedulingStopServices.GetEducationSchedulingStopView(EducationSchedulingStopID.Value); return View(scheduleAdjustmentView); } } [HttpPost] public ActionResult StopList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("ddlSchoolyear"); var coursematerialID = pararms.getExtraGuid("cgbCoursematerial"); var collegeID = pararms.getExtraGuid("ddlCollege"); var teacherID = pararms.getExtraGuid("cgbTeacher"); var weekNum = pararms.getExtraInt("ddlWeekNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlWeekNum"); var weekDay = pararms.getExtraInt("WeekDay") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("WeekDay"); var coursesTimeID = pararms.getExtraGuid("Times"); var classroomID = pararms.getExtraGuid("ClassroomID"); var applyUserID = pararms.getExtraGuid("applyUserID"); var starDate = pararms.getExtraDateTime("txtStartDate"); var endDate = pararms.getExtraDateTime("txtEndDate"); var recordStatus = pararms.getExtraInt("ddlRecordStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlRecordStatus"); var result = EducationSchedulingStopServices.GetEducationSchedulingStopViewList(configuretView, schoolyearID, coursematerialID, collegeID, teacherID, weekNum, weekDay, coursesTimeID, classroomID, applyUserID, starDate, endDate, recordStatus, (int)pararms.page, (int)pararms.rows); return Json(result); } [HttpPost] public ActionResult StopExcel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var selectedID = Request.Form["hidEducationSchedulingStopID"] ?? ""; var schoolyearID = Request.Form["ddlSchoolyear"].ParseStrTo(); var coursematerialID = Request.Form["cgbCoursematerial"].ParseStrTo(); var collegeID = Request.Form["ddlCollege"].ParseStrTo(); var teacherID = Request.Form["cgbTeacher"].ParseStrTo(); var weekNum = Request.Form["ddlWeekNum"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlWeekNum"].ParseStrTo(); var weekDay = Request.Form["WeekDay"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["WeekDay"].ParseStrTo(); var coursesTimeID = Request.Form["Times"].ParseStrTo(); var classroomID = Request.Form["ClassroomID"].ParseStrTo(); var applyUserID = Request.Form["applyUserID"].ParseStrTo(); var starDate = Request.Form["txtStartDate"].ParseStrTo(); var endDate = Request.Form["txtEndDate"].ParseStrTo(); var recordStatus = Request.Form["ddlRecordStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlRecordStatus"].ParseStrTo(); List result; if (!string.IsNullOrEmpty(selectedID)) { var stopIDList = selectedID.Split(',') .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); result = EducationSchedulingStopServices.GetEducationSchedulingStopViewList(stopIDList); } else { result = EducationSchedulingStopServices.GetEducationSchedulingStopViewList(configuretView, schoolyearID, coursematerialID, collegeID, teacherID, weekNum, weekDay, coursesTimeID, classroomID, applyUserID, starDate, endDate, recordStatus); } var dt = result.Select(x => new { x.SchoolyearCode, x.CourseCode, x.CourseName, x.EducationMissionClassName, x.TimeDetail, x.ClassroomName, x.TeacherNames, x.RecordStatusName }).ToTable(); string[] liststring = { "学年学期", "课程代码", "课程名称", "任务班名称", "上课时间","教室", "停课老师", "状态"}; neh.Export(dt, liststring, "停课信息"); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } [HttpPost] public ActionResult StopDelete(string educationSchedulingStopIDs) { try { var stopIDList = educationSchedulingStopIDs.Split(',') .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); this.EducationSchedulingStopServices.Delete(stopIDList); return Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + ex.Message }); } } [HttpPost] public ActionResult StopSubmit(string educationSchedulingStopIDs) { try { var stopIDList = educationSchedulingStopIDs.Split(',') .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); this.EducationSchedulingStopServices.Submit(stopIDList, CustomPrincipal.Current.UserID); return Json(new ReturnMessage { IsSuccess = true, Message = "提交成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "提交失败:" + ex.Message }); } } [HttpPost] public ActionResult StopEdit(EducationSchedulingStopView scheduleStop) { try { this.EducationSchedulingStopServices.Save(scheduleStop); return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } public ActionResult StopApprove() { ViewBag.DefaultApproveStatusID = EducationSchedulingStopServices.GetApproveStatusViewList().Select(x => x.ID).FirstOrDefault(); return View(); } [HttpPost] public ActionResult StopApproveList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("ddlSchoolyear"); var coursematerialID = pararms.getExtraGuid("cgbCoursematerial"); var collegeID = pararms.getExtraGuid("ddlCollege"); var teacherID = pararms.getExtraGuid("cgbTeacher"); var weekNum = pararms.getExtraInt("ddlWeekNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlWeekNum"); var weekDay = pararms.getExtraInt("WeekDay") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("WeekDay"); var coursesTimeID = pararms.getExtraGuid("Times"); var classroomID = pararms.getExtraGuid("ClassroomID"); var applyUserID = pararms.getExtraGuid("applyUserID"); var starDate = pararms.getExtraDateTime("txtStartDate"); var endDate = pararms.getExtraDateTime("txtEndDate"); var recordStatus = pararms.getExtraInt("ddlRecordStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlRecordStatus"); var result = EducationSchedulingStopServices.GetEducationSchedulingStopApproveList(configuretView, schoolyearID, coursematerialID, collegeID, teacherID,weekNum,weekDay,coursesTimeID,classroomID,applyUserID,starDate,endDate, recordStatus, (int)pararms.page, (int)pararms.rows); return Json(result); } [HttpPost] public ActionResult StopApprove(string educationSchedulingStopIDs, Guid actionID, string comment) { var schedulingStopIDList = educationSchedulingStopIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); var curUserID = CustomPrincipal.Current.UserID; if (schedulingStopIDList.Count == 0) { return Json(new ReturnMessage { IsSuccess = false, Message = "请选择至少一条记录进行审核。" }); } try { this.EducationSchedulingStopServices.Approve(schedulingStopIDList, curUserID, actionID, comment); return Json(new ReturnMessage { IsSuccess = true, Message = "审核成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "审核失败:" + ex.Message }); } } [HttpPost] public ActionResult StopApproveExcel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var selectedID = Request.Form["hidEducationSchedulingStopID"] ?? ""; var schoolyearID = Request.Form["ddlSchoolyear"].ParseStrTo(); var coursematerialID = Request.Form["cgbCoursematerial"].ParseStrTo(); var collegeID = Request.Form["ddlCollege"].ParseStrTo(); var teacherID = Request.Form["cgbTeacher"].ParseStrTo(); var weekNum = Request.Form["ddlWeekNum"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlWeekNum"].ParseStrTo(); var weekDay = Request.Form["WeekDay"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["WeekDay"].ParseStrTo(); var coursesTimeID = Request.Form["Times"].ParseStrTo(); var classroomID = Request.Form["ClassroomID"].ParseStrTo(); var applyUserID = Request.Form["applyUserID"].ParseStrTo(); var starDate = Request.Form["txtStartDate"].ParseStrTo(); var endDate = Request.Form["txtEndDate"].ParseStrTo(); var recordStatus = Request.Form["ddlRecordStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlRecordStatus"].ParseStrTo(); List result; if (!string.IsNullOrEmpty(selectedID)) { var stopIDList = selectedID.Split(',') .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); result = EducationSchedulingStopServices.GetEducationSchedulingStopApproveList(stopIDList); } else { result = EducationSchedulingStopServices.GetEducationSchedulingStopApproveList(configuretView, schoolyearID, coursematerialID, collegeID, teacherID,weekNum,weekDay,coursesTimeID,classroomID,applyUserID,starDate,endDate, recordStatus); } var dt = result.Select(x => new { x.SchoolyearCode, x.CourseCode, x.CourseName, x.EducationMissionClassName, x.TimeDetail, x.ClassroomName, x.TeacherNames, x.RecordStatusName }).ToTable(); string[] liststring = { "学年学期", "课程代码", "课程名称", "任务班名称", "上课时间", "教室", "停课老师", "状态" }; neh.Export(dt, liststring, "停课信息"); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } [HttpPost] public ActionResult GetNotUseCoursesTimeDropDown(DropdownListBindType? bindType, Guid schoolyearID, int weekday, int toWeekday, Guid courseTimeID, int weekNum, int toWeekNum, Guid? fromTeacherID, Guid? replaceTeacherID, Guid educationMissionClassID) { var notUseCourseTimeViewList = this.ScheduleServices.GetNotUseCoursesTimeViewList(schoolyearID, weekday, toWeekday, courseTimeID, weekNum, toWeekNum, fromTeacherID, replaceTeacherID, educationMissionClassID); List list = notUseCourseTimeViewList .Select(x => new DropdownListItem { Text = x.StartDate + "-" + x.EndDate, Value = x.CoursesTimeID.ToString() }).ToList(); DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value; DropdownList.FormatDropdownItemList(dbt, list); return base.Json(list); } [HttpPost] public ActionResult GetNotUseClassroomList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); Guid schoolyearID = pararms.getExtraGuid("SchoolyearID") ?? Guid.Empty; int weekday = (pararms.getExtraInt("Weekday") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("Weekday")) ?? -1; int toWeekday = (pararms.getExtraInt("ToWeekday") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ToWeekday")) ?? -1; Guid coursesTimeID = pararms.getExtraGuid("CoursesTimeID") ?? Guid.Empty; Guid toCoursesTimeID = pararms.getExtraGuid("ToCoursesTimeID") ?? Guid.Empty; int weekNum = (pararms.getExtraInt("WeekNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("WeekNum")) ?? -1; int toWeekNum = (pararms.getExtraInt("ToWeekNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ToWeekNum")) ?? -1; int classroomTypeID = (pararms.getExtraInt("ClassroomTypeID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ClassroomTypeID")) ?? -1; Guid educationMissionClassID = pararms.getExtraGuid("EducationMissionClassID") ?? Guid.Empty; var notUseClassroomViewList = this.ScheduleServices.GetNotUseClassroomViewList(configuretView, schoolyearID, weekday, toWeekday, coursesTimeID, toCoursesTimeID, new List { weekNum }, new List { toWeekNum }, classroomTypeID, educationMissionClassID, pararms.page, pararms.rows); return base.Json(notUseClassroomViewList); } [HttpPost] public ActionResult GetEducationSchedulingClass(Guid schoolyearID, Guid classmajorID) { var schedulingClassList = EducationSchedulingClassServices.GetEducationSchedulingClassViewList(schoolyearID, classmajorID); var draggableList = new GridResultSet { rows = schedulingClassList, total = schedulingClassList.Count }; return Json(draggableList); } [HttpPost] public ActionResult GetDepartmentEducationSchedulingClass(Guid schoolyearID, Guid departmentID, string handleModes) { var handleModeList = handleModes.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (int?)Convert.ToInt32(x)).ToList(); var schedulingClassList = EducationSchedulingClassServices.GetDepartmentEducationSchedulingClassViewList(schoolyearID, departmentID, handleModeList); var draggableList = new GridResultSet { rows = schedulingClassList, total = schedulingClassList.Count }; return Json(draggableList); } [HttpPost] public ActionResult GetClassmajorSchedule(Guid schoolyearID, Guid classmajorID) { var classmajorSchedule = ScheduleServices.GetClassmajorSchedule(schoolyearID, classmajorID); return Json(classmajorSchedule); } [HttpPost] public ActionResult GetEducationMissionClassViewBySchedule(Guid? schoolyearID, DateTime date, Guid coursesTimeID, Guid teacherUserID) { var educationMissionClassView = ScheduleServices.GetEducationMissionClassViewBySchedule(schoolyearID, date, coursesTimeID, teacherUserID); return Json(educationMissionClassView); } [HttpPost] public ActionResult GetDepartmentSchedule(Guid schoolyearID, Guid departmentID, string handleModes) { var handleModeList = handleModes.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (int?)Convert.ToInt32(x)).ToList(); var departmentSchedule = ScheduleServices.GetDepartmentSchedule(schoolyearID, departmentID, handleModeList); return Json(departmentSchedule); } [HttpPost] public ActionResult GetAvailableClassroom(Guid schoolYearID, Guid collegeID, string schedulingWeekListStr, int weekday, Guid courseTimeID, int? classroomTypeID, int? studentNum) { var schedulingWeekList = schedulingWeekListStr.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (int?)Convert.ToInt32(x)).ToList(); var classroomList = ScheduleServices.GetAvailableClassroomList(collegeID, schoolYearID, schedulingWeekList, weekday, courseTimeID, studentNum, classroomTypeID); return Json(classroomList); } [HttpPost] public ActionResult IsEducationSchedulingClassCanAddManualSchedule(Guid educationScheduleClassID, string schedulingWeekListStr, Guid schoolYearID, int weekday, Guid courseTimeID) { try { var schedulingWeekList = schedulingWeekListStr.JsonToObject>().ToList(); this.ScheduleServices.CheckEducationSchedulingClassCanAddManualSchedule(educationScheduleClassID, schedulingWeekList, schoolYearID, weekday, courseTimeID); return Json(new ReturnMessage { IsSuccess = true }); } catch (Exception ex) { if (ex.Data.Count > 0) { var data = new List>(); foreach (DictionaryEntry item in ex.Data) { data.Add(new KeyValuePair((Guid)item.Key, item.Value.ToString())); } return Json(new ReturnMessage>> { IsSuccess = false, Message = ex.Message, Data = data }); } return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message }); } } [HttpPost] public ActionResult IsClassroomIsAvailable(Guid collegeID, Guid schoolYearID, string schedulingWeekListStr, int weekday, Guid courseTimeID, Guid classroomID) { var schedulingWeekList = schedulingWeekListStr.Split(',').Where(x => x != null).Select(x => (int?)Convert.ToInt32(x)).ToList(); try { ScheduleServices.CheckClassroomIsAvailable(collegeID, schoolYearID, schedulingWeekList, weekday, courseTimeID, classroomID); return Json(new ReturnMessage { IsSuccess = true }); } catch (ClassroomConflictException ex) { return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message, Data = classroomID }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message }); } } [HttpPost] public ActionResult IsCourseOnWork(Guid coursematerialID, int weekday, Guid courseTimeID) { try { this.ScheduleServices.CheckCourseIsOnWork(coursematerialID, weekday, courseTimeID); return Json(new ReturnMessage { IsSuccess = true }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message }); } } [HttpPost] public ActionResult IsTeacherOnWork(Guid educationScheduleClassID, string schedulingWeekListStr, int weekday, Guid courseTimeID) { try { var schedulingWeekList = schedulingWeekListStr.JsonToObject>().ToList(); this.ScheduleServices.CheckTeacherIsOnWork(educationScheduleClassID, schedulingWeekList, weekday, courseTimeID); return Json(new ReturnMessage { IsSuccess = true }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message }); } } [HttpPost] public ActionResult GetTeacherContinuousWorkTime(Guid educationScheduleClassID, string schedulingWeekListStr, Guid schoolYearID, int weekday) { var schedulingWeekList = schedulingWeekListStr.JsonToObject>().ToList(); return Json(ScheduleServices.GetTeacherContinuousWorkTime(educationScheduleClassID, schedulingWeekList, schoolYearID, weekday)); } [HttpPost] public ActionResult GetContinuousLimitView() { return Json(new ContinuousLimitView { TeacherScheduleContinuousCount = ParameterServices.GetParameterValue(CF_ParameterType.TeacherScheduleContinuousCount) ?? 0, ClassScheduleContinuousCount = ParameterServices.GetParameterValue(CF_ParameterType.ClassScheduleContinuousCount) ?? 0, ClassCourseScheduleContinuousCount = ParameterServices.GetParameterValue(CF_ParameterType.ClassCourseScheduleContinuousCount) ?? 0 }); } [HttpPost] public ActionResult AddScheduling(Guid schoolYearID, Guid educationSchedulingClassID, string weekListStr, string teacherStr, int weekday, Guid courseTimeID, Guid classroomID) { try { var schedulingWeekList = weekListStr.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (int?)Convert.ToInt32(x)).ToList(); var teacherList = teacherStr.JsonToObject>(); EducationSchedulingView educationSchedulingView = new EducationSchedulingView() { SchoolyearID = schoolYearID, EducationSchedulingClassID = educationSchedulingClassID, Weekday = weekday, CoursesTimeID = courseTimeID, ClassroomID = classroomID }; ScheduleServices.AddScheduling(educationSchedulingView, schedulingWeekList, teacherList); return Json(new ReturnMessage { IsSuccess = true }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message }); } } //[HttpPost] //public ActionResult DelScheduling(Guid schoolYearID, Guid educationSchedulingClassID, int weekday, Guid courseTimeID) //{ // try // { // ScheduleServices.DelScheduling(schoolYearID, educationSchedulingClassID, weekday, courseTimeID); // return Json(new ReturnMessage { IsSuccess = true }); // } // catch (Exception ex) // { // return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message }); // } //} [HttpPost] public ActionResult DelScheduling(Guid educationSchedulingID) { try { ScheduleServices.DelScheduling(educationSchedulingID); return Json(new ReturnMessage { IsSuccess = true }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message }); } } [HttpPost] public ActionResult DeleteWeeks(Guid educationSchedulingID, string weekListStr) { try { var deleteWeekList = weekListStr.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (int?)Convert.ToInt32(x)).ToList(); ScheduleServices.DelWeeks(educationSchedulingID, deleteWeekList); return Json(new ReturnMessage { IsSuccess = true }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message }); } } [HttpPost] public ActionResult GetClassroomScheduleViewList(Guid schoolYearID, Guid classroomID) { try { var classroomScheduleViewList = this.ScheduleServices.GetClassroomScheduleViewList(schoolYearID, classroomID); return Json(new GridResultSet { rows = classroomScheduleViewList, total = classroomScheduleViewList.Count }); } catch (Exception ex) { throw ex; } } [HttpPost] public ActionResult ChangeClassroom(Guid educationSchedulingID, Guid classroomID) { try { ScheduleServices.ChangeClassroom(educationSchedulingID, classroomID); return Json(new ReturnMessage { IsSuccess = true }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message }); } } [HttpPost] public ActionResult SetTeacher(Guid educationSchedulingID) { try { var teacherViewList = DataGrid.GetTableData("dgTeacherList"); ScheduleServices.ChangeTeacher(educationSchedulingID, teacherViewList); return Json(new ReturnMessage { IsSuccess = true, Message = "设置教师成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message }); } } [HttpPost] public ActionResult AutoSchedule(string educationMissionClassIDs) { try { var educationMissionClassIDList = educationMissionClassIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); ScheduleServices.GenerateSchedule(educationMissionClassIDList); return Json(new ReturnMessage { IsSuccess = true, Message = "智能排课成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message }); } } public ActionResult ClearAutoSchedule() { ClearAutoScheduleView viewmodel = new ClearAutoScheduleView(); viewmodel.SchoolyearID = BaseExtensions.GetCurrentSchoolYearID(); return View(); } [HttpPost] public ActionResult ClearAutoSchedule(ClearAutoScheduleView viewmodel) { try { if (viewmodel.Year == DropdownList.SELECT_ALL) { viewmodel.Year = null; } if (viewmodel.StandardID == DropdownList.SELECT_ALL) { viewmodel.StandardID = null; } ScheduleServices.ClearAutoSchedule(viewmodel.SchoolyearID, viewmodel.CollegeID, viewmodel.StandardID, viewmodel.Year, viewmodel.ClassmarjorID); return Json(new ReturnMessage { IsSuccess = true, Message = "清除智能排课结果完成。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "清除智能排课结果失败," + ex.Message }); } } } }