using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using EMIS.CommonLogic.MinorManage.MinorPlanManage; using EMIS.ViewModel; using EMIS.Web.Controls; using Bowin.Web.Controls.Mvc; using EMIS.ViewModel.MinorManage.MinorPlanManage; using Bowin.Common.Exceptions; using Bowin.Common.Utility; using EMIS.Utility; using Bowin.Common.Data; using Bowin.Common.JSON; namespace EMIS.Web.Controllers.MinorManage.MinorPlanManage { [Authorization] public class MinorSpecialtyPlanController : Controller { public IMinorSpecialtyPlanServices minorSpecialtyPlanServices { get; set; } // // GET: /MinorSpecialtyPlan/ public ActionResult List() { return View(); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolYearID = pararms.getExtraGuid("SchoolyearDropdown"); 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 coursematerialID = pararms.getExtraGuid("CoursematerialIDDropdownGridBo"); var Schoolyear = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear"); var schoolcodeID = pararms.getExtraInt("DictionarySchoolcode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolcode"); var isEnable = pararms.getExtraInt("DictionaryIsEnable") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsEnable"); return this.Json(minorSpecialtyPlanServices.GetMinorSpecialtyViewGrid(configuretView, schoolYearID, collegeID, yearID, standardID, coursematerialID, Schoolyear, schoolcodeID, (int)pararms.page, (int)pararms.rows)); } public ActionResult Add() { return View(); } /// /// 批量添加 /// /// /// [HttpPost] public ActionResult Add(MinorSpecialtyPlanView minorSpecialtyPlanView) { try { var minorSpecialCourseViewList = Request["MinorSpecialtyCourse"].JsonToObject>(); if (minorSpecialCourseViewList.Count > 0) { minorSpecialtyPlanServices.MinorPlanAdd(minorSpecialtyPlanView, minorSpecialCourseViewList); } else { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,请选择要添加的专业课程。" }); } return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } [HttpPost] public ActionResult MinorSpecialtyPlanStandardIDList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var yearID = pararms.getExtraInt("YearID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YearID"); var list = minorSpecialtyPlanServices.GetStandardIDList(configuretView, yearID).Select(x => new { x.StandardID, x.SpecialtyCode, x.StandardName, x.StandardNameStr }).ToList(); return Json(new { total = list.Count, rows = list }); } /// /// 获取未申请过的辅修课程 /// /// /// [HttpPost] public ActionResult StandardAndMinorSpecialtyCourseViewList(QueryParamsModel pararms) { var yearID = pararms.getExtraInt("YearID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YearID"); var standardID = pararms.getExtraInt("StandardID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardID"); return this.Json(minorSpecialtyPlanServices.StandardAndMinorSpecialtyCourseViewGrid(yearID, standardID, (int)pararms.page, (int)pararms.rows)); } /// /// 编辑 /// /// /// public ActionResult Edit(Guid? MinorPlanID) { MinorSpecialtyPlanView minorSpecialtyPlanView = new MinorSpecialtyPlanView(); if (MinorPlanID.HasValue) { minorSpecialtyPlanView = minorSpecialtyPlanServices.GetMinorSpecialtyView(MinorPlanID); } else { minorSpecialtyPlanView.ResultTypeID = (int)CF_ResultType.Percentage; minorSpecialtyPlanView.Credit = 0; minorSpecialtyPlanView.TheoryCourse = 0; minorSpecialtyPlanView.Practicehours = 0; minorSpecialtyPlanView.Trialhours = 0; minorSpecialtyPlanView.Totalhours = 0; minorSpecialtyPlanView.TheoryWeeklyNum = 0; minorSpecialtyPlanView.PracticeWeeklyNum = 0; minorSpecialtyPlanView.TrialWeeklyNum = 0; minorSpecialtyPlanView.SchoolweeksNum = 0; minorSpecialtyPlanView.WeeklyHours = 0; minorSpecialtyPlanView.WeeklyNum = 0; minorSpecialtyPlanView.IsEnable = true; } return View(minorSpecialtyPlanView); } /// /// 编辑 /// /// /// [HttpPost] public ActionResult Edit(MinorSpecialtyPlanView minorSpecialtyPlanView) { try { minorSpecialtyPlanServices.MinorSpecialtyCourseEdit(minorSpecialtyPlanView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } /// /// 获取已经存在在授课方式 /// /// /// [HttpPost] public ActionResult TeachingModeType(Guid? MinorPlanID) { List list = new List(); if (MinorPlanID.HasValue && MinorPlanID != Guid.Empty) list = minorSpecialtyPlanServices.GetTeachingModeType(MinorPlanID); else list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory).ToString()); return base.Json(list); } /// /// 获取已经存在在授课地点 /// /// /// [HttpPost] public ActionResult TeachingPlace(Guid? MinorPlanID) { List list = new List(); if (MinorPlanID.HasValue && MinorPlanID != Guid.Empty) list = minorSpecialtyPlanServices.GetTeachingPlace(MinorPlanID); return base.Json(list); } /// /// 删除 /// /// /// [HttpPost] public ActionResult Delete(string MinorPlanIDs) { try { List list = new List(); for (int i = 0; i < MinorPlanIDs.Split(',').Length; i++) { string id = MinorPlanIDs.Split(',')[i]; if (!string.IsNullOrEmpty(id)) { Guid MinorPlanID = new Guid(id); list.Add(MinorPlanID); } } minorSpecialtyPlanServices.MinorPlanDelete(list); return base.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 base.Json("删除失败,原因:" + mge); } } /// /// 导出Excel /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); var MinorPlanID = Request.Form["MinorPlanID"]; ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var schoolYearID = Request.Form["SchoolyearDropdown"].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 coursematerialID = Request.Form["CoursematerialIDDropdownGridBo"].ParseStrTo(); var Schoolyear = Request.Form["DictionarySchoolyear"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolyear"].ParseStrTo(); var schoolcodeID = Request.Form["DictionarySchoolcode"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolcode"].ParseStrTo(); List MinorPlanIDList = new List(); if (MinorPlanID != "") { MinorPlanIDList = MinorPlanID.SplitIDString(); } else { MinorPlanIDList = null; } var dt = minorSpecialtyPlanServices.GetMinorSpecialtyViewList(configuretView, schoolYearID, collegeID, yearID, standardID, coursematerialID, Schoolyear, schoolcodeID, MinorPlanIDList).Select(x => new { x.SchoolcodeStr, x.YearID, x.SpecialtyCode, x.StandardName, x.CourseCode, x.CourseName, x.CourseTypeName, x.Credit, x.TheoryCourse, x.Practicehours, x.Trialhours, x.Totalhours, x.SchoolyearNumName, x.SchoolcodeName, x.DepartmentName, x.CollegeName }).ToTable(); string[] liststring = { "学年学期", "年级", "专业代码", "专业名称", "课程代码","课程名称", "课程类型","学分","理论学时","实践学时","实验学时","总学时","开课学年","开课学期","开课教研室","开课"+RSL.Get("College")}; neh.Export(dt, liststring, "辅修计划信息"); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } [HttpPost] public ActionResult GetListByMinorSpecialtyID(QueryParamsModel pararms) { var MinorSpecialtyID = Request["MinorSpecialtyID"].ParseStrTo(); return this.Json(minorSpecialtyPlanServices.GetMinorSpecialtyViewByMinorSpecialtyIDGrid(MinorSpecialtyID, (int)pararms.page, (int)pararms.rows)); } } }