using System; using System.Text; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Collections; using Bowin.Common.Data; using Bowin.Common.Exceptions; using Bowin.Common.Utility; using Bowin.Web.Controls.Mvc; using EMIS.Web.Controls; using EMIS.Utility; using EMIS.ViewModel; using EMIS.ViewModel.StudentManage.StudentChange; using EMIS.CommonLogic.StudentWeb.Change; using EMIS.CommonLogic.StudentManage.StudentProfile; namespace EMIS.Web.Controllers.StudentWeb.Change { [Authorization] public class StudentChangeController : Controller { public Lazy StudentChangeServices { get; set; } public Lazy StudentServices { get; set; } /// /// 异动申请(学生)页面 /// /// public ActionResult List() { return View(); } /// /// 异动申请(学生)列表查询 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var user = EMIS.Utility.FormValidate.CustomPrincipal.Current; return base.Json(StudentChangeServices.Value.GetStudentChangeViewGrid(configuretView, user.UserID, (int)pararms.page, (int)pararms.rows)); } /// /// 编辑 /// /// /// [HttpGet] public ActionResult Edit(Guid? studentChangeID) { var user = EMIS.Utility.FormValidate.CustomPrincipal.Current; if (user == null) { throw new Exception("登录超时,请退出系统重新登录。"); } StudentChangeView studentChangeView = new StudentChangeView(); if (studentChangeID.HasValue && studentChangeID != Guid.Empty) { studentChangeView = StudentChangeServices.Value.GetStudentChangeView(studentChangeID); } else { var studentView = StudentServices.Value.GetStudentView(user.UserID); if(studentView == null) { throw new Exception("登录超时,请退出系统重新登录。"); } else { studentChangeView.UserID = studentView.UserID; studentChangeView.StudentNo = studentView.StudentNo; studentChangeView.Name = studentView.Name; studentChangeView.SexID = studentView.SexID; studentChangeView.BeforeCollegeID = studentView.CollegeID; studentChangeView.BeforeGradeID = studentView.GradeID; studentChangeView.BeforeStandardID = studentView.StandardID; studentChangeView.BeforeEducationID = studentView.EducationID; studentChangeView.BeforeLearningformID = studentView.LearningformID; studentChangeView.BeforeLearnSystem = studentView.LearnSystem; studentChangeView.BeforeClassmajorID = studentView.ClassmajorID; studentChangeView.BeforeInSchoolStatusID = studentView.InSchoolStatusID; studentChangeView.BeforeStudentStatus = studentView.StudentStatus; studentChangeView.AfterCollegeID = studentView.CollegeID; studentChangeView.AfterGradeID = studentView.GradeID; studentChangeView.AfterStandardID = studentView.StandardID; studentChangeView.AfterEducationID = studentView.EducationID; studentChangeView.AfterLearningformID = studentView.LearningformID; studentChangeView.AfterLearnSystem = studentView.LearnSystem; studentChangeView.AfterClassmajorID = studentView.ClassmajorID; studentChangeView.AfterInSchoolStatusID = studentView.InSchoolStatusID; studentChangeView.AfterStudentStatus = studentView.StudentStatus; } } return View(studentChangeView); } /// /// 编辑 /// /// /// [HttpPost] public ActionResult Edit(StudentChangeView studentChangeView) { try { StudentChangeServices.Value.StudentChangeEdit(studentChangeView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message }); } } /// /// 删除 /// /// /// [HttpPost] public ActionResult Delete(string studentChangeIDs) { try { List list = studentChangeIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); StudentChangeServices.Value.StudentChangeDelete(list); return Json(new ReturnMessage() { IsSuccess = true, Message = "删除成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "删除失败,原因:" + ex.Message }); } } /// /// 提交 /// /// /// [HttpPost] public ActionResult Submit(string studentChangeIDs) { try { var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal; List list = studentChangeIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); string result = StudentChangeServices.Value.StudentChangeSubmit(list, user.UserID, ""); return Json(new ReturnMessage() { IsSuccess = true, Message = "提交成功" + result + "。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "提交失败,原因:" + ex.Message }); } } /// /// 申请表报表 /// /// public ActionResult ApplyReport() { var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current; ViewBag.LoginUserID = curUser.UserID.ToString(); var dataRangeID = StudentServices.Value.GetDataRangeID(); ViewBag.DataRangeID = dataRangeID; return View(); } /// /// Excel导出 /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var user = EMIS.Utility.FormValidate.CustomPrincipal.Current; var dt = StudentChangeServices.Value.GetStudentChangeViewList(configuretView, user.UserID) .Select(x => new { x.SchoolyearCode, x.StudentNo, x.Name, x.SexName, x.ChangeTypeName, x.InSchoolStatusName, x.BeforeStandardName, x.BeforeClassmajorName, x.BeforeInSchoolStatusName, x.AfterStandardName, x.AfterClassmajorName, x.AfterInSchoolStatusName, x.ChangeReasonName, x.Description, ChangeDate = (x.ChangeDate.HasValue ? x.ChangeDate.Value.ToString("yyyyMMdd") : ""), x.ApprovalStatusName }).ToTable(); string[] liststring = { "异动学期", "学号", "姓名", "性别", "异动类型", "在校状态", "异动前专业", "异动前班级", "在校状态(前)", "异动后专业", "异动后班级", "在校状态(后)", "异动原因", "申请说明", "异动日期", "审核状态" }; neh.Export(dt, liststring, "异动申请信息(" + user.LoginID + ")" + DateTime.Now.ToString("yyyyMMdd")); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } } }