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; using EMIS.ViewModel.Students; using System.IO; using System.Data; 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("ddlSchoolyear"); var examinationBatchID = pararms.getExtraGuid("cgExaminationBatch"); var examinationTypeID = pararms.getExtraGuid("cgExaminationType"); var examinationProjectID = pararms.getExtraGuid("cgExaminationProject"); var schoolAreaID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea"); var collegeID = pararms.getExtraGuid("cgCollege"); var year = pararms.getExtraInt("ddlYear") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear"); var classmajorID = pararms.getExtraGuid("cgClassmajor"); var recordStatus = pararms.getExtraInt("PayRecordStatus") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("PayRecordStatus"); var isConfirm = pararms.getExtraInt("IsConfirm") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsConfirm"); if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = ""; return base.Json(ExaminationSubjectServices.GetStudentListViewGrid(configuretView, schoolyearID, examinationBatchID, examinationTypeID, examinationProjectID, schoolAreaID, collegeID, year, classmajorID, recordStatus, isConfirm, (int)pararms.page, (int)pararms.rows)); } [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var schoolyearID = Request.Form["ddlSchoolyear"].ParseStrTo(); var examinationBatchID = Request.Form["cgExaminationBatch"].ParseStrTo(); var examinationTypeID = Request.Form["cgExaminationType"].ParseStrTo(); var examinationProjectID = Request.Form["cgExaminationProject"].ParseStrTo(); var schoolAreaID = Request.Form["ddlSchoolArea"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlSchoolArea"].ParseStrTo(); var collegeID = Request.Form["cgCollege"].ParseStrTo(); var year = Request.Form["ddlYear"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlYear"].ParseStrTo(); var classmajorID = Request.Form["cgClassmajor"].ParseStrTo(); var recordStatus = Request.Form["PayRecordStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["PayRecordStatus"].ParseStrTo(); var isConfirm = Request.Form["IsConfirm"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["IsConfirm"].ParseStrTo(); var examinationRegistrationIDs = Request.Form["SelectedID"]; if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = ""; List selectIDlist = new List(); if (examinationRegistrationIDs != "" && examinationRegistrationIDs != null) { selectIDlist = examinationRegistrationIDs.SplitIDString(); } var dt = ExaminationSubjectServices.GetStudentListViewForExport(configuretView, schoolyearID, examinationBatchID, examinationTypeID, examinationProjectID, schoolAreaID, collegeID, year, classmajorID, recordStatus, isConfirm,selectIDlist).Select(x => new { x.SchoolyearCode, x.ExaminationBatchName, x.ExaminationProjectName, x.SchoolAreaName, x.CollegeName, x.ClassmajorName, x.UserName, x.SexName, x.CertificatesTypeName, x.IDNumber, x.FeeTypeAndFee, x.PayFee, x.RecordStatusStr, x.WechatOrderID, x.RefundOrderID, x.ExaminationRegistrationConfirmNo, x.Remark, }).ToTable(); string[] liststring = { "学年学期", "考试批次", "项目名称", "校区", "院系所", "班级", "姓名", "性别", "证件类型", "证件号码", "报名项目(费用)", "金额", "缴费状态", "微信订单号", "微信退款单号", "确认单号", "备注" }; neh.Export(dt, liststring, "考试报名名单"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功。", url = Url.Content("~/ExaminationApplayStudentList/List").AddMenuParameter() }); } /// /// 复制新增 /// /// /// public ActionResult CopyAdd(Guid examinationRegistrationID) { StudentListView studentListView = new StudentListView(); studentListView = ExaminationSubjectServices.GetStudentListView(examinationRegistrationID); return View("Edit", studentListView); } /// /// 复制新增 /// /// /// [HttpPost] public ActionResult CopyAdd(StudentListView studentListView) { studentListView.ExaminationRegistrationID = Guid.Empty; return this.Edit(studentListView); } /// /// 新增 /// /// /// [HttpGet] public ActionResult Edit(Guid? examinationRegistrationID, Guid? schoolYearID, Guid? examinationBatchID, Guid? examinationTypeID, Guid? examinationProjectID) { StudentListView studentListView = new StudentListView(); if (schoolYearID.HasValue) { studentListView.SchoolyearID = schoolYearID; } if (examinationBatchID.HasValue) { studentListView.ExaminationBatchID = examinationBatchID; } if (schoolYearID.HasValue) { studentListView.ExaminationTypeID = examinationTypeID; } if (schoolYearID.HasValue) { studentListView.ExaminationProjectID = examinationProjectID; } if (examinationRegistrationID.HasValue && examinationRegistrationID != Guid.Empty) { studentListView = ExaminationSubjectServices.GetStudentListView(examinationRegistrationID); } return View(studentListView); } /// /// 新增 /// /// /// [HttpPost] public ActionResult Edit(StudentListView studentListView) { try { var studentList = DataGrid.GetTableData("dgStudentList"); ExaminationSubjectServices.AddSave(studentListView, studentList); string UrlStr = Url.Action("Edit").AddMenuParameter() + "&schoolYearID=" + studentListView.SchoolyearID + "&examinationBatchID=" + studentListView.ExaminationBatchID + "&examinationTypeID=" + studentListView.ExaminationTypeID + "&examinationProjectID=" + studentListView.ExaminationProjectID; return RedirectToAction("MsgShowAndOpenAddUrl", "Common", new { WindowID = Request["WindowID"], msg = "保存成功!", url = UrlStr, title = "报名名单新增", }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message }); } } /// /// 修改 /// /// /// [HttpGet] public ActionResult FeeTypeEdit(Guid? examinationRegistrationID) { StudentListView studentListView = new StudentListView(); if (examinationRegistrationID.HasValue && examinationRegistrationID != Guid.Empty) { studentListView = ExaminationSubjectServices.GetStudentListView(examinationRegistrationID); } return View(studentListView); } /// /// 修改 /// /// /// [HttpPost] public ActionResult FeeTypeEdit(StudentListView studentListView) { try { //var studentList = DataGrid.GetTableData("dgStudentList"); ExaminationSubjectServices.EditSave(studentListView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message }); } } [HttpPost] public ActionResult Delete(string examinationRegistrationIDs) { try { var examinationRegistrationIDList = examinationRegistrationIDs.Split(',').Select(x => (Guid)new Guid(x)).ToList(); ExaminationSubjectServices.Delete(examinationRegistrationIDList); return base.Json("删除成功"); } catch (Exception ex) { string mge = ex.Message; return base.Json("删除失败,原因:" + mge + "!"); } } [HttpGet] public ActionResult ChangeFee(string examinationRegistrationIDs) { ViewBag.ExaminationRegistrationIDs = examinationRegistrationIDs; return View(); } [HttpPost] public ActionResult ChangeFee(StudentListView studentListView) { try { decimal? Fee = Request.Form["Fee"].ParseStrTo(); string Remark = Request.Form["Remark"]; string examinationRegistrationIDs = Request.Form["examinationRegistrationIDs"]; var examinationRegistrationIDList = examinationRegistrationIDs.Split(',').Select(x => (Guid)new Guid(x)).ToList(); ExaminationSubjectServices.ChangeFee(examinationRegistrationIDList, Fee, Remark); return Json(new ReturnMessage() { IsSuccess = true, Message = "修改成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "修改失败,原因:" + ex.Message }); } } [HttpPost] public ActionResult Confirm(string examinationRegistrationIDs) { try { var examinationRegistrationIDList = examinationRegistrationIDs.Split(',').Select(x => (Guid)new Guid(x)).ToList(); var filePathUrl = Url.Content(Const.LOCAL_SETTING_UPLOAD_FILEPATH); var confirmID = ExaminationSubjectServices.Confirm(examinationRegistrationIDList, filePathUrl); return Json(new ReturnMessage() { IsSuccess = true, Message = confirmID.ToString(), }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "确认失败,原因:" + ex.Message }); } } [HttpPost] public ActionResult CancelConfirm(string examinationRegistrationIDs) { try { var examinationRegistrationIDList = examinationRegistrationIDs.Split(',').Select(x => (Guid)new Guid(x)).ToList(); ExaminationSubjectServices.CancelConfirm(examinationRegistrationIDList); return Json(new ReturnMessage() { IsSuccess = true, Message = "取消成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "取消失败,原因:" + ex.Message }); } } [HttpPost] public ActionResult StudentList(QueryParamsModel pararms, Guid? examinationRegistrationID) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var studentList = ExaminationSubjectServices.GetStudentViewList(configuretView, examinationRegistrationID,(int)pararms.page, (int)pararms.rows); return Json(studentList); } public ActionResult StudentSelect(Guid? examinationRegistrationID, Guid? examinationBatchID, Guid? examinationProjectID) { ViewBag.examinationBatchID = examinationBatchID; ViewBag.examinationProjectID = examinationProjectID; ViewBag.examinationRegistrationID = examinationRegistrationID; return View(); } [HttpPost] public ActionResult StudentListForSelect(QueryParamsModel pararms, Guid? examinationRegistrationID, Guid? examinationBatchID, Guid? examinationProjectID) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolAreaID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea"); var collegeID = pararms.getExtraGuid("CollegeComboGrid"); var grademajorID = pararms.getExtraGuid("GrademajorComboGrid"); var year = pararms.getExtraInt("ddlYear") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear"); var standardID = pararms.getExtraInt("StandardID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardID"); var classmajorID = pararms.getExtraGuid("ClassmajorComboGrid"); //examinationPlanID = Request.Form["examinationPlanID"].ParseStrTo(); return base.Json(ExaminationSubjectServices.GetStudentListForSelect(configuretView, examinationRegistrationID, examinationBatchID, examinationProjectID, schoolAreaID, collegeID, grademajorID, year, standardID, classmajorID, (int)pararms.page, (int)pararms.rows)); } //[HttpGet] //public ActionResult ExportPictures(string selectedIDs) //{ // ViewBag.selectedID = selectedIDs; // return View(); //} [HttpPost] public ActionResult ExportPictures() { try { string WindowStr = Request.UrlReferrer.ToString(); int IndexofID = WindowStr.LastIndexOf("="); WindowStr = WindowStr.Remove(0, IndexofID + 1); WindowStr = WindowStr.Substring(0, WindowStr.Length - 1); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var schoolyearID = Request.Form["ddlSchoolyear"].ParseStrTo(); var examinationBatchID = Request.Form["cgExaminationBatch"].ParseStrTo(); var examinationTypeID = Request.Form["cgExaminationType"].ParseStrTo(); var examinationProjectID = Request.Form["cgExaminationProject"].ParseStrTo(); var schoolAreaID = Request.Form["ddlSchoolArea"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlSchoolArea"].ParseStrTo(); var collegeID = Request.Form["cgCollege"].ParseStrTo(); var year = Request.Form["ddlYear"].ParseStrTo() == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : Request.Form["ddlYear"].ParseStrTo(); var classmajorID = Request.Form["cgClassmajor"].ParseStrTo(); var recordStatus = Request.Form["PayRecordStatus"].ParseStrTo() == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : Request.Form["PayRecordStatus"].ParseStrTo(); var isConfirm = Request.Form["IsConfirm"].ParseStrTo() == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : Request.Form["IsConfirm"].ParseStrTo(); var selectedIDs = Request.Form["SelectedID"]; if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = ""; //WebClient conn = new WebClient(); List studentList = new List(); if (!string.IsNullOrEmpty(selectedIDs)) { var selectedIDList = selectedIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); studentList = ExaminationSubjectServices.GetStudentViewListByIDList(selectedIDList).ToList(); } else { studentList = ExaminationSubjectServices.GetStudentListByCondition(configuretView, schoolyearID, examinationBatchID, examinationTypeID, examinationProjectID, schoolAreaID, collegeID, year, classmajorID, recordStatus, isConfirm).ToList(); } var remoteFileList = studentList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x => new EMIS.Utility.FileUploadHelper.RemoteFileInfo { FileName = x.IDNumber + Path.GetExtension(x.PhotoUrl.Trim()), RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : Url.Content(x.PhotoUrl.Trim())) }).ToList(); //if (ExportPictureType == "IDNumberToPicture") //{ // remoteFileList = studentList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x => // new EMIS.Utility.FileUploadHelper.RemoteFileInfo // { // FileName = x.IDNumber + Path.GetExtension(x.PhotoUrl.Trim()), // RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : Url.Content(x.PhotoUrl.Trim())) // }).ToList(); //} //if (ExportPictureType == "ExamineeNumToPicture") //{ // remoteFileList = studentList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x => // new EMIS.Utility.FileUploadHelper.RemoteFileInfo // { // FileName = x.ExamineeNum + Path.GetExtension(x.PhotoUrl.Trim()), // RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : Url.Content(x.PhotoUrl.Trim())) // }).ToList(); //} //if (ExportPictureType == "LoginIDandUserNameToPicture") //{ // remoteFileList = studentList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x => // new EMIS.Utility.FileUploadHelper.RemoteFileInfo // { // FileName = x.LoginID + x.UserName + Path.GetExtension(x.PhotoUrl.Trim()), // RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : Url.Content(x.PhotoUrl.Trim())) // }).ToList(); //} if (remoteFileList.Count > 0) { var zipFileStream = FileUploadHelper.DownLoadFiles(Guid.NewGuid().ToString(), "学生相片", remoteFileList); return File(zipFileStream, System.Net.Mime.MediaTypeNames.Application.Zip, "学生相片.zip"); } else { return RedirectToAction("MsgShow", "Common", new { WindowID = Request["WindowID"], msg = "没有相片可导出!", url = Url.Action("List").AddMenuParameter(), }); } } catch (Exception ex) { string mge = ex.Message; return RedirectToAction("MsgShow", "Common", new { WindowID = Request["WindowID"], msg = "导出失败。原因:" + mge + "!", url = Url.Action("List").AddMenuParameter() }); } } public ActionResult RegistrationConfirmReport(string examinationRegistrationConfirmIDs) { var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current; ViewBag.ExaminationRegistrationConfirmID = examinationRegistrationConfirmIDs; //ViewBag.UserID = curUser.UserID.ToString(); return View(); } [HttpGet] public ActionResult StudentImport(string errorFile, string operationTips) { ViewBag.ErrorFile = errorFile; //if (string.IsNullOrEmpty(operationTips)) //{ // operationTips = "错误数据下载"; //} ViewBag.operationTips = operationTips; //ViewBag.result = errorResult; //if (errorResult != null) //{ // return View(errorResult); //} return View(new ExcelImportResult()); } [HttpPost] public ActionResult StudentImport(HttpPostedFileBase file, Guid? schoolyearID, Guid? examinationBatchID, Guid? examinationTypeID, Guid? examinationProjectID, Guid? examinationProjectFeeID, int? feeTypeID) { try { //var schoolyearID = pararms.getExtraGuid("schoolyearID"); //var examinationBatchID = pararms.getExtraGuid("examinationBatchID"); //var examinationTypeID = pararms.getExtraGuid("examinationTypeID"); //var examinationProjectID = pararms.getExtraGuid("examinationProjectID"); //var examinationProjectFeeID = pararms.getExtraGuid("examinationProjectFeeID"); //var feeTypeID = pararms.getExtraInt("feeTypeID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("feeTypeID"); if (!NpoiExcelHelper.GetIsCompatible(file.FileName)) { throw new Exception("只允许上传xls和xlsx格式的Excel文件!"); } var excel = new NpoiExcelHelper(); #region 表单头 Dictionary cellheader = new Dictionary { { "IDNumber", "证件号" }, { "UserName", "姓名" }, }; #endregion StringBuilder errorMsg = new StringBuilder(); // 错误信息 string sourceWebPath = FileUploadHelper.UploadFile(file); var sourcePhysicalPath = Server.MapPath(sourceWebPath); List errList = new List(); List dataList = new List(); int errCount = 0; int OkCount = 0; var insertList = ExaminationSubjectServices.StudentImport(cellheader, out OkCount, out errList, out errCount, sourcePhysicalPath, schoolyearID, examinationBatchID, examinationTypeID, examinationProjectID, examinationProjectFeeID, feeTypeID); if (errCount > 0) { //errorResult = insertList; var errorPhysicalPath = sourcePhysicalPath; var errorWebPaths = sourceWebPath; string errorWebPath = string.Format("{0}", NpoiExcelHelper.EntityListToExcel2003(cellheader, errList, "学生报名名单失败文件", errorWebPaths)); insertList.ErrorFilePath = errorWebPath; insertList.Message = string.Format("提示:成功导入{0}条记录,失败{1}条,详情请点击错误数据下载查看。", OkCount < 1 ? 0 : OkCount, errCount < 1 ? 0 : errCount); //ViewBag.operationTips = Errinfo; //ViewBag.result = insertList; //// //return RedirectToAction("Import", new { errorFile = errorWebPath, operationTips = Errinfo }); //return RedirectToAction("MsgShow", "Common", new //{ // WindowID = "none", // msg = "导入失败!", // url = Url.Action("StudentImport").AddMenuParameter() + "&errorFile=" + errorWebPath + "&operationTips=" + Errinfo + "&result=" + insertList.Data + "&WindowID=" + Request["WindowID"] //}); return View(insertList); } else { return View(insertList); } } catch (Exception ex) { return RedirectToAction("MsgShow", "Common", new { WindowID = Request["WindowID"], msg = "导入失败,原因:" + ex.Message + "!", url = Url.Action("Edit").AddMenuParameter() }); } } /// /// 获取批次下拉(根据学年学期) /// /// /// [HttpPost] public ActionResult GetExaminationBatchViewGrid(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("SchoolYearDropdown"); return base.Json(ExaminationSubjectServices.GetExaminationBatchViewForComboGrid(configuretView, schoolyearID, (int)pararms.page, (int)pararms.rows)); } /// /// 获取考试类型下拉(根据学年学期) /// /// /// [HttpPost] public ActionResult GetExaminationTypeViewGrid(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("SchoolYearDropdown"); var examinationBatchID = pararms.getExtraGuid("cgExaminationBatch"); return base.Json(ExamineApplyService.GetExaminationTypeViewForComboGrid(configuretView, schoolyearID, examinationBatchID, (int)pararms.page, (int)pararms.rows)); } /// /// 获取项目下拉(根据批次,考试类型) /// /// /// [HttpPost] public ActionResult GetProjectListViewGrid(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var examinationBatchID = pararms.getExtraGuid("cgExaminationBatch"); var examinationTypeID = pararms.getExtraGuid("cgExaminationType"); return base.Json(ExaminationSubjectServices.GetExaminationProjectViewGridForComboGrid(configuretView, examinationBatchID, examinationTypeID, (int)pararms.page, (int)pararms.rows)); } /// /// 获取项目收费标准下拉(根据项目)学生端,根据批次项目控制查询 /// /// /// [HttpPost] public ActionResult GetExaminationProjectFeeViewGrid(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var examinationProjectID = pararms.getExtraGuid("cgExaminationProject"); var examinationBatchID = pararms.getExtraGuid("cgExaminationBatch"); return base.Json(ExaminationSubjectServices.GetProjectFeeTypeViewForComboGrid(configuretView, examinationBatchID, examinationProjectID, (int)pararms.page, (int)pararms.rows)); } /// /// 获取项目收费标准下拉(根据项目)教师端,根据收费项目查询 /// /// /// [HttpPost] public ActionResult GetExaminationProjectFeeViewByBaseGrid(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var examinationProjectID = pararms.getExtraGuid("cgExaminationProject"); var examinationBatchID = pararms.getExtraGuid("cgExaminationBatch"); return base.Json(ExaminationSubjectServices.GetProjectFeeTypeViewByBaseForComboGrid(configuretView, examinationBatchID, examinationProjectID, (int)pararms.page, (int)pararms.rows)); } /// /// 获取收费项下拉(根据项目收费标准) /// /// /// [HttpPost] public ActionResult GetFeeTypeViewGrid(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var examinationProjectFeeID = pararms.getExtraGuid("cgExaminationProjectFee"); return base.Json(ExaminationSubjectServices.GetFeeTypeViewForComboGrid(configuretView, examinationProjectFeeID, (int)pararms.page, (int)pararms.rows)); } public ActionResult InfoExport() { return View(); } public ActionResult DailyExport(QueryParamsModel pararms, string selectedIDs) { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("ddlSchoolyear"); var examinationBatchID = pararms.getExtraGuid("cgExaminationBatch"); var examinationTypeID = pararms.getExtraGuid("cgExaminationType"); var examinationProjectID = pararms.getExtraGuid("cgExaminationProject"); var schoolAreaID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea"); var collegeID = pararms.getExtraGuid("cgCollege"); var year = pararms.getExtraInt("ddlYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear"); var classmajorID = pararms.getExtraGuid("cgClassmajor"); var recordStatus = pararms.getExtraInt("PayRecordStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("PayRecordStatus"); var isConfirm = pararms.getExtraInt("IsConfirm") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsConfirm"); var examinationRegistrationIDs = Request.Form["SelectedID"]; if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = ""; List selectIDlist = new List(); if (selectedIDs != "" && selectedIDs != null) { selectIDlist = selectedIDs.SplitIDString(); } var dt = ExaminationSubjectServices.GetStudentListForExportViewGrid(configuretView, schoolyearID, examinationBatchID, examinationTypeID, examinationProjectID, schoolAreaID, collegeID, year, classmajorID, recordStatus, isConfirm, selectIDlist).Select(x => new { x.Year, x.SchoolAreaName, x.CollegeName, x.StandardName, x.ClassmajorName, x.ExaminationTypeName, x.ExaminationProjectName, x.StudentNo, x.UserName, x.SexName, x.IDNumber, BirthDate = (x.BirthDate.HasValue ? x.BirthDate.Value.ToString("yyyy-MM-dd") : ""), x.NationName, x.EducationName, x.ResidenceTypeName, x.ResidenceStr, x.HomeAddress, x.Mobile, x.FeeTypeAndFee, x.PayFee, RegistrDate = (x.RegistrDate.HasValue ? x.RegistrDate.Value.ToString("yyyy-MM-dd") : ""), PayDate = (x.PayDate.HasValue ? x.PayDate.Value.ToString("yyyy-MM-dd") : ""), x.WeChatNo, x.RecordStatusStr, x.Remark }).ToTable(); dt = AddSeriNumToDataTable(dt); string[] liststring = { "序号","年级", "校区", "院系所", "专业", "班级", "项目种类","项目名称","学号", "姓名", "性别", "身份证号", "出生日期","民族","学历","户口性质", "户口所在地", "家庭住址", "联系电话", "报名项目(费用)", "总费用","报名日期","收费日期","微信号", "状态", "备注" }; neh.Export(dt, liststring, "常规信息"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功。", url = Url.Content("~/ExaminationApplayStudentList/InfoExport").AddMenuParameter() }); } public ActionResult PJ5Export(QueryParamsModel pararms, string selectedIDs) { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("ddlSchoolyear"); var examinationBatchID = pararms.getExtraGuid("cgExaminationBatch"); var examinationTypeID = pararms.getExtraGuid("cgExaminationType"); var examinationProjectID = pararms.getExtraGuid("cgExaminationProject"); var schoolAreaID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea"); var collegeID = pararms.getExtraGuid("cgCollege"); var year = pararms.getExtraInt("ddlYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear"); var classmajorID = pararms.getExtraGuid("cgClassmajor"); var recordStatus = pararms.getExtraInt("PayRecordStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("PayRecordStatus"); var isConfirm = pararms.getExtraInt("IsConfirm") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsConfirm"); var examinationRegistrationIDs = Request.Form["SelectedID"]; if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = ""; List selectIDlist = new List(); if (examinationRegistrationIDs != "" && examinationRegistrationIDs != null) { selectIDlist = examinationRegistrationIDs.SplitIDString(); } var dt = ExaminationSubjectServices.GetStudentListForExportViewGrid(configuretView, schoolyearID, examinationBatchID, examinationTypeID, examinationProjectID, schoolAreaID, collegeID, year, classmajorID, recordStatus, isConfirm, selectIDlist).Select(x => new { x.UserName, x.CertificatesTypeName, x.IDNumber, x.SpecialSign, BirthDate = (x.BirthDate.HasValue ? x.BirthDate.Value.ToString("yyyy-MM-dd") : ""), x.SexName, x.EducationName, x.WorkingYears, x.WorkPlace, x.ProfessionalQualificationLevel, x.Copy, x.ExaminationTypeName, x.AppraisalPersonalType, x.PersonalType, x.ResidenceTypeName, x.ResidenceStr, x.NationName, x.PoliticsName, x.MaritalStatus, x.NationalQualificationLevel, x.PositionLevel, x.NationalAndCode, x.Address, RegistrDate = (x.RegistrDate.HasValue ? x.RegistrDate.Value.ToString("yyyy-MM-dd") : ""), x.ResitTheory, x.ResitPractice, x.ResitOne, x.ResitTwo, x.ResitThree, x.ResitFour, x.ProfessionalTitle, x.IsNotTheory, x.TheoryScore, x.PracticeScore, x.ResitOneScore, x.ResitTwoScore, x.ResitThreeScore, x.ResitFourScore, x.Mobile }).ToTable(); dt = AddSeriNumToDataTable(dt); string[] liststring = { "序号","姓名", "证件名称", "证件编号", "特殊标志", "出生日期","性别","文化程度", "工龄", "工作单位","上一级职业资格级别", "副本", "考试类型","鉴定人员类别","人员类别", "户口性质", "户口所在地", "民族", "政治面貌","婚姻状况","国家职业资格等级","专业技术职务级别","国家/地区代码", "联系地址", "报名日期", "补考理论","补考实操","补加考1","补加考2", "补加考3", "补加考4","职称","是否免考理论","理论成绩","实操成绩", "加考1成绩", "加考2成绩", "加考3成绩","加考4成绩","考生手机"}; neh.Export(dt, liststring, "广州市PJ5信息"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功。", url = Url.Content("~/ExaminationApplayStudentList/InfoExport").AddMenuParameter() }); } public ActionResult HighNewExport(QueryParamsModel pararms, string selectedIDs) { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("ddlSchoolyear"); var examinationBatchID = pararms.getExtraGuid("cgExaminationBatch"); var examinationTypeID = pararms.getExtraGuid("cgExaminationType"); var examinationProjectID = pararms.getExtraGuid("cgExaminationProject"); var schoolAreaID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea"); var collegeID = pararms.getExtraGuid("cgCollege"); var year = pararms.getExtraInt("ddlYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear"); var classmajorID = pararms.getExtraGuid("cgClassmajor"); var recordStatus = pararms.getExtraInt("PayRecordStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("PayRecordStatus"); var isConfirm = pararms.getExtraInt("IsConfirm") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsConfirm"); var examinationRegistrationIDs = Request.Form["SelectedID"]; if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = ""; List selectIDlist = new List(); if (examinationRegistrationIDs != "" && examinationRegistrationIDs != null) { selectIDlist = examinationRegistrationIDs.SplitIDString(); } var dt = ExaminationSubjectServices.GetStudentListForExportViewGrid(configuretView, schoolyearID, examinationBatchID, examinationTypeID, examinationProjectID, schoolAreaID, collegeID, year, classmajorID, recordStatus, isConfirm, selectIDlist).Select(x => new { x.CertificatesTypeName, x.IDNumber, x.UserName, x.EnglishName, BirthDate = (x.BirthDate.HasValue ? x.BirthDate.Value.ToString("yyyy-MM-dd") : ""), x.SexName, x.WorkPlace, x.EducationName, x.JoinWorkDate, x.WorkingYears, x.WorkType, x.Area, x.ResidenceStr, x.Place, x.NationName, x.PoliticsName, x.Mobile, x.ZipCode, x.IDCardAddress, x.HomeAddress, x.IsSoldier, x.IsLaidOff, x.IsUnemployment, x.IsDisability, x.IsFarmer, x.IsLabour, x.Other, x.DeclareOccupation, x.DeclareLevel, x.DeclareCondition, x.AppraisalType, x.OldCertificateNumber, x.ExamineeType, x.SubsidyTarget, x.SubsidyCertificateType, x.SubsidyCertificateNumber, x.ExamineeRemark, x.ExamineeCampus }).ToTable(); dt = AddSeriNumToDataTable(dt); string[] liststring = { "序号","身份证件类型","身份证件编号", "中文姓名", "英文姓名", "出生日期","性别", "工作单位","文化程度", "参加工作时间","职业年限", "从事职业","考生来源","户口所在省(市)","户口所在市(区)", "民族", "政治面貌","联系电话","邮政编码","身份证住址","常住住址", "现役军人", "下岗人员", "失业人员", "残疾人员","农民工","劳教劳改人员", "其它", "申报职业","申报级别","申报条件","鉴定分类","原证书编号", "考生类别","补贴对象", "补贴证件类型", "补贴证件编码","报名备注","报名单位"}; neh.Export(dt, liststring, "高新信息"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功。", url = Url.Content("~/ExaminationApplayStudentList/InfoExport").AddMenuParameter() }); } [HttpPost] public ActionResult ExportBySelect(QueryParamsModel pararms, string selectedIDs, string colnames, string showname) { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("ddlSchoolyear"); var examinationBatchID = pararms.getExtraGuid("cgExaminationBatch"); var examinationTypeID = pararms.getExtraGuid("cgExaminationType"); var examinationProjectID = pararms.getExtraGuid("cgExaminationProject"); var schoolAreaID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea"); var collegeID = pararms.getExtraGuid("cgCollege"); var year = pararms.getExtraInt("ddlYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear"); var classmajorID = pararms.getExtraGuid("cgClassmajor"); var recordStatus = pararms.getExtraInt("PayRecordStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("PayRecordStatus"); var isConfirm = pararms.getExtraInt("IsConfirm") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsConfirm"); List selectIDlist = new List(); if (selectedIDs != "" && selectedIDs != null) { selectIDlist = selectedIDs.SplitIDString(); } List namelist = new List(); for (int i = 0; i < showname.Split(',').Length; i++) { string col = showname.Split(',')[i]; if (!string.IsNullOrEmpty(col)) { namelist.Add(col); } } List idlist = new List(); for (int i = 0; i < colnames.Split(',').Length; i++) { string col = colnames.Split(',')[i]; if (!string.IsNullOrEmpty(col)) { idlist.Add(col); } } var dt = ExaminationSubjectServices.GetStudentListForExportViewGrid(configuretView, schoolyearID, examinationBatchID, examinationTypeID, examinationProjectID, schoolAreaID, collegeID, year, classmajorID, recordStatus, isConfirm, selectIDlist).Select(x => new { x.SchoolAreaName, x.ExamineeNum, x.UserName, x.SexName, BirthDate = (x.BirthDate.HasValue ? x.BirthDate.Value.ToString("yyyy-MM-dd") : ""), x.IDNumber, x.QQ, x.Email, x.PhoneNumber, x.SchoolCode, x.SchoolName, x.StandardCode, x.StandardName, LearnSystem = (x.LearnSystem.HasValue ? (x.LearnSystem.Value % 1 == 0 ? x.LearnSystem.Value.ToString("0") : x.LearnSystem.Value.ToString("0.0")) : ""), x.LearningformName, x.EducationName, EntranceDate = (x.EntranceDate.HasValue ? x.EntranceDate.Value.ToString("yyyy-MM-dd") : ""), PlanningGraduateDate = (x.PlanningGraduateDate.HasValue ? x.PlanningGraduateDate.Value.ToString("yyyy-MM-dd") : ""), x.GraduationResultName, x.StudentNo, x.PoliticsName, x.NationName, x.CampusName, x.CollegeName, x.ClassmajorCode, x.ClassmajorName, x.Remark, }).ToTable(namelist); string[] liststring = idlist.ToArray(); neh.Export(dt, liststring, "自定义信息"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Content("~/ExaminationApplayStudentList/InfoExport").AddMenuParameter() }); } /// /// 在DataTable中添加一序号列,编号从1依次递增 /// /// DataTable /// private DataTable AddSeriNumToDataTable(DataTable dt) { //需要返回的值 DataTable dtNew; if (dt.Columns.IndexOf("序号") >= 0) { dtNew = dt; } else //添加一序号列,并且在第一列 { int rowLength = dt.Rows.Count; int colLength = dt.Columns.Count; DataRow[] newRows = new DataRow[rowLength]; dtNew = new DataTable(); //在第一列添加“序号”列 dtNew.Columns.Add("序号"); for (int i = 0; i < colLength; i++) { dtNew.Columns.Add(dt.Columns[i].ColumnName); //复制dt中的数据 for (int j = 0; j < rowLength; j++) { if (newRows[j] == null) newRows[j] = dtNew.NewRow(); //将其他数据填充到第二列之后,因为第一列为新增的序号列 newRows[j][i + 1] = dt.Rows[j][i]; } } foreach (DataRow row in newRows) { dtNew.Rows.Add(row); } } //对序号列填充,从1递增 for (int i = 0; i < dt.Rows.Count; i++) { dtNew.Rows[i]["序号"] = i + 1; } return dtNew; } public ActionResult AddStudentsCheck(string IDNumberStr, Guid? schoolyearID, Guid? examinationBatchID, Guid? examinationTypeID, Guid? examinationProjectID, Guid? examinationProjectFeeID, int? feeTypeID) { List IDNumberlist = new List(); if (IDNumberStr != "" && IDNumberStr != null) { IDNumberlist = IDNumberStr.Split(',').ToList(); } var studentList = ExaminationSubjectServices.AddStudentsCheck(IDNumberlist, schoolyearID, examinationBatchID, examinationTypeID, examinationProjectID, examinationProjectFeeID, feeTypeID); //var successfulID = studentList.Select(x => x.IDNumber).ToList(); return Json(studentList); } } }