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 RetakePlanResultTaskController : Controller
{
public IRetakePlanTaskServices RetakePlanTaskServices { get; set; }
public IRetakePlanResultServices RetakePlanResultTaskServices { 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(RetakePlanResultTaskServices.GetRetakePlanResultTaskView(configuretView, schoolyearID, collegeID, departmentID,
coursematerialID, retakeTypeID, statusID, (int)pararms.page, (int)pararms.rows));
}
///
/// 编辑
///
///
///
public ActionResult Edit(Guid? retakePlanID)
{
RetakePlanTaskSettingView retakePlanTaskView = new RetakePlanTaskSettingView();
if (retakePlanID != Guid.Empty && retakePlanID.HasValue)
{
retakePlanTaskView = RetakePlanTaskServices.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");
RetakePlanTaskServices.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
});
}
}
}
///
/// 开班(重修计划)
///
///
///
[HttpPost]
public ActionResult Generate(string RetakePlanIDs)
{
try
{
string result = RetakePlanResultTaskServices.RetakePlanResultGenerate(RetakePlanIDs);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "" + result + "。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "开班失败,原因:" + ex.Message + "。"
});
}
}
///
/// 重修计划名单列表信息
///
///
public ActionResult StudentPlanDetail()
{
return View();
}
///
/// 重修计划名单列表信息
///
///
///
[HttpPost]
public ActionResult StudentPlanDetail(QueryParamsModel pararms)
{
var retakePlanID = Request["RetakePlanID"].ParseStrTo();
return Json(RetakePlanTaskServices.GetRetakePlanTaskStudentView(retakePlanID, (int)pararms.page, (int)pararms.rows));
}
///
/// 重修计划名单Excel导出
///
///
///
[HttpPost]
public ActionResult StudentPlanDetail_Excel(QueryParamsModel pararms)
{
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
var retakePlanID = Request["RetakePlanID"].ParseStrTo();
var dt = RetakePlanTaskServices.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("~/RetakePlanResultTask/List").AddMenuParameter()
});
}
///
/// 检测重修报名人数是否超过人数下限和人数上限范围
///
///
///
[HttpPost]
public ActionResult IsOverRange(string retakePlanIDs)
{
try
{
var result = RetakePlanResultTaskServices.IsOverRange(retakePlanIDs);
return Json(new ReturnMessage()
{
IsSuccess = true,
Data = result
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Data = false,
Message = ex.Message
});
}
}
///
/// 查询对应的重修班级报名名单
///
///
public ActionResult StudentDetail()
{
return View();
}
///
/// 查询对应的重修班级报名名单
///
///
///
[HttpPost]
public ActionResult StudentDetail(QueryParamsModel pararms)
{
var retakePlanID = Request["RetakePlanID"].ParseStrTo();
return Json(RetakePlanResultTaskServices.GetRetakePlanResultTaskStudentView(retakePlanID, (int)pararms.page, (int)pararms.rows));
}
///
/// 重修班级报名名单报名(从计划人数中选择)
///
///
public ActionResult StudentSelect()
{
var retakePlanID = Request["RetakePlanID"].ParseStrTo();
ViewBag.RetakePlanID = retakePlanID;
return View();
}
///
/// 重修班级报名名单报名(从计划人数中选择)
///
///
///
///
[HttpPost]
public ActionResult StudentSelect(RetakePlanTaskView retakePlanTaskView, string UserIDs)
{
try
{
string result = RetakePlanResultTaskServices.AddStudent(retakePlanTaskView.RetakePlanID, retakePlanTaskView.UserIDs);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "报名成功" + result + "。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "报名失败,原因:" + ex.Message + "。"
});
}
}
///
/// 查询对应的重修班级未报名名单列表(未报名名单)
///
///
///
[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(RetakePlanResultTaskServices.GetStudentView(configuretView, retakePlanID, gradeYearID, standardID,
classmajorID, inSchoolStatus, (int)pararms.page, (int)pararms.rows));
}
///
/// 删除(重修报名名单删除,取消报名)
///
///
///
///
[HttpPost]
public ActionResult DeleteStudent(string retakePlanID, string UserIDs)
{
try
{
Guid ID = new Guid(retakePlanID);
RetakePlanResultTaskServices.DeleteStudent(ID, UserIDs);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "取消报名成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "取消报名失败,原因:" + ex.Message
});
}
}
///
/// 重修班级报名名单Excel导出
///
///
[HttpPost]
public ActionResult StudentDetailt_Excel()
{
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
var retakePlanID = Request["RetakePlanID"].ParseStrTo();
var dt = RetakePlanResultTaskServices.GetRetakePlanResultTaskStudentViewList(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()
});
}
///
/// 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 = RetakePlanResultTaskServices.GetRetakePlanResultTaskViewList(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.ApplyNumber,
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()
});
}
}
}