123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Bowin.Common.Data;
- using Bowin.Common.Exceptions;
- using Bowin.Common.Utility;
- using Bowin.Web.Controls.Mvc;
- using EMIS.Utility;
- using EMIS.Web.Controls;
- using EMIS.ViewModel;
- using EMIS.ViewModel.UniversityManage.AdministrativeOrgan;
- using EMIS.CommonLogic.UniversityManage.AdministrativeOrgan;
- namespace EMIS.Web.Controllers.UniversityManage.AdministrativeOrgan
- {
- [Authorization]
- public class UniversityController : Controller
- {
- public IUniversityServices UniversityServices { 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);
- return base.Json(UniversityServices.GetUniversityViewGrid(configuretView, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 学校信息下拉查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult DropdownListBanid()
- {
- List<DropdownListItem> list = UniversityServices.GetUniversityList().Select(x => new DropdownListItem
- {
- Text = x.Name,
- Value = x.UniversityID.ToString()
- }).ToList();
- return base.Json(list);
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="universityID"></param>
- /// <returns></returns>
- public ActionResult CopyAdd(Guid universityID)
- {
- UniversityView universityView = new UniversityView();
- universityView = UniversityServices.GetUniversityView(universityID);
- return View("Edit", universityView);
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="universityView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CopyAdd(UniversityView universityView)
- {
- universityView.UniversityID = Guid.Empty;
- return this.Edit(universityView);
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:学校代码或学校名称)
- /// </summary>
- /// <param name="universityID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(Guid? universityID)
- {
- UniversityView universityView = new UniversityView();
- if (universityID != null && universityID != Guid.Empty)
- {
- universityView = UniversityServices.GetUniversityView(universityID);
- }
- return View(universityView);
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:学校代码或学校名称)
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(UniversityView universityView)
- {
- try
- {
- UniversityServices.UniversityEdit(universityView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="universityID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string universityIDs)
- {
- try
- {
- List<Guid?> list = universityIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
- UniversityServices.UniversityDelete(list);
- return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
- }
- catch (Exception ex)
- {
- string mge = ex.Message;
- System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
- if (num != null)
- {
- if (num.Number == 547)
- {
- mge = "请先删除与其有关联的数据,如:" + RSL.Get("Campus") + "、" + RSL.Get("College") + "等。";
- }
- }
- return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + mge });
- }
- }
- /// <summary>
- /// Excel导出
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel(UniversityView pararms)
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var dt = UniversityServices.GetUniversityViewList(configuretView)
- .Select(x => new
- {
- x.Code,
- x.Name,
- x.SimpleName,
- x.EnglishName,
- x.ProvinceName,
- x.CityName,
- x.HeadMasterName,
- x.PartyManageName,
- x.Telephone,
- x.ZIPCode,
- x.FAX,
- x.Email,
- x.BuildDate,
- x.SchoolMotto,
- x.HistoryEvolution,
- x.HomePage,
- x.Address,
- x.EnglishAddress,
- x.Remark
- }).ToTable();
- string[] liststring = {
- "学校代码", "学校名称", "学校简称", "英文名称", "所属省份", "所属市", "校长",
- "党务负责人", "联系电话", "邮政编码", "传真", "电子邮件", "创校日期", "校训",
- "历史沿革", "主页地址", "学校地址" , "学校英文地址", "备注"
- };
- neh.Export(dt, liststring, "学校信息" + DateTime.Now.ToString("yyyyMMdd"));
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "导出成功。"
- });
- }
- }
- }
|