using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Bowin.Web.Controls.Mvc; using Bowin.Common.Utility; using Bowin.Common.Data; using Bowin.Common.JSON; using EMIS.Utility; using EMIS.ViewModel; using EMIS.Web.Controls; using EMIS.CommonLogic.CalendarManage; using EMIS.ViewModel.GraduationManage.GraduationRequirement; using EMIS.CommonLogic.GraduationManage.GraduationRequirement; namespace EMIS.Web.Controllers.GraduationManage.GraduationRequirement { [Authorization] public class GraduationCourseController : Controller { public IGraduationCourseServices GraduationCourseServices { get; set; } /// /// 毕业课程(毕业课程组)页面 /// /// public ActionResult List() { return View(); } /// /// 毕业课程列表查询 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var gradSchoolyearID = pararms.getExtraGuid("GradSchoolyearDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown"); var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown"); 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 learnSystem = pararms.getExtraString("DictionaryLearnSystem"); //课程类型 var courseTypeID = pararms.getExtraInt("DictionaryCourseType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryCourseType"); return base.Json(GraduationCourseServices.GetGraduationCourseViewGird(configuretView, gradSchoolyearID, collegeID, yearID, standardID, educationID, learningformID, learnSystem, courseTypeID, (int)pararms.page, (int)pararms.rows)); } /// /// 计划生成(专业计划) /// /// public ActionResult PlanCreate() { GraduationCourseView graduationCourseView = new GraduationCourseView(); return View(graduationCourseView); } /// /// 计划生成(专业计划) /// /// /// [HttpPost] public ActionResult PlanCreate(GraduationCourseView graduationCourseView) { try { var gradSpecialtyPlanViewList = Request["SpecialtyPlan"].JsonToObject>(); string result = GraduationCourseServices.GraduationCourseBatchAdd(graduationCourseView, gradSpecialtyPlanViewList); return Json(new ReturnMessage() { IsSuccess = true, Message = "生成成功" + result + "。" }); } catch (Exception ex) { string mge = ex.Message; return Json(new ReturnMessage() { IsSuccess = false, Message = "生成失败,原因:" + ex.Message + "。" }); } } /// /// 查询对应的专业计划信息(需与毕业课程信息进行对比) /// /// /// [HttpPost] public ActionResult GraduationSpecialtyPlanList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var gradSchoolyearID = pararms.getExtraGuid("GradSchoolyearDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown"); var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown"); 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 learnSystem = pararms.getExtraString("DictionaryLearnSystem"); var coursematerialID = pararms.getExtraGuid("CoursematerialComboGrid"); //课程类型 var courseTypeID = pararms.getExtraInt("DictionaryCourseType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryCourseType"); return base.Json(GraduationCourseServices.GetGradSpecialtyPlanViewGrid(configuretView, gradSchoolyearID, collegeID, yearID, standardID, educationID, learningformID, learnSystem, coursematerialID, courseTypeID, (int)pararms.page, (int)pararms.rows)); } /// /// 复制新增 /// /// /// public ActionResult CopyAdd(Guid graduationCourseID) { GraduationCourseView graduationCourseView = new GraduationCourseView(); graduationCourseView = GraduationCourseServices.GetGraduationCourseView(graduationCourseID); return View("Edit", graduationCourseView); } /// /// 复制新增 /// /// /// [HttpPost] public ActionResult CopyAdd(GraduationCourseView graduationCourseView) { graduationCourseView.GraduationCourseID = Guid.Empty; return this.Edit(graduationCourseView); } /// /// 编辑(新增、修改,业务主键:年级专业、课程信息、课程类型、课程学分) /// /// /// [HttpGet] public ActionResult Edit(Guid? graduationCourseID) { GraduationCourseView graduationCourseView = new GraduationCourseView(); if (graduationCourseID.HasValue && graduationCourseID != Guid.Empty) { graduationCourseView = GraduationCourseServices.GetGraduationCourseView(graduationCourseID); } return View(graduationCourseView); } /// /// 编辑(新增、修改,业务主键:年级专业、课程信息、课程类型、课程学分) /// /// /// [HttpPost] public ActionResult Edit(GraduationCourseView graduationCourseView) { try { GraduationCourseServices.GraduationCourseEdit(graduationCourseView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message }); } } /// /// 删除 /// /// /// [HttpPost] public ActionResult Delete(string graduationCourseIDs) { try { List list = graduationCourseIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)) .Select(x => (Guid?)new Guid(x)).ToList(); GraduationCourseServices.GraduationCourseDelete(list); return base.Json("删除成功。"); } catch (Exception ex) { return base.Json("删除失败,原因:" + ex.Message); } } /// /// Excel导出 /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var gradSchoolyearID = Request.Form["GradSchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["GradSchoolyearDropdown"].ParseStrTo(); var collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo(); var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo(); var educationID = Request.Form["DictionaryEducation"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo(); var learningformID = Request.Form["DictionaryLearningform"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo(); var learnSystem = Request.Form["DictionaryLearnSystem"].ToString(); //课程类型 var courseTypeID = Request.Form["DictionaryCourseType"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryCourseType"].ParseStrTo(); var dt = GraduationCourseServices.GetGraduationCourseViewList(configuretView, gradSchoolyearID, collegeID, yearID, standardID, educationID, learningformID, learnSystem, courseTypeID) .Select(x => new { x.GraduatingSemesterCode, x.GrademajorCode, x.GrademajorName, x.FacultymajorNo, x.FacultymajorName, x.CollegeNo, x.CollegeName, x.SchoolyearID, x.SchoolcodeName, x.EnteringSchoolYearCode, x.StandardID, x.StandardCode, x.StandardName, x.EducationName, x.LearningformName, x.LearnSystem, x.CourseCode, x.CourseName, x.CourseTypeName, x.CourseCredit }).ToTable(); string[] liststring = { "毕业学期", "年级专业编号", "年级专业名称", "院系专业编号", "院系专业名称", RSL.Get("CollegeCode"), RSL.Get("CollegeName"), "年级", "学期", "入学学年学期", "专业ID(Value)", "专业代码", "专业名称", RSL.Get("EducationID"), "学习形式", "学制", "课程代码", "课程名称", "课程类型", "课程学分" }; neh.Export(dt, liststring, "毕业课程信息" + DateTime.Now.ToString("yyyyMMdd")); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } } }