using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Bowin.Common.Utility; using Bowin.Common.Data; using Bowin.Web.Controls.Mvc; using EMIS.ViewModel; using EMIS.Web.Controls; using EMIS.CommonLogic.ScoreManage; using EMIS.Utility.FormValidate; using EMIS.ViewModel.ScoreManage; using EMIS.ViewModel.WorkflowManage; using Bowin.Common.JSON; namespace EMIS.Web.Controllers.ScoreManage { [Authorization] public class ExaminationSuspensionController : Controller { public IExaminationSuspensionServices ExaminationSuspensionServices { get; set; } /// /// 缓考名单页面 /// /// public ActionResult List() { ViewBag.StartStatusID = this.ExaminationSuspensionServices.GetStartStatus(); return View(); } public ActionResult StudentList() { ViewBag.StartStatusID = ExaminationSuspensionServices.GetStartStatus(); return View(); } public ActionResult Edit(Guid? examinationSuspensionID) { ExaminationSuspensionView examinationSuspensionView = new ExaminationSuspensionView(); if (examinationSuspensionID.HasValue) { examinationSuspensionView = this.ExaminationSuspensionServices.GetExaminationSuspensionView(examinationSuspensionID.Value); } else { //默认值 examinationSuspensionView.ExamsCategoryID = (int)EMIS.ViewModel.CF_ExamsCategory.FinalExam; } return View(examinationSuspensionView); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("ddlSchoolYear"); var collegeID = pararms.getExtraGuid("cbgCollege"); var yearID = 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 examsCategoryID = pararms.getExtraInt("ddlExamsCategory") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlExamsCategory"); var recordstatus = pararms.getExtraInt("ddlRecordStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlRecordStatus"); var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown"); var education = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation"); var LearnSystem = pararms.getExtraString("DictionaryLearnSystem"); return Json(ExaminationSuspensionServices.GetExaminationSuspensionGridView(configuretView, schoolyearID, collegeID, yearID, standardID, classmajorID, examsCategoryID, recordstatus,learningformID,education,LearnSystem, (int)pararms.page, (int)pararms.rows)); } /// /// 导出Excel /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var schoolyearID = Request.Form["ddlSchoolYear"].ParseStrTo(); var collegeID = Request.Form["cbgCollege"].ParseStrTo(); var yearID = Request.Form["ddlYear"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlYear"].ParseStrTo(); var standardID = Request.Form["cbgStandard"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["cbgStandard"].ParseStrTo(); var classmajorID = Request.Form["cbgClassmajor"].ParseStrTo(); var examsCategoryID = Request.Form["ddlExamsCategory"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlExamsCategory"].ParseStrTo(); var recordstatus = Request.Form["ddlRecordStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlRecordStatus"].ParseStrTo(); var learningformID = Request.Form["LearningformDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["LearningformDictionaryDropDown"].ParseStrTo(); var education = Request.Form["DictionaryEducation"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo(); var LearnSystem = Request.Form["DictionaryLearnSystem"].ToString(); var dt = ExaminationSuspensionServices.GetExaminationSuspensionViewList(configuretView, schoolyearID, collegeID, yearID, standardID, classmajorID, examsCategoryID, recordstatus, learningformID, education, LearnSystem).Select(x => new { x.LoginID, x.Name, x.ClassmajorName, x.SchoolyearCode, x.CourseCode, x.CourseName, x.ExamsCategoryName, CreateTime = x.CreateTime.ToStringEx("yyyy-MM-dd"), x.RecordStatusName }).ToTable(); string[] liststring = { "学号", "姓名", "班级", "学年学期", "课程代码","课程名称","考试性质", "申请日期", "状态" }; neh.Export(dt, liststring, "缓考名单"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Action("List").AddMenuParameter() }); } [HttpPost] public ActionResult StudentList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); return Json(ExaminationSuspensionServices.GetExaminationSuspensionStudentGridView(configuretView, CustomPrincipal.Current.UserID, (int)pararms.page, (int)pararms.rows)); } [HttpPost] public ActionResult GetCoursematerial(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); return Json(ExaminationSuspensionServices.GetExaminationSuspensionCoursematerialGridView(configuretView, (int)pararms.page, (int)pararms.rows)); } [HttpPost] public ActionResult GetCoursematerialForTeacher(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var UserID = pararms.getExtraGuid("UserID"); return Json(ExaminationSuspensionServices.GetExaminationSuspensionCoursematerialGridViewForTeacher(configuretView, UserID, (int)pararms.page, (int)pararms.rows)); } [HttpPost] public ActionResult Edit(ExaminationSuspensionView examinationSuspensionView) { try { examinationSuspensionView.UserID = CustomPrincipal.Current.UserID; examinationSuspensionView.SchoolyearID = BaseExtensions.GetCurrentSchoolYearID(); examinationSuspensionView.ExamsCategoryID = (int)CF_ExamsCategory.FinalExam; this.ExaminationSuspensionServices.Save(examinationSuspensionView); return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } [HttpPost] public ActionResult Cancel(string examinationSuspensionIDs, string comment) { var examinationSuspensionIDList = examinationSuspensionIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); var curUserID = CustomPrincipal.Current.UserID; if (examinationSuspensionIDList.Count == 0) { return Json(new ReturnMessage { IsSuccess = false, Message = "请选择至少一条记录进行撤销。" }); } try { this.ExaminationSuspensionServices.Cancel(examinationSuspensionIDList, curUserID, comment); return Json(new ReturnMessage { IsSuccess = true, Message = "撤销成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "撤销失败:" + ex.Message }); } } //[HttpPost] //public ActionResult Rollback(string examinationSuspensionIDs, string comment) //{ // var examinationSuspensionIDList = examinationSuspensionIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); // var curUserID = CustomPrincipal.Current.UserID; // if (examinationSuspensionIDList.Count == 0) // { // return Json(new ReturnMessage { IsSuccess = false, Message = "请选择至少一条记录进行退回。" }); // } // try // { // var actionViewList = this.ExaminationSuspensionServices.GetActionView(examinationSuspensionIDList[0], curUserID); // var actionView = actionViewList.FirstOrDefault(x => x.ActionName != "同意"); // foreach (var examinationSuspensionID in examinationSuspensionIDList) // { // this.ExaminationSuspensionServices.Approve(examinationSuspensionID, curUserID, actionView.ActionID, comment); // } // return Json(new ReturnMessage { IsSuccess = true, Message = "退回成功。" }); // } // catch (Exception ex) // { // return Json(new ReturnMessage { IsSuccess = false, Message = "退回失败:" + ex.Message }); // } //} [HttpPost] public ActionResult Delete(string examinationSuspensionIDs) { var examinationSuspensionIDList = examinationSuspensionIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); try { this.ExaminationSuspensionServices.Delete(examinationSuspensionIDList); return Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + ex.Message }); } } [HttpPost] public ActionResult Submit(string examinationSuspensionIDs) { var examinationSuspensionIDList = examinationSuspensionIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); var curUserID = CustomPrincipal.Current.UserID; if (examinationSuspensionIDList.Count == 0) { return Json(new ReturnMessage { IsSuccess = false, Message = "请选择至少一条记录进行提交。" }); } try { this.ExaminationSuspensionServices.StartUp(examinationSuspensionIDList, curUserID); return Json(new ReturnMessage { IsSuccess = true, Message = "提交成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "提交失败:" + ex.Message }); } } [HttpGet] public ActionResult applyEdit(Guid examinationSuspensionID) { var es=ExaminationSuspensionServices.GetExaminationSuspensionView(examinationSuspensionID); return View(es); } public ActionResult TeacherEdit(Guid? examinationSuspensionID) { ExaminationSuspensionView examinationSuspensionView = new ExaminationSuspensionView(); if (examinationSuspensionID.HasValue) { examinationSuspensionView = this.ExaminationSuspensionServices.GetExaminationSuspensionView(examinationSuspensionID.Value); } else { //默认值 examinationSuspensionView.ExamsCategoryID = (int)EMIS.ViewModel.CF_ExamsCategory.FinalExam; } ViewBag.CoursematerialID = examinationSuspensionView.CoursematerialID; return View(examinationSuspensionView); } [HttpPost] public ActionResult TeacherEdit(ExaminationSuspensionView examinationSuspensionView) { try { examinationSuspensionView.SchoolyearID = BaseExtensions.GetCurrentSchoolYearID(); examinationSuspensionView.ExamsCategoryID = (int)CF_ExamsCategory.FinalExam; this.ExaminationSuspensionServices.Save(examinationSuspensionView); return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } [HttpPost] public ActionResult Approve(string examinationSuspensionIDs, Guid actionID, string comment) { var examinationSuspensionIDList = examinationSuspensionIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); var curUserID = CustomPrincipal.Current.UserID; if (examinationSuspensionIDList.Count == 0) { return Json(new ReturnMessage { IsSuccess = false, Message = "请选择至少一条记录进行审核。" }); } try { this.ExaminationSuspensionServices.Approve(examinationSuspensionIDList, curUserID, (Guid)actionID, comment); return Json(new ReturnMessage { IsSuccess = true, Message = "审核成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "审核失败:" + ex.Message }); } } } }