123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.CommonLogic.ExaminationApply;
- using EMIS.ViewModel;
- using EMIS.Web.Controls;
- using Bowin.Common.Data;
- using Bowin.Common.Utility;
- using EMIS.Utility;
- using Bowin.Common;
- using EMIS.CommonLogic.CalendarManage;
- using EMIS.CommonLogic.Students;
- using Bowin.Web.Controls.Mvc;
- using System.Text;
- using EMIS.ViewModel.ExaminationApply;
- namespace EMIS.Web.Controllers.ExaminationApply
- {
- [Authorization]
- public class ExaminationApplayStudentListController : Controller
- {
- public IExaminationSubjectServices ExaminationSubjectServices { get; set; }
- public ISchoolYearServices SchoolYearServices { get; set; }
- public IExamineApplyServices ExamineApplyService { get; set; }
- public ActionResult List()
- {
- var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
- ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();//默认当前学年
- return View();
- }
- public ActionResult Export()
- {
- return View();
- }
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var schoolyearID = pararms.getExtraGuid("SchoolYearDropdown");
- var subjectID = pararms.getExtraGuid("ddlExaminationSubject");
- var collegeID = pararms.getExtraGuid("cgCollege");
- var classmajorID = pararms.getExtraGuid("cgClassmajor");
- var examinationTypeID = pararms.getExtraGuid("cgExamination");
- var year = pararms.getExtraInt("ddlYear") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear");
- var standardID = pararms.getExtraInt("ddlStandard") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlStandard");
- var isPay = pararms.getExtraInt("IsPay") == DropdownList.SELECT_ALL ? (bool?)null : (pararms.getExtraInt("IsPay") == (int)CF_GeneralPurpose.IsYes);
- if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- return base.Json(ExaminationSubjectServices.GetExaminationSubjectStudentListView(configuretView, subjectID, collegeID,
- year, standardID, classmajorID, examinationTypeID, schoolyearID, isPay, (int)pararms.page, (int)pararms.rows));
- }
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var subjectID = Request.Form["ddlExaminationSubject"].ParseStrTo<Guid>();
- var collegeID = Request.Form["cgCollege"].ParseStrTo<Guid>();
- var schoolyearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>();
- var classmajorID = Request.Form["cgClassmajor"].ParseStrTo<Guid>();
- var examinationTypeID = Request.Form["cgExamination"].ParseStrTo<Guid>();
- var year = Request.Form["ddlYear"].ParseStrTo<int>() == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : Request.Form["ddlYear"].ParseStrTo<int>();
- var standardID = Request.Form["ddlStandard"].ParseStrTo<int>() == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : Request.Form["ddlStandard"].ParseStrTo<int>();
- var isPay = Request.Form["IsPay"];
- bool? IsPay = null;
- if (Convert.ToInt32(isPay) == (int)CF_GeneralPurpose.IsNo)
- {
- IsPay = false;
- }
- if (Convert.ToInt32(isPay) == (int)CF_GeneralPurpose.IsYes)
- {
- IsPay = true;
- }
- if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- var dt = ExaminationSubjectServices.GetExaminationSubjectStudentListView(configuretView, subjectID, collegeID,
- year, standardID, null, examinationTypeID, schoolyearID,IsPay).Select(x => new
- {
- x.SchoolyearCode,
- x.StudentNo,
- x.Name,
- x.SexName,
- x.ClassmajorName,
- x.SubjectName,
- x.CertificatesTypeName,
- x.IDNumber,
- x.Cost,
- x.IsPay
- }).ToTable();
- string[] liststring = { "考试学年学期", "学号", "姓名", "性别", "班级名称", "科目名称", "证件类型", "证件号码", "报名费","是否交费" };
- neh.Export(dt, liststring, "报考学生名单");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/ExaminationApplayStudentList/List").AddMenuParameter()
- });
- }
- public ActionResult ClassStudentStatisticsList()
- {
- var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
- ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();//默认当前学年
- return View();
- }
- [HttpPost]
- public ActionResult ClassStudentStatisticsList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var campusID = pararms.getExtraGuid("CampusDropdown");
- var collegeID = pararms.getExtraGuid("CollegeDropdown");
- var classmajorID = pararms.getExtraGuid("ClassmajorDropdown");
- var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
- //var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
- //ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();//默认当前学年
- var schoolYear = pararms.getExtraInt("SchoolyearDictionaryDropDown");
- var schoolyearID = pararms.getExtraGuid("SchoolYearDropdown");
- var subjectID = pararms.getExtraGuid("ddlExaminationSubject");
- return base.Json(ExaminationSubjectServices.GetExaminationSubjectClassStudentStatisticsListView(subjectID, schoolYear, schoolyearID, (int)pararms.page, (int)pararms.rows, campusID, collegeID, classmajorID, standardID));
- }
- [HttpPost]
- public ActionResult ClassStudentStatisticsExcel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- //ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- //if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- var subjectID = Request.Form["ddlExaminationSubject"].ParseStrTo<Guid>();
- var schoolyearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>();
-
- var dt = ExaminationSubjectServices.GetExaminationSubjectClassStudentStatisticsList(subjectID, schoolyearID).Select(x => new
- {
- x.Year,
- x.GrademajorName,
- x.ClassmajorName,
- x.SchoolyearCode,
- x.SubjectName,
- x.StudentCount,
- x.Cost,
- }).ToTable();
- string[] liststring = { "年级", "年级专业", "班级", "学期", "科目", "报名人数", "收费" };
- neh.Export(dt, liststring, "报考班级学生统计");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/ExaminationApplayStudentList/ClassStudentStatisticsList").AddMenuParameter()
- });
- }
- public ActionResult ClassStudentStatisticsReport()
- {
- return View();
- }
- [HttpPost]
- public ActionResult ExportStudentData()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var schoolyearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>();
- var subjectID = Request.Form["ddlExaminationSubject"].ParseStrTo<Guid>();
- var examinationTypeID = Request.Form["cgExamination"].ParseStrTo<Guid>();
- var collegeID = Request.Form["cgCollege"].ParseStrTo<Guid>();
- var year = Request.Form["ddlYear"].ParseStrTo<int>() == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : Request.Form["ddlYear"].ParseStrTo<int>();
- var standardID = Request.Form["ddlStandard"].ParseStrTo<int>() == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : Request.Form["ddlStandard"].ParseStrTo<int>();
- var isPay = Request.Form["IsPay"];
- bool? IsPay = null;
- if (Convert.ToInt32(isPay) == (int)CF_GeneralPurpose.IsNo)
- {
- IsPay = false;
- }
- if (Convert.ToInt32(isPay) == (int)CF_GeneralPurpose.IsYes)
- {
- IsPay = true;
- }
- if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- var dt = ExaminationSubjectServices.GetExaminationSubjectStudentListView(configuretView, subjectID, collegeID,
- year, standardID, null, examinationTypeID, schoolyearID,IsPay).Select(x => new
- {
- x.SchoolyearCode,
- x.StudentNo,
- x.Name,
- x.SexName,
- x.ClassmajorName,
- x.SubjectName,
- x.CertificatesTypeName,
- x.IDNumber,
- x.CardNo,
- //x.EducationName,
- //LearnSystem = x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("#.#") : null,
- x.CollegeName,
- x.Year,
- //x.SchoolyearNumName,
- x.StandardName,
- // x.ClassmajorNo
- }).ToTable(); //RSL.Get("EducationID"), "学制",
- string[] liststring = { "考试学年学期","学号", "姓名", "性别", "班级名称", "科目名称", "证件类型", "证件号码","银行卡号",
- "院系", "年级", "专业" };
- neh.Export(dt, liststring, "报考学生数据导出");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/ExaminationApplayStudentList/Export").AddMenuParameter()
- });
- }
- [HttpPost]
- public ActionResult ExportStudentPic()
- {
- string tempVirtualFilePath = Const.LOCAL_SETTING_UPLOAD_FILEPATH + "/" + Guid.NewGuid().ToString();
- string tempPhysicalFilePath = HttpContext.Server.MapPath(tempVirtualFilePath);
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var schoolyearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>();
- var subjectID = Request.Form["ddlExaminationSubject"].ParseStrTo<Guid>();
- var collegeID = Request.Form["cgCollege"].ParseStrTo<Guid>();
- var classmajorID = Request.Form["cgClassmajor"].ParseStrTo<Guid>();
- var examinationTypeID = Request.Form["cgExamination"].ParseStrTo<Guid>();
- var year = Request.Form["ddlYear"].ParseStrTo<int>() == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : Request.Form["ddlYear"].ParseStrTo<int>();
- var standardID = Request.Form["ddlStandard"].ParseStrTo<int>() == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : Request.Form["ddlStandard"].ParseStrTo<int>();
- var isPay = Request.Form["IsPay"];
- bool? IsPay = null;
- if (Convert.ToInt32(isPay) == (int)CF_GeneralPurpose.IsNo)
- {
- IsPay = false;
- }
- if (Convert.ToInt32(isPay) == (int)CF_GeneralPurpose.IsYes)
- {
- IsPay = true;
- }
- if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- var studentList = ExaminationSubjectServices.GetExaminationSubjectStudentListView(configuretView, subjectID, collegeID,
- year, standardID, null, examinationTypeID, schoolyearID,IsPay).ToList();
- if (!System.IO.Directory.Exists(tempPhysicalFilePath))
- {
- System.IO.Directory.CreateDirectory(tempPhysicalFilePath);
- }
- var fileInfo = studentList.Where(x => x.PhotoUrl != null)
- .Select(x => new EMIS.Utility.FileUploadHelper.RemoteFileInfo { RemotePath = x.PhotoUrl, FileName = x.IDNumber + ".jpg" }).ToList();
- FileUploadHelper.DownLoadFiles("studentPhoto" + Guid.NewGuid().ToString(), "报考学生照片", fileInfo);
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/ExaminationApplayStudentList/Export").AddMenuParameter()
- });
- }
- public ActionResult ApplyCancel(string ExaminationRegistrationIDs)
- {
- try
- {
- var xaminationRegistrationIDList = ExaminationRegistrationIDs.Split(',').Where(x => x.IndexOf("-") >= 0).Select(x => new Guid(x)).ToList();
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- ExamineApplyService.ApplyCancel(xaminationRegistrationIDList);
- return base.Json("撤销成功");
- }
- catch (Exception ex)
- {
- string mge = ex.Message;
- return base.Json("撤销失败,原因:" + mge);
- }
- }
- /// <summary>
- /// 学生名单导入
- /// </summary>
- /// <param name="errorFile"></param>
- /// <param name="operationTips"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Import(string errorFile, string operationTips)
- {
- ViewBag.ErrorFile = errorFile;
- if (string.IsNullOrEmpty(operationTips))
- {
- operationTips = "错误数据下载";
- }
- ViewBag.operationTips = operationTips;
- return View();
- }
- public ActionResult Import(HttpPostedFileBase file)
- {
- try
- {
- if (!NpoiExcelHelper.GetIsCompatible(file.FileName))
- {
- throw new Exception("只允许上传xls和xlsx格式的Excel文件!");
- }
- var excel = new NpoiExcelHelper();
- #region 表单头
- Dictionary<string, string> cellheader = new Dictionary<string, string>
- {
- { "SchoolyearCode", "考试学年学期" },
- { "StudentNo", "学号" },
- { "Name", "姓名" },
- { "SexForImpor", "性别" },
- { "ClassmajorName", "班级名称" },
- { "SubjectName", "科目名称" },
- { "CertificatesTypeNameForImport", "证件类型" },
- { "IDNumber", "证件号码" },
- { "CostForImpor", "报名费" },
- { "IsPay", "是否交费" },
- { "ErrorMessage", "错误信息" }
- };
- #endregion
- StringBuilder errorMsg = new StringBuilder(); // 错误信息
- string sourceWebPath = FileUploadHelper.UploadFile(file);
- var sourcePhysicalPath = Server.MapPath(sourceWebPath);
- List<StudentListView> errList = new List<StudentListView>();
- List<StudentListView> dataList = new List<StudentListView>();
- int errCount = 0;
- int OkCount = 0;
- ExaminationSubjectServices.ExaminationSubjectStudentImport(cellheader, out OkCount, out errList, out errCount, sourcePhysicalPath);
- System.IO.File.Delete(sourcePhysicalPath);//删除本地缓存文件
- if (errCount > 0)
- {
- var errorPhysicalPath = sourcePhysicalPath;
- var errorWebPaths = sourceWebPath;
- string errorWebPath = string.Format("{0}", NpoiExcelHelper.EntityListToExcel2003(cellheader, errList, "学生缴费名单失败文件", errorWebPaths));
- ViewBag.ErrorFile = errorWebPath;
- string Errinfo = string.Format("提示:成功导入{0}条记录,失败{1}条,详情请点击错误数据下载查看。", OkCount < 1 ? 0 : OkCount, errCount < 1 ? 0 : errCount);
- ViewBag.operationTips = Errinfo;
- // //return RedirectToAction("Import", new { errorFile = errorWebPath, operationTips = Errinfo });
- return RedirectToAction("MsgShow", "Common", new
- {
- WindowID = "none",
- msg = "导入失败!",
- url = Url.Action("Import").AddMenuParameter() + "&errorFile=" + errorWebPath + "&operationTips=" + Errinfo + "&WindowID=" + Request["WindowID"]
- });
- }
- else
- {
- return RedirectToAction("MsgShow", "Common", new
- {
- WindowID = Request["WindowID"],
- msg = "导入成功!",
- url = Url.Action("List").AddMenuParameter()
- });
- }
- }
- catch (Exception ex)
- {
- return RedirectToAction("MsgShow", "Common", new
- {
- WindowID = Request["WindowID"],
- msg = "导入失败,原因:" + ex.Message + "!",
- url = Url.Action("List").AddMenuParameter()
- });
- }
- }
- }
- }
|