123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 |
- 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.Utility;
- using EMIS.Web.Controls;
- using EMIS.ViewModel;
- using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
- using EMIS.CommonLogic.SchedulingManage.SchedulingSettings;
- namespace EMIS.Web.Controllers.SchedulingManage.SchedulingSettings
- {
- [Authorization]
- public class CollegeClassroomController : Controller
- {
- public ICollegeClassroomServices CollegeClassroomServices { 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 collegeCampusID = pararms.getExtraGuid("CollegeCampusDropdown");
- var collegeID = pararms.getExtraGuid("CollegeDropdown");
- 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 isReserve = pararms.getExtraInt("IsReserveDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsReserveDropdown");
- //是否可用
- var isAvailable = pararms.getExtraInt("IsAvailableDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsAvailableDropdown");
- return Json(CollegeClassroomServices.GetCollegeClassroomViewGrid(configuretView, collegeCampusID, collegeID, buildingsID,
- classroomName, classroomTypeID, isConcurrentUse, isReserve, isAvailable, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 院系教室下拉列表信息(仅查询预留为否、状态为可用的院系教室信息)
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult ClassroomListComboGrid(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var collegeCampusID = pararms.getExtraGuid("CollegeCampusDropdown");
- var collegeID = Request.Form["collegeID"].ParseStrTo<Guid>();
- var buildingsID = pararms.getExtraGuid("BuildingsDropdown");
- //教室名称
- var classroomName = pararms.getExtraString("ClassroomNameDropdown");
- //教室类型
- int? classroomTypeID = pararms.getExtraString("ClassroomTypeID").ParseStrTo<int>();
- //可否多班教学
- var isConcurrentUse = pararms.getExtraInt("IsConcurrentUseDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsConcurrentUseDropdown");
- //是否预留
- var isReserve = (int)CF_GeneralPurpose.IsNo;
- //是否可用
- var isAvailable = (int)CF_GeneralPurpose.IsYes;
- return Json(CollegeClassroomServices.GetCollegeClassroomViewGrid(configuretView, collegeCampusID, collegeID, buildingsID,
- classroomName, classroomTypeID, isConcurrentUse, isReserve, isAvailable, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="collegeClassroomID"></param>
- /// <returns></returns>
- public ActionResult CopyAdd(Guid collegeClassroomID)
- {
- CollegeClassroomView collegeClassroomView = new CollegeClassroomView();
- collegeClassroomView = CollegeClassroomServices.GetCollegeClassroomView(collegeClassroomID);
- return View("Edit", collegeClassroomView);
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="collegeClassroomView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CopyAdd(CollegeClassroomView collegeClassroomView)
- {
- collegeClassroomView.CollegeClassroomID = Guid.Empty;
- return this.Edit(collegeClassroomView);
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="collegeClassroomID"></param>
- /// <returns></returns>
- public ActionResult Edit(Guid? collegeClassroomID)
- {
- CollegeClassroomView collegeClassroomView = new CollegeClassroomView();
- if (collegeClassroomID.HasValue && collegeClassroomID != Guid.Empty)
- {
- collegeClassroomView = CollegeClassroomServices.GetCollegeClassroomView(collegeClassroomID);
- }
- return View(collegeClassroomView);
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="collegeClassroomView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(CollegeClassroomView collegeClassroomView)
- {
- try
- {
- CollegeClassroomServices.CollegeClassroomEdit(collegeClassroomView);
- 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 BatchAdd()
- {
- CollegeClassroomView collegeClassroomView = new CollegeClassroomView();
- return View(collegeClassroomView);
- }
- /// <summary>
- /// 院系教室信息批量新增(根据院系所信息选择教室信息新增)
- /// </summary>
- /// <param name="collegeClassroomView"></param>
- /// <returns></returns>
- public ActionResult BatchAdd(CollegeClassroomView collegeClassroomView)
- {
- try
- {
- var classroomIDList = Request["classroomIDList"].JsonToObject<List<Guid?>>();
- string result = CollegeClassroomServices.CollegeClassroomBatchAdd(classroomIDList, collegeClassroomView);
- 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 ClassroomNoAddList(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 isReserve = pararms.getExtraInt("IsReserveDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsReserveDropdown");
- //是否可用
- var isAvailable = pararms.getExtraInt("IsAvailableDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsAvailableDropdown");
- //分配的院系所ID(只能选择一个)
- var collegeID = pararms.getExtraGuid("CollegeID");
- return base.Json(CollegeClassroomServices.GetClassroomViewNoAddGrid(configuretView, campusID, buildingsID, classroomName,
- classroomTypeID, isConcurrentUse, isReserve, isAvailable, collegeID, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 院系教室信息批量新增(根据院系教室信息新增)
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult CollegeClassroomBatchAdd()
- {
- CollegeClassroomView collegeClassroomView = new CollegeClassroomView();
- return View(collegeClassroomView);
- }
- /// <summary>
- /// 院系教室信息批量新增(根据院系教室信息新增)
- /// </summary>
- /// <param name="collegeClassroomView"></param>
- /// <returns></returns>
- public ActionResult CollegeClassroomBatchAdd(CollegeClassroomView collegeClassroomView)
- {
- try
- {
- var collegeClassroomViewList = Request["collegeClassroomViewList"].JsonToObject<List<CollegeClassroomView>>();
- string result = CollegeClassroomServices.CollegeClassroomBatchAdd(collegeClassroomViewList, collegeClassroomView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "新增成功" + result + "。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "新增失败,原因:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 查询对应的未新增院系教室信息
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CollegeClassroomNoAddList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var buildingsInfoCampusID = pararms.getExtraGuid("BuildingsInfoCampusDropdown");
- 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 isReserve = pararms.getExtraInt("IsReserveDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsReserveDropdown");
- //是否可用
- var isAvailable = pararms.getExtraInt("IsAvailableDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsAvailableDropdown");
- //分配的院系所ID(可多选)
- var collegeID = pararms.getExtraGuid("CollegeDropdown");
- return base.Json(CollegeClassroomServices.GetCollegeClassroomViewNoAddGrid(configuretView, buildingsInfoCampusID,
- buildingsID, classroomName, classroomTypeID, isConcurrentUse, isReserve, isAvailable, collegeID, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="collegeClassroomIDs"></param>
- /// <returns></returns>
- public ActionResult Delete(string collegeClassroomIDs)
- {
- try
- {
- List<Guid?> list = collegeClassroomIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => (Guid?)new Guid(x)).ToList();
- CollegeClassroomServices.CollegeClassroomDelete(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 collegeCampusID = Request.Form["CollegeCampusDropdown"].ParseStrTo<Guid>();
- var collegeID = Request.Form["CollegeDropdown"].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 isReserve = Request.Form["IsReserveDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsReserveDropdown"].ParseStrTo<int>();
- //是否可用
- var isAvailable = Request.Form["IsAvailableDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsAvailableDropdown"].ParseStrTo<int>();
- var dt = CollegeClassroomServices.GetCollegeClassroomViewList(configuretView, collegeCampusID, collegeID, buildingsID,
- classroomName, classroomTypeID, isConcurrentUse, isReserve, isAvailable)
- .Select(x => new
- {
- x.CollegeNo,
- x.CollegeName,
- x.UnitCategoryName,
- x.CollegeCampusNo,
- x.CollegeCampusName,
- x.ClassroomCode,
- x.ClassroomName,
- x.ClassroomTypeName,
- x.RoomUseName,
- x.Totalseating,
- x.Effectiveseating,
- x.BuildingsInfoCode,
- x.BuildingsInfoName,
- x.CampusNo,
- x.CampusName,
- x.IsConcurrentUseName,
- x.IsReserveName,
- x.IsAvailableName,
- }).ToTable();
- string[] liststring = {
- RSL.Get("CollegeCode"), RSL.Get("CollegeName"), "单位类别", RSL.Get("CampusCode"),
- RSL.Get("CampusName"), "教室编号", "教室名称", "教室类型", "房间用途", "总座位数",
- "有效座位数", "建筑物编号", "建筑物名称", "所属" + RSL.Get("CampusCode"),
- "所属" + RSL.Get("CampusName"), "可否多班教学", "是否预留", "是否可用"
- };
- 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
- });
- }
- }
- }
- }
|