using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using EMIS.ViewModel; using EMIS.Web.Controls; using Bowin.Web.Controls.Mvc; using EMIS.CommonLogic.CultureplanManage.PlanManagement; using EMIS.ViewModel.SelectCourse; using Bowin.Common.Linq.Entity; using Bowin.Common.JSON; using Bowin.Common.Utility; using Bowin.Common.Data; using EMIS.CommonLogic.SelectCourse; using Bowin.Common.Exceptions; using EMIS.CommonLogic.UniversityManage.SpecialtyClassManage; namespace EMIS.Web.Controllers.SelectCourseManage { [Authorization] public class OptionalCourseSettingController : Controller { public IConditionServices ConditionServices { get; set; } public IClassmajorServices ClassmajorServices { get; set; } public IOptionalCourseSettingServices optionalCourseSettingServices { get; set; } /// /// 限选设定页面 /// /// public ActionResult List() { var conditionView = ConditionServices.GetSelectCourseConditionView(); ViewBag.SelectSchoolYearID = conditionView.Schoolyear; return View(); } /// /// 列表查询 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var coursematerialID = pararms.getExtraGuid("CoursematerialIDDropdownGridBo"); var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown"); //var schoolYearNumID = pararms.getExtraInt("DictionarySchoolYearNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolYearNum"); var schoolYearID = pararms.getExtraGuid("SchoolyearDropdown"); //var schoolCodeID = pararms.getExtraInt("DictionarySchoolCode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolCode"); //var isEnable = pararms.getExtraInt("DictionaryIsEnable") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsEnable"); var Years = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown"); var Status = pararms.getExtraInt("DictionaryStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStatus"); var isOpen = pararms.getExtraInt("DictionaryIsOpen") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsOpen"); return this.Json(optionalCourseSettingServices.GetOptionalCourseSettingViewGrid(configuretView, collegeID, standardID, coursematerialID, schoolYearID, Years, Status, isOpen, (int)pararms.page, (int)pararms.rows)); } /// /// /// /// /// /// public ActionResult Class(QueryParamsModel pararms, Guid GrademajorID) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolYearID = pararms.getExtraGuid("SchoolyearDropdown"); var campusID = pararms.getExtraGuid("CampusDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown"); var grademajorID = pararms.getExtraGuid("GrademajorComboGrid"); var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation"); var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform"); var schoolyear = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown"); return base.Json(ClassmajorServices.GetClassmajorViewGrid(configuretView, campusID, collegeID, schoolyear, standardID, educationID, learningformID, null , GrademajorID, null, null, (int)pararms.page, (int)pararms.rows)); } /// /// 获取任务班授课老师 /// /// /// [HttpPost] public ActionResult TeacherList(Guid executableOptionalCourseID) { var teacherList = optionalCourseSettingServices.GetEducationMissionClassTeacherListViewList(executableOptionalCourseID); return Json(new GridResultSet() { rows = teacherList, total = teacherList.Count }); } public ActionResult ClassList(Guid executableOptionalCourseID, string Type) { ViewBag.ID = executableOptionalCourseID; ViewBag.Type = Type; return View(); } /// /// 获取可选课的班级 /// /// /// [HttpPost] public ActionResult ClassList(Guid executableOptionalCourseID) { var classList = optionalCourseSettingServices.GetClassmajorList(executableOptionalCourseID); return Json(new GridResultSet() { rows = classList, total = classList.Count }); } /// /// 限选任务生成弹出页面 /// /// public ActionResult Create() { var conditionView = ConditionServices.GetSelectCourseConditionView(); ViewBag.SelectSchoolYearID = conditionView.Schoolyear; return View(new OptionalCourseSettingCreateView()); } /// /// 限选任务生成 /// /// /// [HttpPost] public ActionResult Create(OptionalCourseSettingCreateView optionalCourseSettingView) { try { optionalCourseSettingServices.OptionalCourseSettingCreate(optionalCourseSettingView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (SuccessException ex) { return Json(new ReturnMessage() { IsSuccess = true, Message = ex.Message }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败," + ex.Message }); } } /// /// 编辑 /// /// public ActionResult Edit(Guid? ExecutableOptionalCourseIDs,string type) { OptionalCourseSettingView optionalCourseSettingView = new OptionalCourseSettingView(); if (ExecutableOptionalCourseIDs.HasValue && ExecutableOptionalCourseIDs != Guid.Empty) optionalCourseSettingView = optionalCourseSettingServices.GetOptionalCourseSettingView(ExecutableOptionalCourseIDs); if (type == "add" && optionalCourseSettingView!=null) { optionalCourseSettingView.ExecutableOptionalCourseID = null; } ViewBag.RecordStatus = optionalCourseSettingView.RecordStatus; return View(optionalCourseSettingView); } /// /// 保存修改 /// /// /// [HttpPost] public ActionResult Edit(OptionalCourseSettingView optionalCourseSettingView) { try { var teacherList = DataGrid.GetTableData("dgTeacherList"); var classList = DataGrid.GetTableData("dgClassList"); optionalCourseSettingServices.OptionalCourseSettingUpdate(optionalCourseSettingView, teacherList, classList); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } /// /// 删除 /// /// /// [HttpPost] public ActionResult Delete(string optionalCourseSettingIDs) { try { List list = new List(); for (int i = 0; i < optionalCourseSettingIDs.Split(',').Length; i++) { if (!string.IsNullOrEmpty(optionalCourseSettingIDs.Split(',')[i])) { Guid optionalCourseSettingID = new Guid(optionalCourseSettingIDs.Split(',')[i]); list.Add(optionalCourseSettingID); } } optionalCourseSettingServices.OptionalCourseSettingDelete(list); return this.Json("删除成功!"); } catch (Exception ex) { string mge = ex.Message; System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex); if (num != null) { if (num.Number == 547) mge = "请先删除所有关联的数据!"; } return this.Json("删除失败,原因:" + mge); } } /// /// 开放 /// /// /// [HttpPost] public ActionResult Submit(string optionalCourseSettingIDs) { try { List list = new List(); for (int i = 0; i < optionalCourseSettingIDs.Split(',').Length; i++) { if (!string.IsNullOrEmpty(optionalCourseSettingIDs.Split(',')[i])) { Guid optionalCourseSettingID = new Guid(optionalCourseSettingIDs.Split(',')[i]); list.Add(optionalCourseSettingID); } } optionalCourseSettingServices.OptionalCourseSettingSubmit(list); return this.Json("开放成功!"); } catch (Exception ex) { string mge = ex.Message; System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex); return this.Json("开放失败,原因:" + mge); } } /// /// 取消 /// /// /// [HttpPost] public ActionResult Cancel(string optionalCourseSettingIDs) { try { List list = new List(); for (int i = 0; i < optionalCourseSettingIDs.Split(',').Length; i++) { string id = optionalCourseSettingIDs.Split(',')[i]; if (!string.IsNullOrEmpty(id)) { Guid optionalCourseSettingID = new Guid(id); list.Add(optionalCourseSettingID); } } optionalCourseSettingServices.OptionalCourseSettingCancel(list); return base.Json("取消成功!"); } catch (Exception ex) { string mge = ex.Message; return base.Json("取消失败,原因:" + mge); } } /// /// /// /// [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 standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo(); var coursematerialID = Request.Form["CoursematerialIDDropdownGridBo"].ParseStrTo(); var collegeID = Request.Form["ComboGridCollege"].ParseStrTo(); //var schoolYearNumID = Request.Form["DictionarySchoolYearNum"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolYearNum"].ParseStrTo(); //var schoolCodeID = Request.Form["DictionarySchoolCode"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolCode"].ParseStrTo(); //var isEnable = Request.Form["DictionaryIsEnable"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsEnable"].ParseStrTo(); var schoolYearID = Request.Form["SchoolYear"].ParseStrTo(); //var schoolCodeID = pararms.getExtraInt("DictionarySchoolCode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolCode"); //var isEnable = pararms.getExtraInt("DictionaryIsEnable") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsEnable"); var Years = Request.Form["DictionaryGrade"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo(); var Status = Request.Form["DictionaryStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStatus"].ParseStrTo(); var isOpened = Request.Form["DictionaryIsOpen"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsOpen"].ParseStrTo(); var dt = optionalCourseSettingServices.GetOptionalCourseSettingViewList(configuretView, collegeID, standardID, coursematerialID, schoolYearID, Years, Status, isOpened) .Select(x => new { x.SchoolYearCode, //x.GrademajorCode, x.GrademajorName, x.DefaultClassName, //x.CourseCode, x.CourseName, //x.CourseTypeName, //x.CourseCategoryName, //x.CourseQualityName, x.SchoolcodeName, x.SchoolyearNumName, x.Credit, x.Totalhours, //x.DepartmentName, //x.CollegeName, //x.IsEnableDesc, x.IsOpenedDesc, x.RecordStatusName, }).ToTable(); string[] liststring = { "学年学期", //"年级专业代码", "年级专业名称", "班级名称", //"课程代码", "课程名称", //"课程类型", "课程属性", "课程性质", "学期", "开课学年", "学分","总学时", //"教研室", RSL.Get("College"), //"是否启用", "是否开放","状态"}; neh.Export(dt, liststring, "限选设定"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Content("~/OptionalCourseSetting/List").AddMenuParameter() }); } [HttpPost] public ActionResult TeachingModeType(Guid? ExecutableOptionalCourseID) { List list = new List(); if (ExecutableOptionalCourseID.HasValue && ExecutableOptionalCourseID != Guid.Empty) list = optionalCourseSettingServices.GetTeachingModeType(ExecutableOptionalCourseID); else list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory).ToString()); return base.Json(list); } [HttpPost] public ActionResult Save() { return View(); //try //{ // var optionalCourseSettingList = DataGrid.GetTableData("dgOptionalCourseSettingList"); // this.OptionalCoursePlanServices.SaveOptionalCourseSettings(optionalCourseSettingList); // return RedirectToAction("MsgShow", "Common", new // { // msg = "保存成功!", // url = Url.Content("~/OptionalCourseSetting/List").AddMenuParameter() // }); //} //catch (Exception ex) //{ // return RedirectToAction("MsgShow", "Common", new // { // msg = "保存失败!" + ex.Message, // url = Url.Content("~/OptionalCourseSetting/List").AddMenuParameter() // }); //} } /// /// 编辑页新增班级 /// /// /// [HttpPost] public ActionResult ChooseClassList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var GrademajorID = Request.Params["GrademajorID"].ParseStrTo(); //var campusID = pararms.getExtraGuid("CampusDropdown"); //var collegeID = pararms.getExtraGuid("CollegeDropdown"); //var grademajorID = pararms.getExtraGuid("GrademajorComboGrid"); //var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard"); //var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation"); //var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform"); //var schoolyear = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear"); return base.Json(ClassmajorServices.GetClassmajorViewGrid(configuretView, null, null, null, null, null, null, null, GrademajorID, null, null, (int)pararms.page, (int)pararms.rows)); } } }