123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- 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 CampusController : Controller
- {
- public ICampusServices CampusServices { 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(CampusServices.GetCampusViewGrid(configuretView, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 校区信息下拉查询
- /// </summary>
- /// <param name="bindType"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CampusDropdownListBanid(DropdownListBindType? bindType)
- {
- List<DropdownListItem> list = CampusServices.GetCampusList().Select(x => new DropdownListItem
- {
- Text = x.Name,
- Value = x.CampusID.ToString()
- }).ToList();
- DropdownList.FormatDropdownItemList(bindType.Value, list);
- return base.Json(list);
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="campusID"></param>
- /// <returns></returns>
- public ActionResult CopyAdd(Guid campusID)
- {
- CampusView campusView = new CampusView();
- campusView = CampusServices.GetCampusView(campusID);
- return View("Edit", campusView);
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="campusView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CopyAdd(CampusView campusView)
- {
- campusView.CampusID = Guid.Empty;
- return this.Edit(campusView);
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:校区代码或校区名称)
- /// </summary>
- /// <param name="campusID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(Guid? campusID)
- {
- //ViewBag.Type = Request.Params["Type"];//临时性加参数控制、屏蔽列表进入无保存按钮权限
- CampusView campusView = new CampusView();
- if (campusID.HasValue && campusID != Guid.Empty)
- {
- campusView = CampusServices.GetCampusView(campusID);
- }
- return View(campusView);
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:校区代码或校区名称)
- /// </summary>
- /// <param name="campusView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(CampusView campusView)
- {
- try
- {
- CampusServices.CampusEdit(campusView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="campusIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public JsonResult Delete(string campusIDs)
- {
- try
- {
- List<Guid?> list = campusIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
- CampusServices.CampusDelete(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("College") + "等。";
- }
- }
- return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + mge });
- }
- }
- /// <summary>
- /// 校区对应的院系所信息
- /// </summary>
- /// <returns></returns>
- public ActionResult CollegeList()
- {
- return View();
- }
- /// <summary>
- /// 校区对应的院系所信息
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CollegeList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var campusID = Request["campusID"].ParseStrTo<Guid>();
- var unitCategoryID = pararms.getExtraInt("DictionaryUnitCategory") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryUnitCategory");
- return Json(CampusServices.GetCollegeListViewGrid(configuretView, campusID, unitCategoryID, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 校区对应的院系所信息Excel导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CollegeListExcel()
- {
- return null;
- }
- /// <summary>
- /// Excel导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var dt = CampusServices.GetCampusViewList(configuretView)
- .Select(x => new
- {
- x.No,
- x.Name,
- x.SimpleName,
- x.EnglishName,
- x.UniversityCode,
- x.UniversityName,
- x.GeneralsuperName,
- x.RecruitstudentsName,
- x.PlacesuperName,
- x.TeachingsuperName,
- x.StudentchargeName,
- x.ZIPCode,
- x.Officephone,
- x.FAX,
- x.Email,
- x.Evolution,
- x.CollegeCount,
- x.Remark
- }).ToTable();
- string[] liststring = {
- RSL.Get("CampusCode"), RSL.Get("CampusName"), RSL.Get("CampusSimpleName"),
- "英文名称", "学校代码", "学校名称", "总负责人", "招生负责人", "学籍负责人",
- "教学负责人", "学生负责人", "邮政编码", "办公电话",
- "传真", "电子邮箱", "历史沿革", RSL.Get("CollegeCount"), "备注"
- };
- neh.Export(dt, liststring, RSL.Get("CampusName") + "信息" + DateTime.Now.ToString("yyyyMMdd"));
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "导出成功。"
- });
- }
- }
- }
|