using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EMIS.ViewModel;
using EMIS.CommonLogic.RetakeManage.General;
using EMIS.Utility.FormValidate;
using EMIS.CommonLogic.RetakeManage;
using EMIS.Web.Controls;
using Bowin.Web.Controls.Mvc;
using Bowin.Common.Utility;
using Bowin.Common.Data;
using EMIS.Utility;
namespace EMIS.Web.Controllers.RetakeManage.General
{
[Authorization]
public class RetakePlanStudentApplyController : Controller
{
public IRetakePlanStudentApplyServices RetakePlanStudentApplyServices { get; set; }
public IRetakeOpenControlServices IRetakeOpenControlServices { get; set; }
///
/// 进入报名页面(学生平台-网上报名版本)
///
///
public ActionResult List()
{
return View();
}
///
/// 进入报名页面列表查询(学生平台-网上报名版本)
///
///
///
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
Guid UserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID;
var schoolyearID = pararms.getExtraGuid("ddlSchoolYear");
var coursematerialID = pararms.getExtraGuid("CoursematerialComboGrid");
//报名状态
var generalPurposeID = pararms.getExtraInt("DictionaryGeneralPurpose") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGeneralPurpose");
return base.Json(RetakePlanStudentApplyServices.GetRetakePlanStudentApplyView(configuretView, UserID, schoolyearID,
coursematerialID, generalPurposeID, pararms.page, pararms.rows));
}
///
/// 查询重修报名时间
///
///
public ActionResult RetakeOpenControl(QueryParamsModel pararms)
{
try
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
var schoolyearID = pararms.getExtraGuid("ddlSchoolYear");
var retakeOpenTime = IRetakeOpenControlServices.GetRetakeApplyDateTime(schoolyearID);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = retakeOpenTime
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = ex.Message
});
}
}
///
/// 学生平台重修报名(注:1、检测重修开放时间,2、检测人数上限,3、检测重修课程重复,4、检测重修收费控制-暂时不考虑,5、检测排课冲突)
///
///
///
[HttpPost]
public ActionResult Apply(Guid RetakePlanStudentID)
{
try
{
this.RetakePlanStudentApplyServices.Apply(RetakePlanStudentID, CustomPrincipal.Current.UserID);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "报名成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "报名失败,原因:" + ex.Message + "。"
});
}
}
///
/// 学生平台重修取消报名(注:1、检测重修开放时间,2、取消报名控制-暂时不考虑)
///
///
///
[HttpPost]
public ActionResult CancelApply(Guid RetakePlanStudentID)
{
try
{
this.RetakePlanStudentApplyServices.CancleApply(RetakePlanStudentID, CustomPrincipal.Current.UserID);
return Json(new ReturnMessage
{
IsSuccess = true,
Message = "取消报名成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage
{
IsSuccess = false,
Message = "取消报名失败,原因:" + ex.Message + "。"
});
}
}
///
/// Excel导出(学生平台进入报名页面Excel导出)
///
///
[HttpPost]
public ActionResult Excel()
{
return null;
}
///
/// 重修课程页面(学生平台)
///
///
public ActionResult StudentRetakeCourseList()
{
return View();
}
///
/// 重修课程页面列表查询(学生平台)
///
///
///
[HttpPost]
public ActionResult StudentRetakeCourseList(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
Guid UserID = CustomPrincipal.Current.UserID;
var schoolyearID = pararms.getExtraGuid("ddlSchoolYear");
var coursematerialID = pararms.getExtraGuid("CoursematerialComboGrid");
//重修任务状态
var retakePlanStatusID = pararms.getExtraInt("DictionaryRetakePlanStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryRetakePlanStatus");
return base.Json(RetakePlanStudentApplyServices.GetStudentRetakeCourseView(configuretView, UserID, schoolyearID,
coursematerialID, retakePlanStatusID, pararms.page, pararms.rows));
}
///
/// Excel导出(学生平台重修课程页面Excel导出)
///
///
[HttpPost]
public ActionResult StudentRetakeCourse_Excel()
{
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
Guid UserID = CustomPrincipal.Current.UserID;
var schoolyearID = Request.Form["ddlSchoolYear"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["ddlSchoolYear"].ParseStrTo();
var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo();
//重修任务状态
var retakePlanStatusID = Request.Form["DictionaryRetakePlanStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryRetakePlanStatus"].ParseStrTo();
var dt = RetakePlanStudentApplyServices.GetStudentRetakeCourseView(configuretView, UserID, schoolyearID,
coursematerialID, retakePlanStatusID)
.Select(x => new
{
x.LoginID,
x.UserName,
x.SexName,
x.ClassmajorName,
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.DepartmentName,
x.CourseCollegeName,
x.RecordStatusName,
x.ApplyStatusName
}).ToTable();
string[] liststring = {
"学号", "姓名", "性别", "班级名称", "重修学年学期", "重修班级名称",
"重修类型", "课程代码", "课程名称", "课程类型", "课程学分", "总学时",
"起止周次", "上课时间", "教室", "任课教师", "开课教研室",
"开课" + RSL.Get("CollegeName"), "重修任务状态", "报名状态"
};
neh.Export(dt, liststring, "重修课程信息" + DateTime.Now.ToString("yyyyMMddhhmmss"));
return RedirectToAction("MsgShow", "Common", new
{
msg = "导出成功。",
url = Url.Content("~/RetakePlanStudentApply/StudentRetakeCourseList").AddMenuParameter()
});
}
}
}