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.Common.Utility; using EMIS.CommonLogic.RetakeManage; using Bowin.Web.Controls.Mvc; using Bowin.Common.Data; namespace EMIS.Web.Controllers.RetakeManage { [Authorization] public class RetakePlanPrescanController : Controller { public IRetakePlanServices RetakePlanServices { get; set; } public IRetakePlanStudentServices RetakePlanStudentServices { get; set; } public ActionResult List() { return View(); } public ActionResult Add() { return View(); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("ddlSchoolYear"); var collegeID = pararms.getExtraGuid("cbgCollege"); 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 isNoAssears = pararms.getExtraInt("ddlIsNoAssears") == DropdownList.SELECT_ALL ? (bool?)null : (pararms.getExtraInt("ddlIsNoAssears") == (int)CF_GeneralPurpose.IsYes); 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(RetakePlanStudentServices.GetRetakeStudentListViewList(configuretView, schoolyearID, collegeID, gradeYearID, standardID, classmajorID, isNoAssears,learningformID,education,LearnSystem, (int)pararms.page, (int)pararms.rows)); } public ActionResult StudentDetail() { var userID = Request["userID"].ParseStrTo(); var schoolyearID = Request["schoolyearID"].ParseStrTo(); ViewBag.userID = userID; ViewBag.schoolyearID = schoolyearID; return View(); } [HttpPost] public ActionResult StudentDetail(QueryParamsModel pararms) { var userID = Request["userID"].ParseStrTo() ; var schoolyearID = Request["schoolyearID"].ParseStrTo(); ViewBag.userID = userID; ViewBag.schoolyearID = schoolyearID; return Json(RetakePlanStudentServices.GetRetakeStudentDetailListView(userID, schoolyearID, (int)pararms.page, (int)pararms.rows)); } [HttpPost] public ActionResult Generate() { try { RetakePlanServices.Generate(); return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } [HttpPost] public ActionResult Charge(string planStudentIDs) { List list = planStudentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); try { RetakePlanStudentServices.ChargePush(list); return Json(new ReturnMessage { IsSuccess = true, Message = "推送成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "推送失败:" + ex.Message }); } } [HttpPost] public ActionResult Delete(string planStudentIDs) { List list = planStudentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); try { RetakePlanStudentServices.DeleteStudent(list); return Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + ex.Message }); } } [HttpPost] public ActionResult Add(Guid userID) { try { RetakePlanStudentServices.AddStudent(userID); return Json(new ReturnMessage { IsSuccess = true, Message = "添加成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "添加失败:" + ex.Message }); } } //导出 [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 gradeYearID = 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 isNoAssears = Request.Form["ddlIsNoAssears"]; var classmajorID = Request.Form["cbgClassmajor"].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(); bool? isAssears = null; if (Convert.ToInt32(isNoAssears) == (int)CF_GeneralPurpose.IsYes) { isAssears = true; } if (Convert.ToInt32(isNoAssears) == (int)CF_GeneralPurpose.IsNo) { isAssears = false; } var dt = RetakePlanStudentServices.GetRetakeExcelList(configuretView, schoolyearID, collegeID, gradeYearID, standardID, classmajorID, isAssears, learningformID, education, LearnSystem).Select(x => new { x.SchoolyearCode, x.LoginID, x.UserName, x.CollegeName, x.Gradeyear, x.StandardDesc, x.ClassName, x.NoPassCount, x.IsNoArrearsDesc }).ToTable(); string[] liststring = { "学年学期", "学号","姓名", "教学点", "年级", "专业", "班级名称", "不及格门数", "是否已缴费"}; neh.Export(dt, liststring, "补考重修名单"); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功!" }); } } }