ExaminationScoreController.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. using Bowin.Common.Data;
  2. using Bowin.Common.Utility;
  3. using Bowin.Web.Controls.Mvc;
  4. using EMIS.CommonLogic.ExamManage;
  5. using EMIS.CommonLogic.ScoreManage;
  6. using EMIS.Utility;
  7. using EMIS.ViewModel;
  8. using EMIS.ViewModel.ScoreManage;
  9. using EMIS.Web.Controls;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Web;
  15. using System.Web.Mvc;
  16. using System.Data;
  17. using NPOI.XSSF.UserModel;
  18. using NPOI.SS.UserModel;
  19. using NPOI.HSSF.UserModel;
  20. using System.Reflection;
  21. namespace EMIS.Web.Controllers.ScoreManage
  22. {
  23. [Authorization]
  24. public class ExaminationScoreController : Controller
  25. {
  26. //
  27. // GET: /ExaminationScore/
  28. public IExaminationScoreServices examinationScoreServices { get; set; }
  29. public ILevelSettingSubjectServices levelSettingSubjectServices { get; set; }
  30. public CommonLogic.CalendarManage.ISchoolYearServices schoolYearServices { get; set; }
  31. public IExaminationBatchServices examinationBatchServices { get; set; }
  32. public CommonLogic.ExaminationApply.IExaminationTypeServices examinationTypeServices { get; set; }
  33. public IProjectFeeServices projectFeeServices { get; set; }
  34. public ActionResult List()
  35. {
  36. return View();
  37. }
  38. [HttpPost]
  39. public ActionResult List(QueryParamsModel pararms)
  40. {
  41. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  42. var schoolyearID = pararms.getExtraGuid("ddlSchoolyear");
  43. var examinationBatchID = pararms.getExtraGuid("cgExaminationBatch");
  44. var examinationTypeID = pararms.getExtraGuid("cgExaminationType");
  45. var examinationProjectID = pararms.getExtraGuid("cgExaminationProject");
  46. var schoolAreaID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea");
  47. var collegeID = pararms.getExtraGuid("cgCollege");
  48. var year = pararms.getExtraInt("ddlYear") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear");
  49. var standardID = pararms.getExtraInt("DictionaryStandard") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  50. var classmajorID = pararms.getExtraGuid("cgClassmajor");
  51. if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  52. return base.Json(examinationScoreServices.GetExaminationScoreViewGrid(configuretView, schoolyearID, examinationBatchID, examinationTypeID, examinationProjectID,
  53. schoolAreaID, collegeID, year, standardID, classmajorID, (int)pararms.page, (int)pararms.rows));
  54. }
  55. /// <summary>
  56. /// 复制新增
  57. /// </summary>
  58. /// <param name="examinationScoreID"></param>
  59. /// <returns></returns>
  60. public ActionResult CopyAdd(Guid examinationScoreID)
  61. {
  62. ExaminationScoreView examinationScoreView = new ExaminationScoreView();
  63. examinationScoreView = examinationScoreServices.GetExaminationScoreView(examinationScoreID);
  64. return View("Edit", examinationScoreView);
  65. }
  66. /// <summary>
  67. /// 复制新增
  68. /// </summary>
  69. /// <param name="studentListView"></param>
  70. /// <returns></returns>
  71. [HttpPost]
  72. public ActionResult CopyAdd(ExaminationScoreView examinationScoreView)
  73. {
  74. examinationScoreView.ExaminationScoreID = Guid.Empty;
  75. return this.Edit(examinationScoreView);
  76. }
  77. /// <summary>
  78. /// 新增/修改
  79. /// </summary>
  80. /// <param name="examinationScoreID"></param>
  81. /// <returns></returns>
  82. [HttpGet]
  83. public ActionResult Edit(Guid? examinationScoreID)
  84. {
  85. ExaminationScoreView examinationScoreView = new ExaminationScoreView();
  86. if (examinationScoreID.HasValue && examinationScoreID != Guid.Empty)
  87. {
  88. examinationScoreView = examinationScoreServices.GetExaminationScoreView(examinationScoreID);
  89. }
  90. return View(examinationScoreView);
  91. }
  92. /// <summary>
  93. /// 新增/修改
  94. /// </summary>
  95. /// <param name="studentListView"></param>
  96. /// <returns></returns>
  97. [HttpPost]
  98. public ActionResult Edit(ExaminationScoreView examinationScoreView)
  99. {
  100. try
  101. {
  102. examinationScoreServices.Edit(examinationScoreView);
  103. return Json(new ReturnMessage()
  104. {
  105. IsSuccess = true,
  106. Message = "保存成功。"
  107. });
  108. }
  109. catch (Exception ex)
  110. {
  111. return Json(new ReturnMessage()
  112. {
  113. IsSuccess = false,
  114. Message = "保存失败,原因:" + ex.Message
  115. });
  116. }
  117. }
  118. [HttpPost]
  119. public ActionResult Delete(string examinationScoreIDs)
  120. {
  121. try
  122. {
  123. var examinationScoreIDList = examinationScoreIDs.Split(',').Select(x => (Guid?)new Guid(x)).ToList();
  124. examinationScoreServices.Delete(examinationScoreIDList);
  125. return base.Json("删除成功");
  126. }
  127. catch (Exception ex)
  128. {
  129. string mge = ex.Message;
  130. return base.Json("删除失败,原因:" + mge + "!");
  131. }
  132. }
  133. public ActionResult Excel()
  134. {
  135. NpoiExcelHelper neh = new NpoiExcelHelper();
  136. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  137. var schoolyearID = Request.Form["ddlSchoolyear"].ParseStrTo<Guid>();
  138. var examinationBatchID = Request.Form["ddlExaminationBatch"].ParseStrTo<Guid>();
  139. var examinationTypeID = Request.Form["ddlExaminationType"].ParseStrTo<Guid>();
  140. var examinationProjectID = Request.Form["ddlExaminationProject"].ParseStrTo<Guid>();
  141. var schoolAreaID = Request.Form["ddlSchoolArea"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlSchoolArea"].ParseStrTo<int>();
  142. var collegeID = Request.Form["cgCollege"].ParseStrTo<Guid>();
  143. var year = Request.Form["ddlYear"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlYear"].ParseStrTo<int>();
  144. var standardID = Request.Form["DictionaryStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStandard"].ParseStrTo<int>();
  145. var classmajorID = Request.Form["cgClassmajor"].ParseStrTo<Guid>();
  146. var examinationScoreIDString = Request.Form["SelectedID"];
  147. var examinationScoreIDList = examinationScoreIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  148. var dt = examinationScoreServices.GetExaminationScoreViewList(configuretView, schoolyearID, examinationBatchID, examinationTypeID, examinationProjectID, schoolAreaID,
  149. collegeID, year, standardID, classmajorID, examinationScoreIDList)
  150. .Select(x => new
  151. {
  152. x.SchoolyearCode,
  153. x.ExaminationBatchName,
  154. x.ExaminationTypeName,
  155. x.ExaminationProjectName,
  156. x.ExaminationSubjectName,
  157. x.SchoolAreaName,
  158. x.CollegeName,
  159. x.SchoolyearNumID,
  160. x.StandardName,
  161. x.ClassmajorName,
  162. x.UserName,
  163. x.CertificatesTypeName,
  164. x.IDNumber,
  165. x.Score,
  166. x.Expire,
  167. x.Remark
  168. }).ToTable();
  169. string[] liststring = { "学年学期", "考试批次", "考试类型", "考试项目", "科目考核项", "校区", "院系", "年级", "专业", "班级", "姓名", "证件类型", "证件号码", "成绩", "有效日期", "备注" };
  170. neh.Export(dt, liststring, "项目成绩" + DateTime.Now.ToString("yyyyMMdd"));
  171. return Json(new ReturnMessage()
  172. {
  173. IsSuccess = true,
  174. Message = "导出成功。"
  175. });
  176. }
  177. [HttpPost]
  178. public ActionResult GetSubjectViewByProjectID(QueryParamsModel pararms)
  179. {
  180. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  181. var examinationProjectID = pararms.getExtraGuid("cgExaminationProject");
  182. var query = examinationScoreServices.GetSubjectByProjectGrid(configuretView, examinationProjectID, (int)pararms.page, (int)pararms.rows);
  183. return base.Json(query);
  184. }
  185. [HttpPost]
  186. public ActionResult SubjectDropDownList(DropdownListBindType? bindType, Guid? examinationProjectID)
  187. {
  188. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  189. var projectQuery = examinationScoreServices.GetSubjectByProjectList(new ConfiguretView());
  190. if (examinationProjectID.HasValue)
  191. {
  192. projectQuery = projectQuery.Where(x => x.ExaminationProjectID == examinationProjectID);
  193. }
  194. else
  195. {
  196. var emptyList = new List<DropdownListItem>();
  197. Bowin.Web.Controls.Mvc.DropdownList.FormatDropdownItemList(dbt, emptyList);
  198. return Json(emptyList);
  199. }
  200. List<DropdownListItem> list = projectQuery.Select(x => new { x.ExaminationSubjectID, x.ExaminationSubject }).Distinct()
  201. .OrderBy(x => x.ExaminationSubjectID)
  202. .Select(x => new DropdownListItem { Text = x.ExaminationSubject, Value = x.ExaminationSubjectID.ToString() }).ToList();
  203. Bowin.Web.Controls.Mvc.DropdownList.FormatDropdownItemList(dbt, list);
  204. return base.Json(list);
  205. }
  206. /// <summary>
  207. /// Excel导入
  208. /// </summary>
  209. /// <param name="errorFile"></param>
  210. /// <param name="operationTips"></param>
  211. /// <returns></returns>
  212. [HttpGet]
  213. public ActionResult Import(string errorFile, string operationTips)
  214. {
  215. ViewBag.ErrorFile = errorFile;
  216. if (string.IsNullOrEmpty(operationTips))
  217. {
  218. operationTips = "";
  219. }
  220. ViewBag.operationTips = operationTips;
  221. return View();
  222. }
  223. public object GetCellValueByType(ICell cell)
  224. {
  225. switch (cell.CellType)
  226. {
  227. case CellType.BLANK:
  228. return "";
  229. case CellType.BOOLEAN:
  230. return cell.BooleanCellValue;
  231. case CellType.ERROR:
  232. return cell.ErrorCellValue;
  233. case CellType.FORMULA:
  234. return cell.CellFormula;
  235. case CellType.NUMERIC:
  236. return cell.NumericCellValue;
  237. case CellType.STRING:
  238. return cell.StringCellValue;
  239. case CellType.Unknown:
  240. return null;
  241. default:
  242. return "";
  243. }
  244. }
  245. public List<T> convertToList<T>(DataTable dt) where T : new()
  246. {
  247.             //定义集合
  248.             List<T> ts = new List<T>();
  249.             //获得此模型的类型
  250.             Type type = typeof(T);
  251.             //定义一个临时的变量
  252.             string tempName = "";
  253.             //遍历datatable中所有数据行
  254.             foreach (DataRow dr in dt.Rows)
  255. {
  256. T t = new T();
  257.                 //获得此模型的公共属性
  258.                 PropertyInfo[] propertys = t.GetType().GetProperties();
  259.                 //遍历所有属性
  260.                 foreach (PropertyInfo pi in propertys)
  261. {
  262.                     //将此属性赋值给临时变量
  263.                     tempName = pi.Name;
  264.                     //检查datatable是否包含此列
  265.                     if (dt.Columns.Contains(tempName))
  266. {
  267.                         //判断此属性是否有setter,这个啥意思呢,就是我们的实体层的{get;set;}如果我们的实体有了set方法,就说明可以赋值!
  268.                         if (!pi.CanWrite) continue;
  269. {
  270.                             //取值  
  271.                             object value = dr[tempName];
  272. if (value != DBNull.Value)
  273. pi.SetValue(t, value, null);
  274. }
  275. }
  276. }
  277.                 //对象添加到泛型集合中
  278.                 ts.Add(t);
  279. }
  280. return ts;
  281. }
  282. [HttpPost]
  283. public ActionResult Import(HttpPostedFileBase file)
  284. {
  285. try
  286. {
  287. var schoolyearID = Request.Form["ddlSchoolyear"].ParseStrTo<Guid>();
  288. var examinationBatchID = Request.Form["ddlExaminationBatch"].ParseStrTo<Guid>();
  289. var examinationTypeID = Request.Form["ddlExaminationType"].ParseStrTo<Guid>();
  290. var examinationProjectID = Request.Form["ddlExaminationProject"].ParseStrTo<Guid>();
  291. var subjectList = examinationScoreServices.GetSubjectByProject(examinationProjectID);
  292. ////1、要把文件加载到程序中
  293. ////2、获取sheet
  294. ////3、获取所有行
  295. ////4、获取行中所有的数据
  296. ////5、将获取到的数据,按照原有的数据格式,存储到一个数据容器中
  297. string sourceWebPath = FileUploadHelper.UploadFile(file);
  298. var sourcePhysicalPath = Server.MapPath(sourceWebPath);
  299. var excel = new NpoiExcelHelper();
  300. DataTable dtnew = excel.Import(sourcePhysicalPath);
  301. //创建一个数据表,用来存储 从Excel中导入的数据
  302. DataTable dt = new DataTable();
  303. //得到Excel文件地址 是包含路径的fileName
  304. string excelFilePath = sourcePhysicalPath;
  305. //创建一个工作簿 2007版本及以上 使用XSSFWorkbook ,2007以前的版本 使用 使用HSSFWorkbook
  306. IWorkbook workbook = new HSSFWorkbook(file.InputStream);
  307. //创建一个sheet ,用来存储Excel中的一个Sheet
  308. //ISheet sheet = workbook.GetSheet("Sheet1");//根据sheet的名字获取
  309. ISheet sheet = workbook.GetSheetAt(0);//根据sheet的索引,索引从0开始
  310. //创建一个Row 存储第一行有效数据,通常 有可能是标题行
  311. IRow row = sheet.GetRow(sheet.FirstRowNum);
  312. //处理标题行, 遍历标题行中所有的单元格(Cell),每个单元格的值 即为列名
  313. for (int i = 0; i < row.Cells.Count; i++)
  314. {
  315. var item = row.Cells[i];
  316. object cellValue = this.GetCellValueByType(item);
  317. string columnName = "";//DataTable的列明
  318. if (cellValue == null || cellValue.ToString() == "")
  319. {
  320. columnName = "column" + dt.Columns.Count;//默认名
  321. }
  322. else
  323. {
  324. columnName = cellValue.ToString();//具体值单元格值 作为名字
  325. }
  326. dtnew.Columns[i].ColumnName = columnName;
  327. }
  328. //foreach (ICell item in row.Cells)
  329. //{
  330. // //往DataTable中添加Excel中对应的列的值
  331. // object cellValue = this.GetCellValueByType(item);
  332. // string columnName = "";//DataTable的列明
  333. // if (cellValue == null || cellValue.ToString() == "")
  334. // {
  335. // columnName = "column" + dt.Columns.Count;//默认名
  336. // }
  337. // else
  338. // {
  339. // columnName = cellValue.ToString();//具体值单元格值 作为名字
  340. // }
  341. // dtnew.Columns[0].ColumnName = columnName;
  342. // dt.Columns.Add(columnName);
  343. //}
  344. //遍历所有的有效数据 并将有效数据 添加到DataTable
  345. //for (int i = sheet.FirstRowNum + 1; i <= sheet.LastRowNum; i++)
  346. //{
  347. // IRow dataRow = sheet.GetRow(i);
  348. // DataRow dr = dt.NewRow();// 创建与dt表具有相同架构的新数据行(Row)
  349. // for (int j = 0; j < dataRow.Cells.Count; j++)
  350. // {
  351. // dr[j] = this.GetCellValueByType(dataRow.Cells[j]);
  352. // }
  353. // dt.Rows.Add(dr);//向dt数据表中添加一个数据行
  354. //}
  355. //将导入的数据表 绑定到dataGridView1
  356. //dataGridView1.DataSource = dt;
  357. if (!NpoiExcelHelper.GetIsCompatible(file.FileName))
  358. {
  359. throw new Exception("只允许上传xls和xlsx格式的Excel文件!");
  360. }
  361. List<string> errcellheader = new List<string>();
  362. #region 表单头
  363. Dictionary<string, string> cellheader = new Dictionary<string, string>
  364. {
  365. { "SchoolyearCode", "学年学期" },
  366. { "ExaminationBatchName", "考试批次" },
  367. { "ExaminationProjectName", "考试项目" },
  368. { "UserName", "姓名" },
  369. { "IDNumber", "证件号码" },
  370. };
  371. foreach(var subject in subjectList)
  372. {
  373. var code = ViewModel.Cache.IdNameExt.GetDictionaryItem(DictionaryItem.EX_ExaminationSubject.ToString()).Where(x => x.Value == subject.ExaminationSubjectID).Select(x => x.Code).FirstOrDefault();
  374. cellheader.Add(code, subject.ExaminationSubject);
  375. }
  376. cellheader.Add("ExpireImport", "有效日期");
  377. cellheader.Add("Remark", "备注");
  378. #endregion
  379. foreach (var dic in cellheader)
  380. {
  381. errcellheader.Add(dic.Value);
  382. }
  383. errcellheader.Add("错误信息");
  384. StringBuilder errorMsg = new StringBuilder(); // 错误信息
  385. //string sourceWebPath = FileUploadHelper.UploadFile(file);
  386. //var sourcePhysicalPath = Server.MapPath(sourceWebPath);
  387. List <ExaminationScoreView> errList = new List<ExaminationScoreView>();
  388. DataTable errdt = new DataTable();
  389. List<ExaminationScoreView> dataList = new List<ExaminationScoreView>();
  390. int errCount = 0;
  391. int OkCount = 0;
  392. examinationScoreServices.Import(cellheader, out OkCount, out errdt, out errCount, dtnew, sourcePhysicalPath, schoolyearID, examinationBatchID, examinationTypeID, examinationProjectID);
  393. System.IO.File.Delete(sourcePhysicalPath);//删除本地缓存文件
  394. if (errCount > 0)
  395. {
  396. //获取错误数据文件路径
  397. string errorWebPath = WriteErrorFile(excel, errcellheader, errdt);
  398. //string.Format("{0}", NpoiExcelHelper
  399. //.EntityListToExcel2003(cellheader, , "项目成绩导入失败文件", sourcePhysicalPath));
  400. ViewBag.ErrorFile = errorWebPath;
  401. string Errinfo = string.Format("提示:{0}条信息导入成功,{1}条信息导入失败,点击查看。",
  402. OkCount, errCount);
  403. ViewBag.operationTips = Errinfo;
  404. return RedirectToAction("MsgShow", "Common", new
  405. {
  406. WindowID = "none",
  407. msg = Errinfo,
  408. url = Url.Action("Import").AddMenuParameter() + "&errorFile=" + errorWebPath + "&operationTips=" + Errinfo + "&WindowID=" + Request["WindowID"]
  409. });
  410. }
  411. else
  412. {
  413. string successInfo = string.Format("提示:{0}条信息导入成功", OkCount);
  414. return RedirectToAction("MsgShow", "Common", new
  415. {
  416. WindowID = Request["WindowID"],
  417. msg = successInfo,
  418. url = Url.Action("Import").AddMenuParameter() + "&WindowID=" + Request["WindowID"]
  419. });
  420. }
  421. }
  422. catch (Exception ex)
  423. {
  424. return RedirectToAction("MsgShow", "Common", new
  425. {
  426. WindowID = Request["WindowID"],
  427. msg = "导入失败,原因:" + ex.Message + "!",
  428. url = Url.Action("Import").AddMenuParameter() + "&WindowID=" + Request["WindowID"]
  429. });
  430. }
  431. }
  432. private string WriteErrorFile(NpoiExcelHelper excel, IEnumerable<string> errorCellheader, DataTable errorTable)
  433. {
  434. var errorExcelBuff = excel.ExportMemoryStream(errorTable, "", errorCellheader.ToArray());
  435. var logicalPath = Const.LOCAL_SETTING_UPLOAD_FILEPATH + "/" + Guid.NewGuid().ToString() + ".xls";
  436. var physicalPath = System.Web.HttpContext.Current.Server.MapPath(logicalPath);
  437. var fs = System.IO.File.Create(physicalPath);
  438. fs.Write(errorExcelBuff, 0, errorExcelBuff.Length);
  439. fs.Flush();
  440. fs.Close();
  441. return UrlHelper.GenerateContentUrl(logicalPath, System.Web.HttpContext.Current.Request.RequestContext.HttpContext);
  442. }
  443. public ActionResult GetTemplateByProject(Guid? schoolyearID, Guid? examinationBatchID, Guid? examinationTypeID, Guid? examinationProjectID)
  444. {
  445. NpoiExcelHelper neh = new NpoiExcelHelper();
  446. var schoolyearCode = schoolYearServices.GetSchoolYear(schoolyearID).Code;
  447. var batchName = examinationBatchServices.GetExamBatch(examinationBatchID).Name;
  448. var typeName = examinationTypeServices.GetExaminationTypeViewInfo(examinationTypeID).Name;
  449. var projectName = projectFeeServices.GetProject(examinationProjectID).Name;
  450. var subjectList = examinationScoreServices.GetSubjectByProject(examinationProjectID);
  451. DataTable dt = new DataTable();
  452. dt.Columns.Add(new DataColumn());
  453. dt.Columns.Add(new DataColumn());
  454. //dt.Columns.Add(new DataColumn());
  455. dt.Columns.Add(new DataColumn());
  456. dt.Columns.Add(new DataColumn());
  457. dt.Columns.Add(new DataColumn());
  458. foreach (var subject in subjectList)
  459. {
  460. dt.Columns.Add(new DataColumn());
  461. }
  462. dt.Columns.Add(new DataColumn());
  463. dt.Columns.Add(new DataColumn());
  464. DataRow row = dt.NewRow();
  465. row[0] = schoolyearCode;
  466. row[1] = batchName;
  467. row[2] = projectName;
  468. dt.Rows.Add(row);
  469. List<string> idlist = new List<string>();
  470. idlist.Add("学年学期");
  471. idlist.Add("考试批次");
  472. idlist.Add("考试项目");
  473. idlist.Add("姓名");
  474. idlist.Add("证件号码");
  475. foreach (var subject in subjectList)
  476. {
  477. idlist.Add(subject.ExaminationSubject);
  478. }
  479. idlist.Add("有效日期");
  480. idlist.Add("备注");
  481. //var dt = new ConvertToDataTable
  482. //string[] liststring = { "学年学期", "考试批次", "考试类型", "考试项目", "姓名", "证件号码", "成绩", "有效日期", "备注" };
  483. string[] liststring = idlist.ToArray();
  484. neh.Export(dt, liststring, projectName + "项目成绩模板" + DateTime.Now.ToString("yyyyMMdd"));
  485. return RedirectToAction("MsgShow", "Common", new
  486. {
  487. WindowID = Request["WindowID"],
  488. msg = "导出模板成功",
  489. url = Url.Action("Import").AddMenuParameter()
  490. });
  491. }
  492. }
  493. }