123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Bowin.Web.Controls.Mvc;
- using Bowin.Common.Utility;
- using Bowin.Common.Data;
- using Bowin.Common.JSON;
- using EMIS.Web.Controls;
- using EMIS.Utility;
- using EMIS.ViewModel;
- using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
- using EMIS.CommonLogic.SchedulingManage.SchedulingSettings;
- namespace EMIS.Web.Controllers.SchedulingManage.SchedulingSettings
- {
- [Authorization]
- public class ClassroomReserveController : Controller
- {
- public IClassroomReserveServices ClassroomReserveServices { 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);
- var campusID = pararms.getExtraGuid("CampusDropdown");
- var buildingsID = pararms.getExtraGuid("BuildingsDropdown");
- //教室名称
- var classroomName = pararms.getExtraString("ClassroomNameDropdown");
- //教室类型
- var classroomTypeID = pararms.getExtraInt("ClassroomTypeDictionary") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ClassroomTypeDictionary");
- //可否多班教学
- var isConcurrentUse = pararms.getExtraInt("IsConcurrentUseDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsConcurrentUseDropdown");
- //是否可用
- var isAvailable = pararms.getExtraInt("IsAvailableDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsAvailableDropdown");
- return base.Json(ClassroomReserveServices.GetClassroomReserveViewGrid(configuretView, campusID, buildingsID, classroomName,
- classroomTypeID, isConcurrentUse, isAvailable, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="classroomReserveID"></param>
- /// <returns></returns>
- public ActionResult Edit(Guid? classroomReserveID)
- {
- ClassroomReserveView classroomReserveView = new ClassroomReserveView();
- if (classroomReserveID.HasValue && classroomReserveID != Guid.Empty)
- {
- classroomReserveView = ClassroomReserveServices.GetClassroomReserveView(classroomReserveID);
- }
- else
- {
- classroomReserveView.IsReserve = true;
- }
- return View(classroomReserveView);
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="classroomReserveView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(ClassroomReserveView classroomReserveView)
- {
- try
- {
- ClassroomReserveServices.ClassroomReserveEdit(classroomReserveView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 教室预留批量新增
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult ClassroomReserveBatchAdd()
- {
- ClassroomReserveView classroomReserveView = new ClassroomReserveView();
- return View(classroomReserveView);
- }
- /// <summary>
- /// 教室预留批量新增
- /// </summary>
- /// <param name="collegeClassroomView"></param>
- /// <returns></returns>
- public ActionResult ClassroomReserveBatchAdd(ClassroomReserveView classroomReserveView)
- {
- try
- {
- var classroomIDList = Request["classroomIDList"].JsonToObject<List<Guid?>>();
- string result = ClassroomReserveServices.ClassroomReserveBatchAdd(classroomIDList, classroomReserveView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "预留成功" + result + "。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "预留失败,原因:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 查询未预留的教室信息ClassroomView
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult ClassroomNoReserveList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var campusID = pararms.getExtraGuid("CampusDropdown");
- var buildingsID = pararms.getExtraGuid("BuildingsDropdown");
- //教室名称
- var classroomName = pararms.getExtraString("ClassroomNameDropdown");
- //教室类型
- var classroomTypeID = pararms.getExtraInt("ClassroomTypeDictionary") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ClassroomTypeDictionary");
- //可否多班教学
- var isConcurrentUse = pararms.getExtraInt("IsConcurrentUseDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsConcurrentUseDropdown");
- //是否可用
- var isAvailable = pararms.getExtraInt("IsAvailableDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsAvailableDropdown");
- return base.Json(ClassroomReserveServices.GetClassroomViewNoReserveGrid(configuretView, campusID, buildingsID,
- classroomName, classroomTypeID, isConcurrentUse, isAvailable, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="classroomReserveIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string classroomReserveIDs)
- {
- try
- {
- List<Guid?> list = classroomReserveIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => (Guid?)new Guid(x)).ToList();
- ClassroomReserveServices.ClassroomReserveDelete(list);
- return base.Json(new ReturnMessage { IsSuccess = true, Message = "解除成功。" });
- }
- catch (Exception ex)
- {
- return base.Json(new ReturnMessage { IsSuccess = false, Message = "解除失败,原因:" + ex.Message });
- }
- }
- /// <summary>
- /// Excel导出
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- try
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
- var buildingsID = Request.Form["BuildingsDropdown"].ParseStrTo<Guid>();
- //教室名称
- var classroomName = Request.Form["ClassroomNameDropdown"].ToString();
- //教室类型
- var classroomTypeID = Request.Form["ClassroomTypeDictionary"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ClassroomTypeDictionary"].ParseStrTo<int>();
- //可否多班教学
- var isConcurrentUse = Request.Form["IsConcurrentUseDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsConcurrentUseDropdown"].ParseStrTo<int>();
- //是否可用
- var isAvailable = Request.Form["IsAvailableDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsAvailableDropdown"].ParseStrTo<int>();
- var dt = ClassroomReserveServices.GetClassroomReserveViewList(configuretView, campusID, buildingsID,
- classroomName, classroomTypeID, isConcurrentUse, isAvailable)
- .Select(x => new
- {
- x.ClassroomCode,
- x.ClassroomName,
- x.BuildingsInfoCode,
- x.BuildingsInfoName,
- x.CampusNo,
- x.CampusName,
- x.ClassroomTypeName,
- x.RoomUseName,
- x.Totalseating,
- x.Effectiveseating,
- x.CollegeCode,
- x.CollegeName,
- x.CollegeCampusCode,
- x.CollegeCampusName,
- x.IsConcurrentUseName,
- x.ScheduleCollegeCount,
- x.IsAvailableName
- }).ToTable();
- string[] liststring = {
- "教室编号", "教室名称", "建筑物编号", "建筑物名称", RSL.Get("CampusCode"),
- RSL.Get("Campus"), "教室类型", "房间用途", "总座位数", "有效座位数",
- "所属" + RSL.Get("CollegeCode"), "所属" + RSL.Get("College"),
- "所属" + RSL.Get("CampusCode"), "所属" + RSL.Get("Campus"),
- "可否多班教学", "排课院系个数", "是否可用"
- };
- neh.Export(dt, liststring, "教室预留信息" + DateTime.Now.ToString("yyyyMMdd"));
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "导出成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "导出失败,原因:" + ex.Message
- });
- }
- }
- }
- }
|