using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Bowin.Common.Data; using Bowin.Common.Utility; using Bowin.Web.Controls.Mvc; using EMIS.CommonLogic.EducationManage; using EMIS.ViewModel; using EMIS.ViewModel.EducationManage; using EMIS.Web.Controls; namespace EMIS.Web.Controllers.EducationManage { [Authorization] public class TrainingClassController : Controller { public ITrainingClassServices TrainingClassServices { get; set; } public ActionResult List() { return View(); } public ActionResult StudentList(Guid trainingClassID) { return View(); } public ActionResult Generate() { return View(new GenerateTrainingClassConditions()); } public ActionResult Split(Guid trainingClassID) { TrainingClassSplitView trainingClassSplitView = new TrainingClassSplitView(); trainingClassSplitView = TrainingClassServices.GetTrainingClassSplitView(trainingClassID); //trainingClassSplitView.IsByStudentCount = false; //trainingClassSplitView.IsBySplitCount = false; //trainingClassSplitView.IsByClassmajor = false; //trainingClassSplitView.ClassStudentCount = null; //trainingClassSplitView.ClassCount = null; //trainingClassSplitView.ClassMinStudentCount = null; //return View(trainingClassSplitView); return View(trainingClassSplitView); } public ActionResult Merge() { return View(new TrainingClassMergeView()); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView conditionView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("ddlSchoolyear"); var examinationBatchID = pararms.getExtraGuid("ddlExaminationBatch"); var examinationTypeID = pararms.getExtraGuid("ddlExaminationType"); var examinationProjectID = pararms.getExtraGuid("ddlExaminationProject"); var schoolAreaID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea"); return base.Json(TrainingClassServices.GetTrainingClassViewGrid(conditionView, schoolyearID, examinationBatchID, examinationTypeID, examinationProjectID, schoolAreaID, (int)pararms.page, (int)pararms.rows)); } [HttpPost] public ActionResult StudentList(QueryParamsModel pararms, Guid trainingClassID) { ConfiguretView conditionView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolAreaID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea"); var collegeID = pararms.getExtraGuid("ddlCollege"); var year = pararms.getExtraInt("ddlYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear"); var standardID = pararms.getExtraInt("cgbStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("cgbStandard"); var classmajorID = pararms.getExtraGuid("cgbClassmajor"); var name = pararms.getExtraString("txtName"); var idNumber = pararms.getExtraString("txtIDNumber"); return base.Json(TrainingClassServices.GetTrainingClassStudentViewGrid(conditionView, trainingClassID, schoolAreaID, collegeID, year, standardID, classmajorID, name, idNumber, pararms.page, pararms.rows)); } [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView conditionView = ConfiguretExtensions.GetConfiguretermsView(null); var schoolyearID = Request.Form["ddlSchoolyear"].ParseStrTo(); var examinationBatchID = Request.Form["dllExaminationBatch"].ParseStrTo(); var examinationTypeID = Request.Form["dllExaminationType"].ParseStrTo(); var examinationProjectID = Request.Form["dllExaminationProject"].ParseStrTo(); var schoolAreaID = Request.Form["ddlSchoolArea"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlSchoolArea"].ParseStrTo(); var trainingClassIDList = Request.Form["selectedIDs"].Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); var dt = TrainingClassServices.GetTrainingClassExportViewList(conditionView, schoolyearID, examinationBatchID, examinationTypeID, examinationProjectID, schoolAreaID, trainingClassIDList) .Select(x => new { x.SchoolyearCode, x.ExaminationBatchName, x.ExaminationTypeName, x.ExaminationProjectName, x.Year, x.ClassmajorName, x.UserName, x.SexName, x.CertificatesTypeName, x.IDNumber, x.Mobile, x.Name }).ToTable(); string[] liststring = { "学年学期", "考试批次", "考试类型", "项目名称", "年级", "班级", "姓名", "性别", "证件类型", "证件号码", "联系方式", "培训班名" }; neh.Export(dt, liststring, "学生培训信息" + DateTime.Now.ToString("yyyyMMdd")); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } [HttpPost] public ActionResult Generate(GenerateTrainingClassConditions conditions) { try { if (!conditions.ExaminationBatchID.HasValue) { return Json(new ReturnMessage() { IsSuccess = false, Message = "请输入考试批次。" }); } if (conditions.SchoolAreaID == DropdownList.PLEASE_SELECT) { conditions.SchoolAreaID = null; } TrainingClassServices.GenerateTrainingClass(conditions.ExaminationBatchID.Value, conditions.ExaminationProjectID, conditions.SchoolAreaID); return Json(new ReturnMessage() { IsSuccess = true, Message = "生成成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "生成失败:" + ex.Message }); } } [HttpPost] public ActionResult Split(Guid trainingClassID, string newName, string userIDs) { try { var userIDList = userIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); TrainingClassServices.Split(trainingClassID, newName, userIDList); return Json(new ReturnMessage() { IsSuccess = true, Message = "分班成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "分班失败:" + ex.Message }); } } [HttpPost] public ActionResult GetMergeName(string trainingClassIDs) { List trainingClassIDList = trainingClassIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); try { return Json(new ReturnMessage() { IsSuccess = true, Message = "", Data = this.TrainingClassServices.GetMergeName(trainingClassIDList) }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "合班失败:" + ex.Message }); } } [HttpPost] public ActionResult Merge(TrainingClassMergeView trainingClassMergeView) { try { TrainingClassServices.Merge(trainingClassMergeView); return Json(new ReturnMessage() { IsSuccess = true, Message = "合班成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "合班失败:" + ex.Message }); } } [HttpPost] public ActionResult AddStudent(Guid trainingClassID, string studentIDs) { var userIDList = studentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); try { TrainingClassServices.AddStudent(trainingClassID, userIDList); return Json(new ReturnMessage() { IsSuccess = true, Message = "添加成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "添加失败:" + ex.Message }); } } [HttpPost] public ActionResult DelStudent(Guid trainingClassID, string studentIDs) { var userIDList = studentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); try { TrainingClassServices.DelStudent(trainingClassID, userIDList); return Json(new ReturnMessage() { IsSuccess = true, Message = "删除成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "删除失败:" + ex.Message }); } } [HttpPost] public ActionResult StudentUserIDList(string trainingClassIDs) { var trainingClassIDList = trainingClassIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); return base.Json(TrainingClassServices.GetTrainingClassStudentIDList(trainingClassIDList)); } [HttpGet] public ActionResult Edit(Guid? trainingClassID) { TrainingClassView trainingClassView = new TrainingClassView(); if (trainingClassID.HasValue && trainingClassID != Guid.Empty) { trainingClassView = TrainingClassServices.GetTrainingClassView(trainingClassID); } return View(trainingClassView); } [HttpPost] public ActionResult Edit(TrainingClassView trainingClassView) { try { TrainingClassServices.Edit(trainingClassView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message }); } } } }