123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.CommonLogic.ExaminationApply;
- using EMIS.ViewModel;
- using EMIS.Web.Controls;
- using Bowin.Web.Controls.Mvc;
- using Bowin.Common.Utility;
- using Bowin.Common.Data;
- using EMIS.ViewModel.ExaminationApply;
- using Bowin.Common.Exceptions;
- namespace EMIS.Web.Controllers.ExaminationApply
- {
- [Authorization]
- public class ExaminationTypeController : Controller
- {
- public IExaminationTypeServices ExaminationTypeServices { get; set; }
- /// <summary>
- /// 考试类型页面
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- return View();
- }
- public ActionResult Edit(Guid? ExaminationTypeID)
- {
- ExaminationTypeView examinationTypeView = new ExaminationTypeView();
- if (ExaminationTypeID != null && ExaminationTypeID != Guid.Empty)
- {
- examinationTypeView = ExaminationTypeServices.GetExaminationTypeViewInfo(ExaminationTypeID);
- }
- return View(examinationTypeView);
- }
- /// <summary>
- /// 列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- return base.Json(ExaminationTypeServices.GetExaminationTypeViewList(configuretView, (int)pararms.page, (int)pararms.rows));
- }
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- var dt = ExaminationTypeServices.GetExaminationTypeViewList(configuretView).Select(x => new
- {
- x.Name,
- x.IsTimesLimitDesc
- }).ToTable();
- string[] liststring = { "考试类型", "是否要求次数限定" };
- neh.Export(dt, liststring, "考试类型信息");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/ExaminationType/List").AddMenuParameter()
- });
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="roleID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string examinationTypeIDs)
- {
- try
- {
- var examinationTypeIDList = examinationTypeIDs.Split(',').Select(x => (Guid?)new Guid(x)).ToList();
- ExaminationTypeServices.Delete(examinationTypeIDList);
- 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(ExaminationTypeView examinationTypeView)
- {
- try
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- ExaminationTypeServices.Save(examinationTypeView);
- 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)
- {
- List<DropdownListItem> list = ExaminationTypeServices.GetExaminationTypeViewList(new ConfiguretView())
- .Select(x => new DropdownListItem { Text = x.Name, Value = x.ExaminationTypeID.ToString() }).ToList();
- DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
- Bowin.Web.Controls.Mvc.DropdownList.FormatDropdownItemList(dbt, list);
- return base.Json(list);
- }
- }
- }
|