using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using EMIS.ViewModel; using EMIS.CommonLogic.EducationManagement; using EMIS.Web.Controls; using Bowin.Web.Controls.Mvc; using EMIS.ViewModel.EducationManage; using Bowin.Common.Linq.Entity; using Bowin.Common.Utility; using EMIS.ViewModel.EducationManagement; using Bowin.Common.Data; using EMIS.CommonLogic.CalendarManage; using Bowin.Common.Exceptions; using Bowin.Common.JSON; using EMIS.ViewModel.UniversityManage.TeacherManage; using EMIS.CommonLogic.EducationManage; namespace EMIS.Web.Controllers.EducationManage { [Authorization] public class AdultEducationMissionClassController : Controller { public IAdultEducationMissionClassServices AdulteducationMissionClassServices { get; set; } public Lazy staffServices { get; set; } public EMIS.CommonLogic.EducationManagement.IEducationMissionClassServices EducationMissionClassServices { get;set; } public ISchoolYearServices schoolYearServices { get; set; } /// /// 教学任务页面(成教) /// /// public ActionResult List() { var schoolYear = schoolYearServices.GetSchoolYearIsCurrent(true); ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();//默认当前学年 return View(); } /// /// 查询教学任务班列表 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown"); var coursematerialID = pararms.getExtraGuid("CoursematerialComboGrid"); var campusID = pararms.getExtraGuid("CampusDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var CoursesTimeID = pararms.getExtraGuid("TimeComboGrid"); var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown"); var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown"); var education = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation"); var classmajorID = pararms.getExtraGuid("ClassmajorDropdown"); var gradeYearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown"); var approvalStatus = pararms.getExtraInt("ApprovalStatusDropdownList") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ApprovalStatusDropdownList"); var teachingMode = pararms.getExtraInt("DictionaryTeachingMode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryTeachingMode"); var LearnSystem = pararms.getExtraString("DictionaryLearnSystem"); var result = AdulteducationMissionClassServices.GetEducationMissionClassViewGrid(configuretView, campusID, collegeID, schoolyearID, standardID, coursematerialID, approvalStatus, teachingMode, classmajorID, gradeYearID, CoursesTimeID,learningformID,education,LearnSystem, (int)pararms.page, (int)pararms.rows); return Json(result); } /// /// 教学安排 /// /// /// public ActionResult Edit(Guid? educationMissionClassID) { EducationMissionImportClassView educationMissionClassView = new EducationMissionImportClassView(); if (educationMissionClassID != null && educationMissionClassID != Guid.Empty) { educationMissionClassView = AdulteducationMissionClassServices.GetEducationMissionClassView(educationMissionClassID); if (educationMissionClassView != null) { var schoolYear = schoolYearServices.GetSchoolYear(educationMissionClassView.SchoolyearID); List lct = new List(); if (schoolYear != null) { for (int i = 1; i <= schoolYear.WeeksNum; i++) { ListControlItem lt = new ListControlItem { Text = "第" + i + "周", Value = i, IsSelected = true }; lct.Add(lt); } } ViewData["lct"] = lct; } } return View(educationMissionClassView); } /// /// 修改 /// /// /// [HttpPost] public ActionResult Edit(EducationMissionClassView educationMissionClassView) { try { List list = new List(); var listWeekNum = Request.Form["WeekNum"]; if (listWeekNum != null) { for (int i = 0; i < listWeekNum.Split(',').Length; i++) { if (!string.IsNullOrEmpty(listWeekNum.Split(',')[i])) { int teachingModeID = Convert.ToInt32(listWeekNum.Split(',')[i]); list.Add(teachingModeID); } } } var teacherList = DataGrid.GetTableData("dgTeacherList"); EducationMissionClassServices.EducationMissionClassUpdate(educationMissionClassView, list, teacherList); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message }); } } /// /// 提交 /// /// /// [HttpPost] public ActionResult EducationMissionClassUpdate(string educationMissionClassIDs) { try { List list = new List(); var educationMissionClassArray = educationMissionClassIDs.Split(','); for (int i = 0; i < educationMissionClassArray.Length; i++) { if (!string.IsNullOrEmpty(educationMissionClassArray[i])) { Guid? educationMissionClassID = new Guid(educationMissionClassArray[i]); list.Add(educationMissionClassID); } } AdulteducationMissionClassServices.EducationMissionClassUpdate(list); return Json("成功"); } catch (Exception ex) { return Json("提交失败,原因:" + ex.Message); } } /// /// 撤销提交 /// /// /// [HttpPost] public ActionResult UnSubmit(string educationMissionClassIDs) { try { List list = new List(); var educationMissionClassArray = educationMissionClassIDs.Split(','); for (int i = 0; i < educationMissionClassArray.Length; i++) { if (!string.IsNullOrEmpty(educationMissionClassArray[i])) { Guid? educationMissionClassID = new Guid(educationMissionClassArray[i]); list.Add(educationMissionClassID); } } EducationMissionClassServices.UnSubmit(list); return Json("撤销成功。"); } catch (Exception ex) { return Json("撤销失败,原因:" + ex.Message); } } [HttpPost] public ActionResult Delete(string educationMissionClassIDs) { try { List list = new List(); var educationMissionClassArray = educationMissionClassIDs.Split(','); for (int i = 0; i < educationMissionClassArray.Length; i++) { if (!string.IsNullOrEmpty(educationMissionClassArray[i])) { Guid? educationMissionClassID = new Guid(educationMissionClassArray[i]); list.Add(educationMissionClassID); } } EducationMissionClassServices.Delete(list); return Json(new ReturnMessage { IsSuccess = true }); } catch (Exception ex) { string mge = ex.Message; System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex); if (num != null) { if (num.Number == 547) mge = "请先删除所有关联的数据,排课课表,学生成绩,教学评价等"; } return Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + mge }); } } /// /// 导出Excel /// /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDropdown"].ParseStrTo(); var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo(); var campusID = Request.Form["CampusDropdown"].ParseStrTo(); var collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo(); var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo(); var gradeYearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo(); var approvalStatus = Request.Form["ApprovalStatusDropdownList"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ApprovalStatusDropdownList"].ParseStrTo(); var teachingMode = Request.Form["DictionaryTeachingMode"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryTeachingMode"].ParseStrTo(); var learningformID = Request.Form["LearningformDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["LearningformDictionaryDropDown"].ParseStrTo(); var education = Request.Form["DictionaryEducation"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo(); var LearnSystem = Request.Form["DictionaryLearnSystem"].ToString(); var dt = AdulteducationMissionClassServices.GetEducationMissionClassViewList(configuretView, campusID, collegeID, schoolyearID, standardID, coursematerialID, approvalStatus, teachingMode, classmajorID, gradeYearID, learningformID, education, LearnSystem) .Select(x => new { x.OrderNo, x.Name, // x.SchoolyearCode, x.CourseCode, x.CourseName, x.DepartmentName, // x.CollegeName, x.ClassroomTypeName, x.StartStopWeeklyNum, x.Totalhours, x.CourseProcessTimes, // x.SchedulingClassNum, x.ClassNum, x.TeacherName, x.ApprovalStatusName }).ToTable(); string[] liststring = { "排课序号", "任务班名称","课程代码", "课程名称", "教研室", "教室类型", "执行周次", "总学时", "执行学时", "班级人数","授课老师", "状态" }; neh.Export(dt, liststring, "教学任务班基础信息"); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功!" }); } /// /// 批量修改课时类别 /// public ActionResult BatchUpdate(string educationMissionClassStr) { EducationMissionClassView educationMissionClassView = new EducationMissionClassView(); if (!educationMissionClassStr.IsEmpty()) { educationMissionClassView.EducationMissionClassStr = educationMissionClassStr; } return View(educationMissionClassView); } /// /// 批量修改课时类别 /// [HttpPost] public ActionResult BatchUpdate(EducationMissionClassView educationMissionClassView) { try { List educationMissionClassid = educationMissionClassView.EducationMissionClassStr.SplitIDString(); AdulteducationMissionClassServices.BatchModifyCoursesTime(educationMissionClassid, educationMissionClassView.CourseTimeID, educationMissionClassView.ClassroomTypeID); return Json(new ReturnMessage() { IsSuccess = true, Message = "修改成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "修改失败,原因:" + ex.Message }); } } } }