123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- 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.SelectCourse;
- using Bowin.Common.Data;
- using Bowin.Common.Utility;
- using EMIS.ViewModel.SelectCourse;
- namespace EMIS.Web.Controllers.SelectCourseManage
- {
- [Authorization]
- public class SelectCourseTypeSettingController : Controller
- {
- public ITypeSettingServices TypeSettingServices { get; set; }
- /// <summary>
- /// 类型设定页面
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- return View();
- }
- /// <summary>
- /// 列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- //避开全选值
- var schoolYearID = pararms.getExtraGuid("SchoolYear");
- var selectCourseTypeID = pararms.getExtraInt("SelectCourseType");
- if (selectCourseTypeID == DropdownList.SELECT_ALL) selectCourseTypeID = null;
- var recordStatus = pararms.getExtraInt("RecordStatus");
- if (recordStatus == DropdownList.SELECT_ALL) recordStatus = null;
- if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- return base.Json(TypeSettingServices.GetTypeSettingViewList(configuretView, schoolYearID, selectCourseTypeID, recordStatus,
- (int)pararms.page, (int)pararms.rows));
- }
- public ActionResult Edit(Guid? typeSettingID)
- {
- SelectCourseTypeSettingView typeSettingView = new SelectCourseTypeSettingView();
- if (typeSettingID != null && typeSettingID != Guid.Empty)
- {
- typeSettingView = TypeSettingServices.GetTypeSettingViewInfo(typeSettingID);
- }
- else
- {
- typeSettingView.MaxSelectCount = 2;
- typeSettingView.MinSelectCount = 0;
- typeSettingView.MaxCredit = 0;
- typeSettingView.MinCredit = 0;
- }
- return View(typeSettingView);
- }
- /// <summary>
- /// 新增
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(SelectCourseTypeSettingView typeSettingView)
- {
- try
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- TypeSettingServices.Save(typeSettingView);
- return Json(new ReturnMessage
- {
- IsSuccess = true,
- Message = "保存成功"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="roleID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string typeSettingIDs)
- {
- try
- {
- var typeSettingIDList = typeSettingIDs.Split(',').Select(x => (Guid?)new Guid(x)).ToList();
- TypeSettingServices.Delete(typeSettingIDList);
- return base.Json("删除成功!");
- }
- catch (Exception ex)
- {
- return base.Json("删除失败,原因:" + ex.Message + "。");
- }
- }
- [HttpPost]
- public ActionResult Excel(QueryParamsModel pararms)
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- //避开全选值
- var schoolYearID = Request.Form["SchoolYear"].ParseStrTo<Guid>();
- var selectCourseTypeID = Request.Form["SelectCourseType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SelectCourseType"].ParseStrTo<int>();
- var recordStatus = Request.Form["RecordStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["RecordStatus"].ParseStrTo<int>();
- var dt = TypeSettingServices.GetTypeSettingViewList(configuretView, schoolYearID, selectCourseTypeID, recordStatus)
- .Select(x => new
- {
- x.SchoolyearCode,
- x.SelectCourseTypeDesc,
- StartTime = x.StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
- EndTime = x.EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
- x.MaxSelectCount,
- x.MinSelectCount,
- x.MaxCredit,
- x.MinCredit,
- x.RecordStatusDesc,
- x.Remark
- }).ToTable();
- string[] liststring = { "学年学期", "选修类型", "开始时间", "结束时间",
- "门数上限", "门数下限", "学分上限", "学分下限", "是否启用", "备注" };
- neh.Export(dt, liststring, "网上选课类型设定");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/SelectCourseTypeSetting/List").AddMenuParameter()
- });
- }
- }
- }
|