123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.CommonLogic.ExaminationApply;
- using EMIS.ViewModel.ExaminationApply;
- using EMIS.ViewModel;
- using EMIS.Web.Controls;
- using Bowin.Common.Data;
- using Bowin.Common.Utility;
- using Bowin.Web.Controls.Mvc;
- namespace EMIS.Web.Controllers.ExaminationApply
- {
- [Authorization]
- public class ExaminationOpenControlController : Controller
- {
- public IOpenControlServices OpenControlServices { get; set; }
- /// <summary>
- /// 科目控制页面
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- return View();
- }
- public ActionResult Edit(Guid? OpenControlID)
- {
- OpenControlView openControlView = new OpenControlView();
- if (OpenControlID != null && OpenControlID != Guid.Empty)
- {
- openControlView = OpenControlServices.GetOpenControlViewInfo(OpenControlID);
- }
- return View(openControlView);
- }
- /// <summary>
- /// 列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var examinationTypeID = pararms.getExtraGuid("ExaminationTypeDropdown");
- var examinationSubjectID = pararms.getExtraGuid("ExaminationSubjectDropdown");
- var yearNum = pararms.getExtraInt("YearNumDropdown") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YearNumDropdown");
- var studentType = pararms.getExtraInt("StudentTypeDropdown") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StudentTypeDropdown");
- if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- return base.Json(OpenControlServices.GetOpenControlViewList(configuretView, examinationTypeID, examinationSubjectID, yearNum, studentType,
- (int)pararms.page, (int)pararms.rows));
- }
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var examinationTypeID = Request.Form["ExaminationTypeDropdown"].ParseStrTo<Guid>();
- var examinationSubjectID = Request.Form["ExaminationSubjectDropdown"].ParseStrTo<Guid>();
- var yearNum = Request.Form["YearNumDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["YearNumDropdown"].ParseStrTo<int>();
- var studentType = Request.Form["StudentTypeDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StudentTypeDropdown"].ParseStrTo<int>();
- if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- var dt = OpenControlServices.GetOpenControlViewList(configuretView, examinationTypeID, examinationSubjectID, yearNum, studentType).Select(x => new
- {
- x.ExaminationSubjectName,
- x.StudentTypeDesc,
- x.SchoolyearNumName,
- StartDate = (x.StartDate.HasValue ? x.StartDate.Value.ToString("yyyy-MM-dd") : ""),
- EndDate = (x.EndDate.HasValue ? x.EndDate.Value.ToString("yyyy-MM-dd") : ""),
- x.PeopleNumLimit
- }).ToTable();
- string[] liststring = { "考试科目", "学生类别", "年级数", "报名时间起", "报名时间止", "限定人数" };
- neh.Export(dt, liststring, "开放控制信息");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/ExaminationOpenControl/List").AddMenuParameter()
- });
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="roleID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string openControlIDs)
- {
- try
- {
- var openControlIDList = openControlIDs.Split(',').Select(x => (Guid?)new Guid(x)).ToList();
- OpenControlServices.Delete(openControlIDList);
- return base.Json("删除成功");
- }
- catch (Exception ex)
- {
- return base.Json("删除失败,原因:" + ex.Message + "!");
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(OpenControlView openControlView)
- {
- try
- {
- if (openControlView.StudentTypeID == null && openControlView.ExaminationOpenControlID != null)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "请选择学生类别!"
- });
- }
- if (openControlView.StudentTypeID.Count > 1 && openControlView.ExaminationOpenControlID!=null)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "修改操作只能选择一种学生类别!"
- });
- }
- if (openControlView.StudentTypeID == null && openControlView.ExaminationOpenControlID==null)
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "请选择学生类别!"
- });
- if (openControlView.ExaminationSubjectEditID == null && openControlView.ExaminationOpenControlID != null)
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "请选择考试科目!"
- });
- OpenControlServices.Save(openControlView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 获取已经存在在学生类别
- /// </summary>
- /// <param name="specialtyCourseID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult StudentType(Guid? openControlID)
- {
- List<string> list = new List<string>();
- if (openControlID.HasValue && openControlID != Guid.Empty)
- list = OpenControlServices.GetStudentType(openControlID);
- return base.Json(list);
- }
- }
- }
|