using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EMIS.ViewModel;
using EMIS.Web.Controls;
using EMIS.CommonLogic.ExaminationManage;
using Bowin.Web.Controls.Mvc;
using Bowin.Common.Data;
using Bowin.Common.Utility;
namespace EMIS.Web.Controllers.ExaminationManage
{
[Authorization]
public class ExaminationRoomSettingController : Controller
{
public IRoomSettingServices RoomSettingServices { get; set; }
public ActionResult List()
{
return View();
}
///
/// 列表查询
///
///
///
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
var campusID = pararms.getExtraGuid("CampusDropdown");
var buildingID = pararms.getExtraGuid("BuildingsDropdown");
var isSpecial = (!pararms.getExtraInt("IsSpecialDictionaryDropDown").HasValue || pararms.getExtraInt("IsSpecialDictionaryDropDown") == DropdownList.SELECT_ALL) ? null : (bool?)(pararms.getExtraInt("IsSpecialDictionaryDropDown") == (int)CF_GeneralPurpose.IsYes);
if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
return base.Json(RoomSettingServices.GetClassroomViewList(configuretView, campusID, buildingID, isSpecial, (int)pararms.page, (int)pararms.rows));
}
///
/// 列表查询
///
///
///
[HttpPost]
public ActionResult AvailableList(Guid examinationPlanID, Guid? examinationRoomLayoutID, QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
return base.Json(RoomSettingServices.GetAvailableClassroomViewList(configuretView, examinationPlanID, examinationRoomLayoutID, (int)pararms.page, (int)pararms.rows));
}
///
/// 列表查询
///
///
///
[HttpPost]
public ActionResult AvailableListGdss(Guid examinationPlanID, Guid? buildingsInfoID, DateTime examinationDate,
TimeSpan startTime, TimeSpan endTime, int studentCount, QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
return base.Json(RoomSettingServices.GetAvailableClassroomViewGdssList(configuretView, examinationPlanID, buildingsInfoID, examinationDate, startTime, endTime,
studentCount, (int)pararms.page, (int)pararms.rows));
}
///
/// 列表查询
///
///
///
[HttpPost]
public ActionResult AddAvailableList(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
return base.Json(RoomSettingServices.GetAddAvailableClassroomViewList(configuretView, (int)pararms.page, (int)pararms.rows));
}
[HttpPost]
public ActionResult Excel()
{
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
var campusID = Request.Form["CampusDropdown"].ParseStrTo();
var buildingID = Request.Form["BuildingsDropdown"].ParseStrTo();
var isSpecial = Request.Form["IsSpecialDictionaryDropDown"] == DropdownList.SELECT_ALL.ToString() ? null : (bool?)(Request.Form["IsSpecialDictionaryDropDown"] == ((int)CF_GeneralPurpose.IsYes).ToString());
if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
var dt = RoomSettingServices.GetClassroomViewList(configuretView, campusID, buildingID, isSpecial).Select(x => new
{
x.Name,
x.IsAvailableName,
x.ClassroomTypeName,
x.Totalseating,
x.Effectiveseating,
x.Examinationseating,
x.IsWrittenExamName,
x.IsMachinetestName,
x.BuildingsInfoName
}).ToTable();
string[] liststring = { "教室", "是否可用", "教室类型", "总座位数", "有效座位数", "考试座位数", "笔试考试", "机试考试", "所在建筑物" };
neh.Export(dt, liststring, "考场信息");
return RedirectToAction("MsgShow", "Common", new
{
msg = "导出成功!",
url = Url.Content("~/ExaminationRoomSetting/List").AddMenuParameter()
});
}
///
/// 添加
///
///
///
[HttpPost]
public ActionResult Add(string classroomIDs)
{
try
{
var classroomIDList = classroomIDs.Split(',').Select(x => (Guid?)new Guid(x)).ToList();
RoomSettingServices.Add(classroomIDList);
return base.Json("添加成功");
}
catch (Exception ex)
{
return base.Json("添加失败,原因:" + ex.Message + "!");
}
}
///
/// 删除
///
///
///
[HttpPost]
public ActionResult Delete(string classroomIDs)
{
try
{
var classroomIDList = classroomIDs.Split(',').Select(x => (Guid?)new Guid(x)).ToList();
RoomSettingServices.Delete(classroomIDList);
return base.Json("删除成功");
}
catch (Exception ex)
{
return base.Json("删除失败,原因:" + ex.Message + "!");
}
}
}
}