using Bowin.Common.Utility;
using Bowin.Web.Controls.Mvc;
using EMIS.CommonLogic.EducationManagement;
using EMIS.CommonLogic.EducationSchedule;
using EMIS.ViewModel;
using EMIS.Web.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Bowin.Common.Data;
using EMIS.CommonLogic.CalendarManage;
namespace EMIS.Web.Controllers.EducationSchedule
{
[Authorization]
public class EducationMissionClassScheduleController : Controller
{
public ISchoolYearServices SchoolYearServices { get; set; }
//任务班排课
#region 0.0--定义--
public IEducationMissionClassScheduleServices educationMissionClassScheduleServices { get; set; }
#endregion
#region 1.0 任务班排课列表数据加载
public ActionResult List()
{
var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();//默认当前学年
return View();
}
///
/// 查询任务班排课列表
///
///
///
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
var schoolyearID = pararms.getExtraGuid("SchoolyearDropdownList");
var coursematerialID = pararms.getExtraGuid("CoursematerialComboGrid");
var campusID = pararms.getExtraGuid("ComboGridCampus");
var collegeID = pararms.getExtraGuid("ComboGridCollege");
var StandardID = pararms.getExtraInt("DictionaryStandard");
var departmentID = pararms.getExtraGuid("DepartmentDropdown");
var grademajorID = pararms.getExtraGuid("GrademajorComboGrid");
var gradeYearID = pararms.getExtraInt("DictionaryGrade") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGrade");
var approvalStatus = pararms.getExtraInt("ApprovalStatusDropdownList") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ApprovalStatusDropdownList");
var teachingMode = pararms.getExtraInt("DictionaryTeachingMode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryTeachingMode");
var result = educationMissionClassScheduleServices.GetEducationMissionClassScheduleViewGrid(configuretView, campusID, collegeID, schoolyearID, departmentID, coursematerialID, approvalStatus, teachingMode, grademajorID, gradeYearID, StandardID, (int)pararms.page, (int)pararms.rows);
return Json(result);
}
#endregion
#region 2.0 Excel导出
///
/// 导出Excel
///
///
///
[HttpPost]
public ActionResult Excel()
{
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
var campusID = Request.Form["ComboGridCampus"].ParseStrTo();
var collegeID = Request.Form["ComboGridCollege"].ParseStrTo();
var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo();
var grademajorID = Request.Form["GrademajorComboGrid"].ParseStrTo();
var gradeYearID = Request.Form["DictionaryGrade"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo();
var schoolyearID = Request.Form["SchoolyearDropdownList"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDropdownList"].ParseStrTo();
var approvalStatus = Request.Form["ApprovalStatusDropdownList"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ApprovalStatusDropdownList"].ParseStrTo();
var teachingModeID = Request.Form["DictionaryTeachingMode"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryTeachingMode"].ParseStrTo();
var dt = educationMissionClassScheduleServices.GetEducationMissionClassScheduleViewList(configuretView, campusID, collegeID, schoolyearID, null, coursematerialID,
approvalStatus, teachingModeID, grademajorID, gradeYearID).Select(x => new
{
x.OrderNo,
x.Name,
// x.SchoolyearCode,
x.CourseCode,
x.CourseName,
x.DepartmentName,
// x.CollegeName,
x.ClassroomTypeName,
x.StartStopWeeklyNum,
x.Totalhours,
x.CourseProcessTimes,
x.ScheduledTimes,
//x.SchedulingClassNum,
x.ClassNum,
x.TeacherName,
x.ApprovalStatusName
}).ToTable();
string[] liststring = { "排课序号", "任务班名称","课程代码", "课程名称", "教研室", "教室类型",
"执行周次", "总学时", "执行学时","已排学时", "班级人数","授课老师", "状态" };
neh.Export(dt, liststring, "教学任务班基础信息");
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "导出成功!"
});
}
#endregion
#region 3.0 删除排课信息
[HttpPost]
public ActionResult Delete(string educationMissionClassIDs)
{
try
{
List list = new List();
var educationMissionClassArray = educationMissionClassIDs.Split(',');
for (int i = 0; i < educationMissionClassArray.Length; i++)
{
if (!string.IsNullOrEmpty(educationMissionClassArray[i]))
{
Guid? educationMissionClassID = new Guid(educationMissionClassArray[i]);
list.Add(educationMissionClassID);
}
}
educationMissionClassScheduleServices.Delete(list);
return Json(new ReturnMessage { IsSuccess = true, Message = "撤销成功 " });
}
catch (Exception ex)
{
return Json(new ReturnMessage { IsSuccess = false, Message = "撤销失败:" + ex.Message });
}
}
#endregion
}
}