using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Bowin.Web.Controls.Mvc; using Bowin.Common.Utility; using Bowin.Common.Data; using EMIS.CommonLogic.Students; using EMIS.ViewModel; using EMIS.Web.Controls; namespace EMIS.Web.Controllers.StudentManage.StudentChange { [Authorization] public class StudentBatchRepeatController : Controller { public IDifferentDynamicServices DifferentDynamicServices { get; set; } public IBatchRepeatServices BatchRepeatServices { get; set; } /// /// /// /// public ActionResult List() { return View(); } /// /// 列表查询 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolYearID = pararms.getExtraGuid("ddlSchoolYear"); //学年学期 var campusID = pararms.getExtraGuid("cbgCampus"); //校区 var collegeID = pararms.getExtraGuid("cbgCollege"); //院系所 var education = pararms.getExtraInt("ddlEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlEducation"); //培养层次 var year = pararms.getExtraInt("ddlYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear"); //年级 var standard = pararms.getExtraInt("cbgStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("cbgStandard"); //专业名称 var learningform = pararms.getExtraInt("ddlLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlLearningform"); //学习形式 var differentDynamicStatus = pararms.getExtraInt("ddlStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlStatus"); //审批状态 var result = BatchRepeatServices.GetDifferentDynamicViewGrid(configuretView, schoolYearID, campusID, collegeID, year, standard, education, learningform, differentDynamicStatus, (int)pararms.page, (int)pararms.rows); return Json(result); } [HttpPost] public ActionResult Delete(string differentDynamicIDs) { var idList = differentDynamicIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); try { DifferentDynamicServices.DeleteDifferentDynamic(idList); return Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + ex.Message }); } } [HttpPost] public ActionResult BatchAdd(string studentIDs) { var studentIDList = studentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); try { BatchRepeatServices.BatchAddStudents(studentIDList); return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } /// /// 提交 /// /// /// [HttpPost] public ActionResult Submit(string differentDynamicIDs) { try { var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal; var idList = differentDynamicIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); DifferentDynamicServices.Submit(idList, user.UserID); return Json(new ReturnMessage { IsSuccess = true, Message = "提交成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "提交失败:" + ex.Message }); } } /// /// 处理 /// /// /// [HttpPost] public ActionResult Process(string differentDynamicIDs) { try { var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal; var idList = differentDynamicIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); BatchRepeatServices.Process(idList); return Json(new ReturnMessage { IsSuccess = true, Message = "处理成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "处理失败:" + ex.Message }); } } /// /// 审核 /// /// /// [HttpPost] public ActionResult Approve(string differentDynamicIDs) { try { var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal; var idList = differentDynamicIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); BatchRepeatServices.Approve(idList); 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 campusID = Request.Form["cbgCampus"].ParseStrTo(); //校区 var collegeID = Request.Form["cbgCollege"].ParseStrTo(); //院系所 var education = Request.Form["ddlEducation"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlEducation"].ParseStrTo(); //培养层次 var year = Request.Form["ddlYear"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlYear"].ParseStrTo(); //年级 var standard = Request.Form["cbgStandard"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["cbgStandard"].ParseStrTo(); //专业名称 var learningform = Request.Form["ddlLearningform"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlLearningform"].ParseStrTo(); //学习形式 var differentDynamicStatus = Request.Form["ddlStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlStatus"].ParseStrTo(); //审批状态 var result = BatchRepeatServices.GetDifferentDynamicViewList(configuretView, schoolYearID, campusID, collegeID, year, standard, education, learningform, differentDynamicStatus); var dt = result.Select(s => new { s.LoginID, s.Name, s.SchoolyearCode, s.DifferentDynamicTypeName, s.ReasonName, s.ClassmajorName, s.AfterClassmajorName, s.ApprovalStatusName, s.Remark }).ToTable(); string[] liststring = { "学号", "姓名", "学年学期", "异动类型", "异动原因", "异动前班级", "异动后班级", "状态", "备注" }; neh.Export(dt, liststring, "批量留级申请"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Action("List").AddMenuParameter() }); } } }