using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Bowin.Web.Controls.Mvc;
using EMIS.Entities;
using EMIS.ViewModel;
using EMIS.ViewModel.CalendarManage;
using EMIS.CommonLogic.SchedulingManage.SchedulingSettings;
using EMIS.CommonLogic.UniversityManage.ClassroomManage;
namespace EMIS.Web.Controllers.SchedulingManage.SchedulingSettings
{
[Authorization]
public class ClassroomScheduleSettingController : Controller
{
public IClassroomScheduleSettingServices classroomScheduleSettingServices { get; set; }
public IClassroomServices classroomServices { get; set; }
///
///
///
///
public ActionResult List()
{
return View();
}
///
/// 教室可排时间设置列表
///
///
///
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
var classroomID = pararms.getExtraGuid("ClassroomComboGrid");
var collegeID = pararms.getExtraGuid("CollegeComboGrid");
var classroomTypeID = pararms.getExtraInt("DictionaryClassroomType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryClassroomType");
return Json(classroomScheduleSettingServices.GetClassroomScheduleSettingViewGrid(classroomID, collegeID, classroomTypeID, (int)pararms.page, (int)pararms.rows));
}
///
/// 设置
///
///
///
public ActionResult Edit(Guid? classroomID)
{
CF_Classroom classroom = classroomServices.GetClassroomInfo(classroomID);
return View(classroom);
}
///
/// 保存
///
///
[HttpPost]
public ActionResult Edit()
{
try
{
Guid? classroomID = new Guid(Request.Form["ClassroomID"]);
var arrangementsList = DataGrid.GetTableData("dgArrangementsList");
classroomScheduleSettingServices.ClassroomScheduleSettingAdd(arrangementsList, classroomID);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "保存成功!"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "保存失败,原因:" + ex.Message + "!"
});
}
}
///
/// 删除
///
///
///
[HttpPost]
public ActionResult Delete(string classroomIDs)
{
try
{
List list = new List();
for (int i = 0; i < classroomIDs.Split(',').Length; i++)
{
if (!string.IsNullOrEmpty(classroomIDs.Split(',')[i]))
{
Guid classroomID = new Guid(classroomIDs.Split(',')[i]);
list.Add(classroomID);
}
}
classroomScheduleSettingServices.ClassroomScheduleSettingDelete(list);
return Json("删除成功");
}
catch (Exception ex)
{
return Json("删除失败,原因:" + ex.Message);
}
}
///
/// 查看是否设置的排课时间
///
///
///
[HttpPost]
public ActionResult ArrangementsList(Guid? classroomID)
{
return Json(classroomScheduleSettingServices.GetArrangementViewGrid(classroomID));
}
}
}