using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Bowin.Common.Utility; using Bowin.Common.Data; using Bowin.Web.Controls.Mvc; using Bowin.Common.JSON; using EMIS.ViewModel; using EMIS.Web.Controls; using EMIS.CommonLogic.CultureplanManage.CourseMaterial; using EMIS.ViewModel.Cultureplan; using EMIS.ViewModel.CultureplanManage.CourseMaterial; namespace EMIS.Web.Controllers.CultureplanManage.CourseMaterial { [Authorization] public class ClubCourseController : Controller { public IClubCourseServices ClubCourseServices { get; set; } /// /// 俱乐部页面 /// /// public ActionResult List() { return View(); } /// /// 俱乐部页面列表查询 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); //课程级别 var courseLevelID = pararms.getExtraInt("DictionaryCourseLevel") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryCourseLevel"); //课程科类 var courseScienceID = pararms.getExtraInt("DictionaryCourseScience") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryCourseScience"); //上课类型 var classGroupingID = pararms.getExtraGuid("TeachTypeDropdown"); //是否启用 var isEnable = pararms.getExtraInt("DictionaryIsEnable") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsEnable"); return base.Json(ClubCourseServices.GetClubCourseViewGrid(configuretView, courseLevelID, courseScienceID, classGroupingID, isEnable, (int)pararms.page, (int)pararms.rows)); } /// /// 批量新增 /// /// public ActionResult BatchAdd() { ClubCourseView clubCourseView = new ClubCourseView(); return View(clubCourseView); } /// /// 批量新增 /// /// /// [HttpPost] public ActionResult BatchAdd(ClubCourseView clubCourseView) { try { var courseNoClubViewList = Request["CourseNoClubList"].JsonToObject>(); string result = ClubCourseServices.ClubCourseBatchAdd(clubCourseView, courseNoClubViewList); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功" + result + "。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message }); } } /// /// 查询对应的课程信息View(课程信息表左连俱乐部课程表,排除对应的俱乐部课程信息) /// /// /// [HttpPost] public ActionResult CourseNoClubList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); //课程级别 var courseLevelID = pararms.getExtraInt("DictionaryCourseLevel") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryCourseLevel"); //课程科类 var courseScienceID = pararms.getExtraInt("DictionaryCourseScience") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryCourseScience"); //是否启用 var isEnable = pararms.getExtraInt("DictionaryIsEnable") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsEnable"); return base.Json(ClubCourseServices.GetCourseNoClubViewGrid(configuretView, courseLevelID, courseScienceID, isEnable, (int)pararms.page, (int)pararms.rows)); } /// /// 编辑(新增、修改--暂时无效) /// /// /// public ActionResult Edit(Guid? clubCourseID) { return null; } /// /// 编辑(新增、修改--暂时无效) /// /// /// [HttpPost] public ActionResult Edit(ClubCourseView clubCourseView) { return null; } /// /// 删除 /// /// /// [HttpPost] public ActionResult Delete(string clubCourseIDs) { try { List list = clubCourseIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)) .Select(x => (Guid?)new Guid(x)).ToList(); ClubCourseServices.ClubCourseDelete(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 courseLevelID = Request.Form["DictionaryCourseLevel"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryCourseLevel"].ParseStrTo(); //课程科类 var courseScienceID = Request.Form["DictionaryCourseScience"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryCourseScience"].ParseStrTo(); //上课类型 var classGroupingID = Request.Form["TeachTypeDropdown"].ParseStrTo(); //是否启用 var isEnable = Request.Form["DictionaryIsEnable"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsEnable"].ParseStrTo(); var dt = ClubCourseServices.GetClubCourseViewList(configuretView, courseLevelID, courseScienceID, classGroupingID,isEnable) .Select(x => new { x.CourseCode, x.CourseName, x.Abbreviation, x.CourseLevelName, x.CourseScienceName, x.ClassName, x.IsEnableName }).ToTable(); string[] liststring = { "课程代码", "课程名称", "课程简称", "课程级别", "课程科类", "上课类型", "是否启用" }; neh.Export(dt, liststring, "俱乐部课程信息" + DateTime.Now.ToString("yyyyMMdd")); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } } }