123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- 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.Common.Exceptions;
- namespace EMIS.Web.Controllers.ExaminationApply
- {
- [Authorization]
- public class ExaminationSubjectCountLimitController : Controller
- {
- public ISubjectCountLimitServices SubjectCountLimitServices { get; set; }
- /// <summary>
- /// 专业控制页面
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- return View();
- }
- public ActionResult Add()
- {
- SubjectCountLimitView subjectCountLimitView = new SubjectCountLimitView();
- return View(subjectCountLimitView);
- }
- [HttpPost]
- public ActionResult Add(SubjectCountLimitView subjectCountLimitView)
- {
- try
- {
- if (subjectCountLimitView.FacultymajorID == null)
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "请选择院系专业!"
- });
- var facultymajorString = Request.Form["FacultymajorID"];
- var facultymajorIDList = facultymajorString.Split(',').Where(x => x.IndexOf("-") >= 0).Select(x => new Guid(x)).ToList();
- foreach (var facultymajorID in facultymajorIDList)
- {
- subjectCountLimitView.FacultymajorID = facultymajorID;
- SubjectCountLimitServices.Save(subjectCountLimitView);
- }
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- public ActionResult Edit(Guid? SubjectCountLimitID)
- {
- SubjectCountLimitView subjectCountLimitView = new SubjectCountLimitView();
- if (SubjectCountLimitID != null && SubjectCountLimitID != Guid.Empty)
- {
- subjectCountLimitView = SubjectCountLimitServices.GetSubjectCountLimitViewInfo(SubjectCountLimitID);
- }
- return View(subjectCountLimitView);
- }
- /// <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 facultymajorID = pararms.getExtraGuid("FacultymajorDropdown");
- var yearNum = pararms.getExtraInt("YearNumDropdown") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YearNumDropdown");
- if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- return base.Json(SubjectCountLimitServices.GetSubjectCountLimitViewList(configuretView, examinationTypeID, facultymajorID, yearNum, (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 facultymajorID = Request.Form["FacultymajorDropdown"].ParseStrTo<Guid>();
- if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- var dt = SubjectCountLimitServices.GetSubjectCountLimitViewList(configuretView, examinationTypeID, facultymajorID).Select(x => new
- {
- x.ExaminationTypeName,
- x.FacultymajorName,
- x.SchoolyearNumName,
- x.SubjectCountLimit
- }).ToTable();
- string[] liststring = { "考试类型", "院系专业", "年级数", "报名门数" };
- neh.Export(dt, liststring, "门数限定信息");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/SubjectCountLimit/List").AddMenuParameter()
- });
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="roleID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string subjectCountLimitIDs)
- {
- try
- {
- var subjectCountLimitIDList = subjectCountLimitIDs.Split(',').Select(x => (Guid?)new Guid(x)).ToList();
- SubjectCountLimitServices.Delete(subjectCountLimitIDList);
- return base.Json("删除成功");
- }
- catch (Exception ex)
- {
- return base.Json("删除失败,原因:" + ex.Message + "!");
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(SubjectCountLimitView subjectCountLimitView)
- {
- try
- {
- if (subjectCountLimitView.FacultymajorID == null)
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "请选择院系专业!"
- });
- SubjectCountLimitServices.Save(subjectCountLimitView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- public ActionResult Validation(Guid? examinationType, string facultymajorIDs, string years)
- {
- List<Guid?> list = new List<Guid?>();
- foreach (var i in facultymajorIDs.Split(','))
- {
- list.Add(new Guid(i));
- }
- List<int?> list1 = new List<int?>();
- foreach (var i in years.Split(','))
- {
- list1.Add(Convert.ToInt32(i));
- }
- string [] result=SubjectCountLimitServices.Validation(examinationType, list, list1);
- return Json(new ReturnMessage()
- {
- IsSuccess = result[0] == "true" ? true : false,
- Message = result[1]
- });
- }
- }
- }
|