123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.ViewModel.ExaminationApply;
- using EMIS.CommonLogic.ExaminationApply;
- using EMIS.ViewModel;
- using EMIS.Web.Controls;
- using Bowin.Common.Data;
- using Bowin.Common.Utility;
- using Bowin.Common.Exceptions;
- using Bowin.Web.Controls.Mvc;
- namespace EMIS.Web.Controllers.ExaminationApply
- {
- [Authorization]
- public class ExaminationSubjectController : Controller
- {
- public IExaminationSubjectServices ExaminationSubjectServices { get; set; }
- /// <summary>
- /// 考试科目页面
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- return View();
- }
- public ActionResult Edit(Guid? ExaminationSubjectID)
- {
- ExaminationSubjectView examinationSubjectView = new ExaminationSubjectView();
- if (ExaminationSubjectID != null && ExaminationSubjectID != Guid.Empty)
- {
- examinationSubjectView = ExaminationSubjectServices.GetExaminationSubjectViewInfo(ExaminationSubjectID);
- }
- ViewBag.ID = ExaminationSubjectID;
- return View(examinationSubjectView);
- }
- /// <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 schoolYearID = pararms.getExtraGuid("SchoolYearDropdown");
- var examinationSubjectID = pararms.getExtraGuid("ExaminationSubjectDropdown");
- if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- return base.Json(ExaminationSubjectServices.GetExaminationSubjectViewList(configuretView, examinationTypeID,examinationSubjectID,schoolYearID, (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>();
- if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- var dt = ExaminationSubjectServices.GetExaminationSubjectViewList(configuretView, examinationTypeID, null).Select(x => new
- {
- x.Name,
- ExaminationDate = (x.ExaminationDate.HasValue ? x.ExaminationDate.Value.ToString("yyyy-MM-dd") : ""),
- x.ExaminationTypeName,
- x.ExaminationFormName,
- x.PeopleNumLimit,
- x.SchoolyearCode
- }).ToTable();
- string[] liststring = { "考试科目", "考试日期", "考试类型", "考试类别", "最大报名人数", "考试学年学期" };
- neh.Export(dt, liststring, "考试科目信息");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/ExaminationSubject/List").AddMenuParameter()
- });
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="roleID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string examinationSubjectIDs)
- {
- try
- {
- var examinationSubjectIDList = examinationSubjectIDs.Split(',').Select(x => (Guid?)new Guid(x)).ToList();
- ExaminationSubjectServices.Delete(examinationSubjectIDList);
- 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 + "!");
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(ExaminationSubjectView examinationSubjectView)
- {
- try
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- ExaminationSubjectServices.Save(examinationSubjectView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- [HttpPost]
- public ActionResult DropdownList(DropdownListBindType? bindType, Guid? examinationTypeID,Guid? examinationSubjectID)
- {
- List<DropdownListItem> list = ExaminationSubjectServices.GetExaminationSubjectViewList(new ConfiguretView(), examinationTypeID, examinationSubjectID)
- .Select(x => new DropdownListItem { Text = x.Name, Value = x.ExaminationSubjectID.ToString() }).ToList();
- DropdownListBindType dbt = bindType == null ? DropdownListBindType.PleaseSelect : bindType.Value;
- Bowin.Web.Controls.Mvc.DropdownList.FormatDropdownItemList(dbt, list);
- return base.Json(list);
- }
- [HttpPost]
- public ActionResult DropdownExaminationSubjectNameList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
-
- if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- var list = ExaminationSubjectServices.GetExaminationSubjectNameViewList(configuretView, (int)pararms.page, (int)pararms.rows);
- return base.Json(list);
- }
- public ActionResult Validation(string ExaminationTypeIDs, string SchoolyearIDs,string ExaminationFormIDs, string names)
- {
- List<Guid?> list = new List<Guid?>();
- foreach (var i in ExaminationTypeIDs.Split(','))
- {
- list.Add(new Guid(i));
- }
- List<Guid?> list1 = new List<Guid?>();
- foreach (var i in SchoolyearIDs.Split(','))
- {
- list1.Add(new Guid(i));
- }
- List<int?> list2 = new List<int?>();
- foreach (var i in ExaminationFormIDs.Split(','))
- {
- list2.Add(Convert.ToInt32(i));
- }
- List<string> list3 = new List<string>();
- foreach (var i in names.Split(','))
- {
- list3.Add(i);
- }
- string[] result = ExaminationSubjectServices.Validation(list, list1, list2, list3);
- return Json(new ReturnMessage()
- {
- IsSuccess = result[0] == "true" ? true : false,
- Message = result[1]
- });
- }
- }
- }
|