123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- 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<Guid>();
- var examinationBatchID = Request.Form["dllExaminationBatch"].ParseStrTo<Guid>();
- var examinationTypeID = Request.Form["dllExaminationType"].ParseStrTo<Guid>();
- var examinationProjectID = Request.Form["dllExaminationProject"].ParseStrTo<Guid>();
- var schoolAreaID = Request.Form["ddlSchoolArea"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlSchoolArea"].ParseStrTo<int>();
- 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<Guid> trainingClassIDList = trainingClassIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
- try
- {
- return Json(new ReturnMessage<string>()
- {
- 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
- });
- }
- }
- }
- }
|