123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Bowin.Common.Utility;
- using Bowin.Common.Data;
- using Bowin.Web.Controls.Mvc;
- using EMIS.Web.Controls;
- using EMIS.Utility;
- using EMIS.ViewModel;
- using EMIS.ViewModel.TeachingMaterial;
- using EMIS.CommonLogic.TeachingMaterial;
- using EMIS.CommonLogic.UniversityManage.AdministrativeOrgan;
- namespace EMIS.Web.Controllers.TeachingMaterial
- {
- [Authorization]
- public class LibraryController : Controller
- {
- public ILibraryServices LibraryServices { get; set; }
- public ICampusServices CampusServices { get; set; }
- /// <summary>
- /// 书库信息页面
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult List()
- {
- return View();
- }
- /// <summary>
- /// 列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- return base.Json(LibraryServices.GetLibraryViewGrid(configuretView, (int)pararms.page, (int)pararms.rows));
- }
- [HttpPost]
- public ActionResult Excel(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- NpoiExcelHelper neh = new NpoiExcelHelper();
- var dt = LibraryServices.GetLibraryViewExcel(configuretView).Select(x => new
- {
- x.LibraryCode,
- x.LibraryName,
- x.CampusName,
- x.HeadPeople,
- x.ContectTelNumber,
- x.CreateTime,
- x.CreateUserName
- }).ToTable();
- string[] liststring = { "书库编号", "书库名称", RSL.Get("CampusName"), "负责人", "联系电话", "创建时间", "创建人" };
- neh.Export(dt, liststring, "书库信息");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/ Library/List").AddMenuParameter()
- });
- }
- /// <summary>
- /// 编辑页面
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(Guid? libraryID)
- {
- LibraryView libraryView;
- if (libraryID != null && libraryID != Guid.Empty)
- {
- libraryView = LibraryServices.GetSingleLibrary(libraryID.Value);
- }
- else
- {
- libraryView = new LibraryView()
- {
- LibraryID = Guid.Empty
- };
- }
- return View(libraryView);
- }
- /// <summary>
- /// 新增
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(LibraryView libraryView)
- {
- try
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- LibraryServices.EditLibrary(libraryView, user.UserID);
-
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message + "!"
- });
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="roleID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string libraryIDs)
- {
- try
- {
- var libraryIDList = libraryIDs.Split(',').Select(x => (Guid)new Guid(x)).ToList();
- LibraryServices.DeleteLibrary(libraryIDList);
- return base.Json("删除成功");
- }
- catch (Exception ex)
- {
- return base.Json("删除失败,原因:" + ex.Message + "。");
- }
- }
- [HttpPost]
- public ActionResult GetCampusCodeByCampusID(Guid campusID)
- {
- string campusCode = string.Empty;
- var campus = CampusServices.GetCampusList()
- .Where(x => x.CampusID == campusID).SingleOrDefault();
- if (campus != null)
- {
- campusCode = campus.No;
- }
- return base.Json(campusCode);
- }
- }
- }
|