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; }
///
/// 教室预留页面
///
///
public ActionResult List()
{
return View();
}
///
/// 教室预留查询列表
///
///
///
[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));
}
///
/// 编辑(新增、修改)
///
///
///
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);
}
///
/// 编辑(新增、修改)
///
///
///
[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
});
}
}
///
/// 教室预留批量新增
///
///
[HttpGet]
public ActionResult ClassroomReserveBatchAdd()
{
ClassroomReserveView classroomReserveView = new ClassroomReserveView();
return View(classroomReserveView);
}
///
/// 教室预留批量新增
///
///
///
public ActionResult ClassroomReserveBatchAdd(ClassroomReserveView classroomReserveView)
{
try
{
var classroomIDList = Request["classroomIDList"].JsonToObject>();
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
});
}
}
///
/// 查询未预留的教室信息ClassroomView
///
///
///
[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));
}
///
/// 删除
///
///
///
[HttpPost]
public ActionResult Delete(string classroomReserveIDs)
{
try
{
List 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 });
}
}
///
/// Excel导出
///
///
///
[HttpPost]
public ActionResult Excel()
{
try
{
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
var campusID = Request.Form["CampusDropdown"].ParseStrTo();
var buildingsID = Request.Form["BuildingsDropdown"].ParseStrTo();
//教室名称
var classroomName = Request.Form["ClassroomNameDropdown"].ToString();
//教室类型
var classroomTypeID = Request.Form["ClassroomTypeDictionary"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ClassroomTypeDictionary"].ParseStrTo();
//可否多班教学
var isConcurrentUse = Request.Form["IsConcurrentUseDropdown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["IsConcurrentUseDropdown"].ParseStrTo();
//是否可用
var isAvailable = Request.Form["IsAvailableDropdown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["IsAvailableDropdown"].ParseStrTo();
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
});
}
}
}
}