using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EMIS.ViewModel;
using EMIS.Web.Controls;
using Bowin.Web.Controls.Mvc;
using EMIS.CommonLogic.RetakeManage;
using Bowin.Common.Utility;
using Bowin.Common.Data;
using EMIS.CommonLogic.RetakeManage.General;
using EMIS.ViewModel.RetakeManage;
using EMIS.Utility.FormValidate;
using Bowin.Common.Linq.Entity;
using Bowin.Common.JSON;
using EMIS.Utility;
namespace EMIS.Web.Controllers.RetakeManage.General
{
[Authorization]
public class RetakePlanTaskController : Controller
{
public IRetakePlanTaskServices RetakePlanServices { get; set; }
///
/// 重修任务页面
///
///
public ActionResult List()
{
return View();
}
///
/// 重修任务列表查询
///
///
///
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
var schoolyearID = pararms.getExtraGuid("SchoolYearDropdown").ToString() == DropdownList.SELECT_ALL.ToString() ? null : pararms.getExtraGuid("SchoolYearDropdown");
//开课院系所
var collegeID = pararms.getExtraGuid("CollegeDropdown");
//开课教研室
var departmentID = pararms.getExtraGuid("DepartmentComboGrid");
var coursematerialID = pararms.getExtraGuid("CoursematerialComboGrid");
var retakeTypeID = pararms.getExtraInt("DictionaryRetakeType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryRetakeType");
var statusID = pararms.getExtraInt("DictionaryStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStatus");
return Json(RetakePlanServices.GetRetakePlanTaskView(configuretView, schoolyearID, collegeID, departmentID, coursematerialID,
retakeTypeID, statusID, (int)pararms.page, (int)pararms.rows));
}
///
/// 重修任务分班
///
///
///
public ActionResult DivideIntoClassesEdit(Guid? retakePlanID)
{
RetakeDivideIntoClassesView divideIntoClassesView = new RetakeDivideIntoClassesView();
if (retakePlanID != Guid.Empty && retakePlanID.HasValue)
{
divideIntoClassesView = RetakePlanServices.GetDivideIntoClassesView(retakePlanID);
ViewBag.StudentTotalNum = divideIntoClassesView.StudentTotalNum;
}
return View(divideIntoClassesView);
}
///
/// 重修任务分班
///
///
///
[HttpPost]
public ActionResult DivideIntoClassesEdit(RetakeDivideIntoClassesView divideIntoClassesView)
{
try
{
divideIntoClassesView.GroupNum = Convert.ToInt32(Request.Form["hid_GroupNum"]);
divideIntoClassesView.StudentNum = Convert.ToInt32(Request.Form["hid_StudentNum"]);
divideIntoClassesView.StudentTotalNum = Convert.ToInt32(Request.Form["hid_StudentTotalNum"]);
RetakePlanServices.DivideIntoClassesSeparate(divideIntoClassesView);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "分班成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "分班失败,原因:" + ex.Message
});
}
}
///
/// 编辑
///
///
///
public ActionResult Edit(Guid? retakePlanID)
{
RetakePlanTaskSettingView retakePlanTaskView = new RetakePlanTaskSettingView();
if (retakePlanID != Guid.Empty && retakePlanID.HasValue)
{
retakePlanTaskView = RetakePlanServices.GetRetakePlanTaskUpdateView(retakePlanID);
//处理方式(暂时无效)
retakePlanTaskView.HandleModeID = retakePlanTaskView.HandleModeID.HasValue ?
retakePlanTaskView.HandleModeID : (int)EMIS.ViewModel.CF_HandleMode.RequiredCourse;
//重修任务状态标识
ViewBag.Status = retakePlanTaskView.RecordStatus;
}
else
{
retakePlanTaskView.ExaminationModeID = (int)CF_ExaminationMode.WrittenExam;
retakePlanTaskView.IsRequired = true;
retakePlanTaskView.PeopleNumlimit = 0;
retakePlanTaskView.PeopleNumlower = 0;
}
return View(retakePlanTaskView);
}
///
/// 编辑
///
///
///
[HttpPost]
public ActionResult Edit(RetakePlanTaskSettingView retakePlanTaskSettingView)
{
int? type = 0;
try
{
//排课明细列表
var schedulingList = DataGrid.GetTableData("dgSchedulingList");
//任课教师列表
var teacherList = DataGrid.GetTableData("dgTeacherList");
RetakePlanServices.RetakePlanTaskSet(retakePlanTaskSettingView, teacherList, schedulingList, out type);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "保存成功。"
});
}
catch (Exception ex)
{
//如果验证到排课冲突type返回1,页面js根据type弹出选择框
//用户可选择继续保存或不保存,如果不返回1,弹出一般的错误提示框
if (type == 1)
{
return Json(new ReturnMessage()
{
Type = 1,
IsSuccess = false,
Message = "保存失败:" + ex.Message
});
}
else
{
return Json(new ReturnMessage()
{
Type = 2,
IsSuccess = false,
Message = "保存失败:" + ex.Message
});
}
}
}
///
/// 删除(需要检测是否存在对应的已报名重修计划名单,根据重修计划ID)
///
///
///
[HttpPost]
public ActionResult Delete(string RetakePlanIDs)
{
try
{
List list = RetakePlanIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
.Select(x => (Guid?)new Guid(x)).ToList();
RetakePlanServices.DeleteRetakePlanTask(list);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "删除成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "删除失败,原因:" + ex.Message
});
}
}
///
/// 检测是否存在对应的已报名重修计划名单(根据重修计划ID)
///
///
///
[HttpPost]
public ActionResult IsExistsApplyStudentByRetakePlanID(string retakePlanIDs)
{
try
{
var result = RetakePlanServices.IsExistsApplyStudentByRetakePlanID(retakePlanIDs);
return Json(new ReturnMessage
{
IsSuccess = true,
Data = result
});
}
catch (Exception ex)
{
return Json(new ReturnMessage
{
IsSuccess = false,
Data = false,
Message = ex.Message
});
}
}
///
/// 重修计划取消开放(删除对应的重修计划报名名单)
///
///
///
[HttpPost]
public ActionResult CancleOpen(string RetakePlanIDs)
{
try
{
List list = RetakePlanIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
.Select(x => (Guid?)new Guid(x)).ToList();
RetakePlanServices.CancleRetakePlanTask(list);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "取消开放成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "取消开放失败,原因:" + ex.Message
});
}
}
///
/// 重修计划开放
///
///
///
[HttpPost]
public ActionResult Open(string RetakePlanIDs)
{
try
{
List list = RetakePlanIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
.Select(x => (Guid?)new Guid(x)).ToList();
RetakePlanServices.OpenRetakePlanTask(list);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "开放成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "开放失败,原因:" + ex.Message
});
}
}
///
/// 排课明细
///
///
///
public ActionResult GetSchedulingViewList(Guid? RetakePlanID)
{
var schedulingViewList = RetakePlanServices.GetSchedulingView(RetakePlanID);
return Json(new GridResultSet { rows = schedulingViewList, total = schedulingViewList.Count });
}
///
/// 任课教师
///
///
///
public ActionResult TeacherList(Guid? RetakePlanID)
{
var teacherListView = RetakePlanServices.GetTeacherListView(RetakePlanID);
return base.Json(new GridResultSet() { rows = teacherListView, total = teacherListView.Count });
}
///
/// 授课方式
///
///
///
public ActionResult TeachingModeType(Guid? RetakePlanID)
{
List list = new List();
if (RetakePlanID != Guid.Empty && RetakePlanID.HasValue)
{
list = RetakePlanServices.GetTeachingModeType(RetakePlanID);
}
else
{
list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory));
}
return base.Json(list.ConvertAll(x => x.ToString()));
}
///
/// 授课地点
///
///
///
public ActionResult TeachingPlace(Guid? RetakePlanID)
{
List list = new List();
if (RetakePlanID != Guid.Empty && RetakePlanID.HasValue)
{
list = RetakePlanServices.GetTeachingPlace(RetakePlanID);
}
return base.Json(list.ConvertAll(x => x.ToString()));
}
///
/// 重修计划名单列表信息
///
///
public ActionResult StudentDetail()
{
return View();
}
///
/// 重修计划名单列表信息
///
///
///
[HttpPost]
public ActionResult StudentDetail(QueryParamsModel pararms)
{
var retakePlanID = Request["RetakePlanID"].ParseStrTo();
return Json(RetakePlanServices.GetRetakePlanTaskStudentView(retakePlanID, (int)pararms.page, (int)pararms.rows));
}
///
/// 重修计划名单添加
///
///
public ActionResult StudentSelect()
{
var RetakePlanID = Request["RetakePlanID"].ParseStrTo();
ViewBag.RetakePlanID = RetakePlanID;
return View();
}
///
/// 重修计划名单添加
///
///
///
///
[HttpPost]
public ActionResult StudentSelect(string finallyScoreIDs, RetakePlanTaskView retakePlanTaskView)
{
try
{
//最终成绩信息IDList
var finallyScoreIDList = finallyScoreIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
.Select(x => (Guid?)new Guid(x)).ToList();
RetakePlanServices.AddStudent(retakePlanTaskView.RetakePlanID, finallyScoreIDList);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "添加成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "添加失败,原因:" + ex.Message
});
}
}
///
/// 查询对应的重修计划名单列表(不需排除已在其它相应的重修计划中存在的名单,不及格成绩,小于60分)
///
///
///
[HttpPost]
public ActionResult BaseStudentViewList(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
var retakePlanID = new Guid(Request["RetakePlanID"]);
var gradeYearID = pararms.getExtraInt("ddlYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear");
var standardID = pararms.getExtraInt("cbgStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("cbgStandard");
var classmajorID = pararms.getExtraGuid("cbgClassmajor");
//在校状态
var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
return Json(RetakePlanServices.GetStudentView(configuretView, retakePlanID, gradeYearID, standardID,
classmajorID, inSchoolStatus, (int)pararms.page, (int)pararms.rows));
}
///
/// 删除(重修计划名单删除,根据重修计划名单ID)
///
///
///
[HttpPost]
public ActionResult DeleteStudent(string retakePlanStudentIDs)
{
try
{
List list = retakePlanStudentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
.Select(x => (Guid?)new Guid(x)).ToList();
RetakePlanServices.DeleteStudent(list);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "删除成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "删除失败,原因:" + ex.Message
});
}
}
///
/// 检测是否存在对应的已报名重修计划名单(根据重修计划ID)
///
///
///
[HttpPost]
public ActionResult IsExistsApplyStudentByRetakePlanStudentID(string retakePlanStudentIDs)
{
try
{
var result = RetakePlanServices.IsExistsApplyStudentByRetakePlanStudentID(retakePlanStudentIDs);
return Json(new ReturnMessage
{
IsSuccess = true,
Data = result
});
}
catch (Exception ex)
{
return Json(new ReturnMessage
{
IsSuccess = false,
Data = false,
Message = ex.Message
});
}
}
///
/// 重修计划名单Excel导出
///
///
///
[HttpPost]
public ActionResult StudentDetail_Excel(QueryParamsModel pararms)
{
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
var retakePlanID = Request["RetakePlanID"].ParseStrTo();
var dt = RetakePlanServices.GetRetakePlanTaskStudentViewList(configuretView, retakePlanID)
.Select(x => new
{
x.SchoolyearCode,
x.ClassName,
x.RecordStatusName,
x.RetakeTypeName,
x.LoginID,
x.UserName,
x.SexName,
x.InSchoolStatusName,
x.StudentStatusName,
x.ClassmajorCode,
x.ClassmajorName,
x.GrademajorCode,
x.GrademajorName,
x.CourseCode,
x.CourseName,
x.CourseTypeDesc,
x.CourseCredit,
x.Totalhours,
x.SchoolyearNumDesc,
x.StarttermDesc,
x.DepartmentCode,
x.DepartmentName,
x.ApplyStatusName
}).ToTable();
string[] liststring = {
"重修学年学期", "重修班级名称", "重修任务状态", "重修类型", "学号", "姓名", "性别", "在校状态",
"学籍状态", "班级编号", "班级名称", "年级专业编号", "年级专业名称", "课程代码", "课程名称",
"课程类型", "课程学分", "总学时", "开课学年", "开课学期", "开课教研室代码", "开课教研室名称",
"报名状态"
};
neh.Export(dt, liststring, "重修计划名单信息" + DateTime.Now.ToString("yyyyMMddhhmmss"));
return RedirectToAction("MsgShow", "Common", new
{
msg = "导出成功。",
url = Url.Content("~/RetakePlanTask/List").AddMenuParameter()
});
}
///
/// 添加节次(排课检查)
///
///
public ActionResult CoursesTimeList()
{
return View();
}
///
/// 添加教室(排课检查)
///
///
public ActionResult CourseProcessClassroomList()
{
return View();
}
///
/// 添加教室(排课冲突检查,列出课程进度中的可选教室)
///
///
///
[HttpPost]
public ActionResult GetCourseProcessClassroomList(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
int? classroomType = pararms.getExtraString("ClassroomType").ParseStrTo() == DropdownList.SELECT_ALL ? null : pararms.getExtraString("ClassroomType").ParseStrTo();
string schedulingWeek = pararms.getExtraString("schedulingWeek");
int? weekday = pararms.getExtraString("weekDay").ParseStrTo() == DropdownList.SELECT_ALL ? null : pararms.getExtraString("weekDay").ParseStrTo();
var coursesTimeID = pararms.getExtraGuid("coursesTimeID") ?? Guid.Empty;
//int? minSeatCount = pararms.getExtraString("MinSeatCount").ParseStrTo() == DropdownList.SELECT_ALL ? null : pararms.getExtraString("MinSeatCount").ParseStrTo();
//var collegeID = pararms.getExtraGuid("CollegeDropdown") ?? Guid.Empty;
var schoolYearID = pararms.getExtraGuid("SchoolYearID") ?? Guid.Empty;
var buildingsID = pararms.getExtraInt("BuildingsDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraGuid("BuildingsDropdown");
return base.Json(RetakePlanServices.GetAvailableClassroom(configuretView, buildingsID, schedulingWeek, weekday, coursesTimeID, classroomType, schoolYearID, (int)pararms.page, (int)pararms.rows));
}
///
/// Excel导出
///
///
[HttpPost]
public ActionResult Excel()
{
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
var schoolyearID = Request.Form["SchoolYearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["SchoolyearDropdown"].ParseStrTo();
//开课院系所
var collegeID = Request.Form["CollegeDropdown"].ParseStrTo();
//开课教研室
var departmentID = Request.Form["DepartmentComboGrid"].ParseStrTo();
var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo();
var retakeTypeID = Request.Form["DictionaryRetakeType"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryRetakeType"].ParseStrTo();
var statusID = Request.Form["DictionaryStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStatus"].ParseStrTo();
var dt = RetakePlanServices.GetRetakePlanTaskViewList(configuretView, schoolyearID, collegeID, departmentID,
coursematerialID, retakeTypeID, statusID)
.Select(x => new
{
x.SchoolyearCode,
x.ClassName,
x.RetakeTypeName,
x.CourseCode,
x.CourseName,
x.CourseTypeName,
x.Credit,
x.Totalhours,
x.StartEndWeeklyNum,
x.WeekdayTimesSegmentName,
x.ClassroomName,
x.TeacherName,
x.PeopleNumlower,
x.PeopleNumlimit,
x.DepartmentName,
x.CourseCollegeName,
x.PlanNumber,
x.RecordStatusName
}).ToTable();
string[] liststring = {
"重修学年学期", "重修班级名称", "重修类型", "课程代码", "课程名称", "课程类型", "课程学分",
"总学时", "起止周次", "上课时间", "教室", "任课教师", "人数下限", "人数上限","开课教研室",
"开课" + RSL.Get("CollegeName"), "计划人数", "重修任务状态"
};
neh.Export(dt, liststring, "重修任务信息" + DateTime.Now.ToString("yyyyMMddhhmmss"));
return RedirectToAction("MsgShow", "Common", new
{
msg = "导出成功。",
url = Url.Content("~/RetakePlanTask/List").AddMenuParameter()
});
}
}
}