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 EMIS.CommonLogic.EducationSchedule; using EMIS.ViewModel; using EMIS.Web.Controls; using EMIS.Utility; using EMIS.ViewModel.EducationSchedule; using Bowin.Common.Linq.Entity; using EMIS.CommonLogic.CalendarManage; namespace EMIS.Web.Controllers.EducationSchedule { [Authorization] public class ClassroomExcessiveUseController : Controller { public ISchoolYearServices SchoolYearServices { get; set; } public IClassroomExcessiveUseServices ClassroomExcessiveUseServices { get; set; } public ActionResult List() { return View(); } public ActionResult Edit(Guid? classroomExecessiveUseID) { ClassroomExcessiveUseView model; if (classroomExecessiveUseID.HasValue) { model = ClassroomExcessiveUseServices.GetClassroomExcessiveUseView(classroomExecessiveUseID.Value); } else { model = new ClassroomExcessiveUseView(); model.SchoolyearID = BaseExtensions.GetCurrentSchoolYearID(); } return View(model); } public ActionResult SchedulingEdit(Guid? schoolyearID, Guid? classroom) { var weekNumList = SchoolYearServices.GetCurrentSchoolyearWeekNumList(); List lctWeekNum = new List(); for (int i = 1; i <= weekNumList.Count; i++) { ListControlItem lt = new ListControlItem { Text = i.ToString(), Value = i, IsSelected = true }; lctWeekNum.Add(lt); } ViewBag.WeekList = lctWeekNum; ViewBag.SchoolyearID = schoolyearID; ViewBag.ClassroomID = classroom; return View(); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("ddlSchoolyear"); var weekNum = pararms.getExtraInt("ddlWeekNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlWeekNum"); var weekday = pararms.getExtraInt("ddlWeekday") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlWeekday"); var courseTimeID = pararms.getExtraGuid("cbgCoursesTime"); var collegeID= pararms.getExtraGuid("CollegeComboGrid"); var buildingID = pararms.getExtraGuid("cbgBuilding"); var classroomID = pararms.getExtraGuid("cbgClassroom"); var result = ClassroomExcessiveUseServices.GetClassroomExcessiveUseViewList(configuretView, schoolyearID, weekNum, weekday, courseTimeID, buildingID, classroomID, collegeID, (int)pararms.page, (int)pararms.rows); return Json(result); } [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var schoolyearID = Request.Form["ddlSchoolyear"].ParseStrTo(); var weekNum = Request.Form["ddlWeekNum"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlWeekNum"].ParseStrTo(); var weekday = Request.Form["ddlWeekday"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlWeekday"].ParseStrTo(); var courseTimeID = Request.Form["cbgCoursesTime"].ParseStrTo(); var buildingID = Request.Form["cbgBuilding"].ParseStrTo(); var classroomID = Request.Form["cbgClassroom"].ParseStrTo(); var collegeID = Request.Form["CollegeComboGrid"].ParseStrTo(); var dt = ClassroomExcessiveUseServices.GetClassroomExcessiveUseViewList(configuretView, schoolyearID, weekNum, weekday, courseTimeID, buildingID, classroomID, collegeID) .Select(x => new { x.SchoolyearCode, x.ClassroomName, x.CollegeName, x.UserName, x.Content, x.Scheduling }).ToTable(); string[] liststring = { "学年学期", "教室", RSL.Get("UsingCollege"), "使用人", "活动内容", "时间安排" }; neh.Export(dt, liststring, "课外教室使用登记表"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Content("~/Students/List").AddMenuParameter() }); } [HttpPost] public ActionResult Delete(string classroomExcessiveUseIDs) { try { List idList = classroomExcessiveUseIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); ClassroomExcessiveUseServices.Delete(idList); return Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + ex.Message }); } } [HttpPost] public ActionResult SchedulingList(Guid? classroomExcessiveUseID) { if (!classroomExcessiveUseID.HasValue) { return Json(new GridResultSet { rows = new List(), total = 0 }); } else { var schedulingList = ClassroomExcessiveUseServices.GetClassroomExcessiveUseSchedulingViewList(classroomExcessiveUseID.Value); return Json(new GridResultSet { rows = schedulingList, total = schedulingList.Count }); } } [HttpPost] public ActionResult Edit(ClassroomExcessiveUseView model) { var schedulingList = DataGrid.GetTableData("dgSchedulingList"); try { if (schedulingList.Count <= 0) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:时间安排不能为空。" }); } else { ClassroomExcessiveUseServices.Save(model, schedulingList); return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" }); } } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } [HttpPost] public ActionResult GetCourseTimeOnlyUsable(QueryParamsModel pararms) //, Guid schoolYearID,IList schedulingWeekList, int weekday, Guid classroomID) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolYearID = pararms.getExtraGuid("schoolyearID"); var weekNumList = pararms.getExtraString("weekNumList"); var schedulingWeekList = weekNumList.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => x.ParseStrTo()).ToList(); var weekday = pararms.getExtraInt("weekDay") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("weekDay"); var classroomID = pararms.getExtraGuid("classroomID"); var result = ClassroomExcessiveUseServices.GetCoursesTimeViewGrid(configuretView, schoolYearID.Value, schedulingWeekList, weekday.Value, classroomID.Value, (int)pararms.page, (int)pararms.rows); return Json(result); } } }