NewStudentCollegeController.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.IO;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Web;
  8. using System.Web.Mvc;
  9. using Bowin.Common.Utility;
  10. using Bowin.Common.Data;
  11. using Bowin.Common.Linq;
  12. using Bowin.Common.JSON;
  13. using Bowin.Web.Controls.Mvc;
  14. using EMIS.Utility;
  15. using EMIS.Web.Controls;
  16. using EMIS.ViewModel;
  17. using EMIS.ViewModel.EnrollManage.NewStudentManage;
  18. using EMIS.CommonLogic.EnrollManage.NewStudentManage;
  19. namespace EMIS.Web.Controllers.EnrollManage.NewStudentManage
  20. {
  21. [Authorization]
  22. public class NewStudentCollegeController : Controller
  23. {
  24. public INewStudentCollegeServices newStudentCollegeServices { get; set; }
  25. /// <summary>
  26. /// 新生分配页面
  27. /// </summary>
  28. /// <returns></returns>
  29. public ActionResult List()
  30. {
  31. return View();
  32. }
  33. /// <summary>
  34. /// 新生分配页面列表查询
  35. /// </summary>
  36. /// <param name="pararms"></param>
  37. /// <returns></returns>
  38. [HttpPost]
  39. public ActionResult List(QueryParamsModel pararms)
  40. {
  41. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  42. var campusID = pararms.getExtraGuid("CampusDropdown");
  43. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  44. var gradeID = pararms.getExtraInt("DictionaryGrade") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGrade");
  45. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  46. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  47. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  48. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  49. var isPhotoUrl = pararms.getExtraInt("IsPhotoUrlDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsPhotoUrlDropdown");
  50. return base.Json(newStudentCollegeServices.GetNewStudentCollegeViewGrid(configuretView, campusID, collegeID, gradeID, standardID, educationID, learningformID, learnSystem, isPhotoUrl, (int)pararms.page, (int)pararms.rows));
  51. }
  52. /// <summary>
  53. /// 编辑
  54. /// </summary>
  55. /// <param name="newStudentID"></param>
  56. /// <returns></returns>
  57. [HttpGet]
  58. public ActionResult Edit(Guid? newStudentID)
  59. {
  60. NewStudentView newStudentView = new NewStudentView();
  61. if (newStudentID.HasValue && newStudentID != Guid.Empty)
  62. {
  63. newStudentView = newStudentCollegeServices.GetNewStudentCollegeView(newStudentID);
  64. }
  65. return View(newStudentView);
  66. }
  67. /// <summary>
  68. /// 导入分配
  69. /// </summary>
  70. /// <param name="errorFile"></param>
  71. /// <param name="operationTips"></param>
  72. /// <returns></returns>
  73. [HttpGet]
  74. public ActionResult AssignCollegeImport(string errorFile, string operationTips)
  75. {
  76. ViewBag.ErrorFile = errorFile;
  77. if (string.IsNullOrEmpty(operationTips))
  78. {
  79. operationTips = "点击查看失败原因...";
  80. }
  81. ViewBag.operationTips = operationTips;
  82. return View();
  83. }
  84. /// <summary>
  85. /// 导入分配
  86. /// </summary>
  87. /// <param name="file"></param>
  88. /// <returns></returns>
  89. [HttpPost]
  90. public ActionResult AssignCollegeImport(HttpPostedFileBase file)
  91. {
  92. try
  93. {
  94. if (!NpoiExcelHelper.GetIsCompatible(file.FileName))
  95. {
  96. throw new Exception("格式错误,只允许导入xls或xlsx格式的Excel文件。");
  97. }
  98. //注:只获取Excel模板中的有效列
  99. Dictionary<string, string> cellheader = new Dictionary<string, string>
  100. {
  101. { "OrderNoStr", "序号" }, //序号
  102. { "IDNumber", "身份证号" }, //身份证号
  103. { "Name", "姓名" }, //姓名
  104. { "GradeStr", "年级" }, //年级
  105. { "CollegeNo", RSL.Get("CollegeCode") }, //院系所代码
  106. { "ErrorMessage", "未导入原因" }
  107. };
  108. StringBuilder errorMsg = new StringBuilder(); // 错误信息
  109. string sourceWebPath = FileUploadHelper.UploadFile(file);
  110. var sourcePhysicalPath = Server.MapPath(sourceWebPath);
  111. List<NewStudentView> errList = new List<NewStudentView>();
  112. List<NewStudentView> dataList = new List<NewStudentView>();
  113. int? inCount = 0; //导入个数
  114. int? upCount = 0; //更新个数
  115. int? errCount = 0; //失败个数
  116. newStudentCollegeServices.NewStudentAssignCollegeImport(cellheader, out inCount, out upCount, out errList, out errCount, sourcePhysicalPath);
  117. System.IO.File.Delete(sourcePhysicalPath);//删除本地缓存文件
  118. if (errList.Count() > 0)
  119. {
  120. //获取错误数据文件路径
  121. string errorWebPath = string.Format("{0}", NpoiExcelHelper.EntityListToExcel2003(cellheader, errList, "名单归站导入失败文件", sourcePhysicalPath));
  122. ViewBag.ErrorFile = errorWebPath;
  123. string Errinfo = string.Format("提示:{0}个新生分配成功,{1}个新生分配更新成功,{2}个新生分配失败,点击查看。", inCount, upCount, errCount);
  124. ViewBag.operationTips = Errinfo;
  125. return RedirectToAction("MsgShow", "Common", new
  126. {
  127. WindowID = "none",
  128. msg = Errinfo,
  129. url = Url.Action("AssignCollegeImport").AddMenuParameter() + "&errorFile=" + errorWebPath + "&operationTips=" + Errinfo + "&WindowID=" + Request["WindowID"]
  130. });
  131. }
  132. else
  133. {
  134. string successInfo = string.Format("提示:{0}个新生分配成功,{1}个新生分配更新成功。", inCount, upCount);
  135. return RedirectToAction("MsgShow", "Common", new
  136. {
  137. WindowID = Request["WindowID"],
  138. msg = successInfo,
  139. url = Url.Action("List").AddMenuParameter()
  140. });
  141. }
  142. }
  143. catch (Exception ex)
  144. {
  145. return RedirectToAction("MsgShow", "Common", new
  146. {
  147. WindowID = "none",
  148. msg = "导入失败,原因:" + ex.Message,
  149. url = Url.Action("AssignCollegeImport").AddMenuParameter() + "&WindowID=" + Request["WindowID"]
  150. });
  151. }
  152. }
  153. /// <summary>
  154. /// 名单分配批量新增
  155. /// </summary>
  156. /// <returns></returns>
  157. [HttpGet]
  158. public ActionResult AssignCollegeBatchAdd()
  159. {
  160. NewStudentView newStudentView = new NewStudentView();
  161. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  162. newStudentView.CollegeID = user.CollegeID;
  163. return View(newStudentView);
  164. }
  165. /// <summary>
  166. /// 名单分配批量新增
  167. /// </summary>
  168. /// <param name="newStudentView"></param>
  169. /// <returns></returns>
  170. [HttpPost]
  171. public ActionResult AssignCollegeBatchAdd(NewStudentView newStudentView)
  172. {
  173. try
  174. {
  175. var newStudentIDList = Request["newStudentIDs"].JsonToObject<List<Guid?>>();
  176. string result = newStudentCollegeServices.NewStudentAssignCollegeConfirm(newStudentView.CollegeID, newStudentIDList);
  177. return Json(new ReturnMessage()
  178. {
  179. IsSuccess = true,
  180. Message = "分配成功" + result + "。"
  181. });
  182. }
  183. catch (Exception ex)
  184. {
  185. return Json(new ReturnMessage()
  186. {
  187. IsSuccess = false,
  188. Message = "分配失败,原因:" + ex.Message
  189. });
  190. }
  191. }
  192. /// <summary>
  193. /// 未分配名单页面列表查询
  194. /// </summary>
  195. /// <param name="pararms"></param>
  196. /// <returns></returns>
  197. [HttpPost]
  198. public ActionResult UnAssignCollegeList(QueryParamsModel pararms)
  199. {
  200. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  201. var gradeID = pararms.getExtraInt("DictionaryGrade") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGrade");
  202. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  203. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  204. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  205. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  206. return base.Json(newStudentCollegeServices.GetUnAssignNewStudentViewGrid(configuretView, gradeID, standardID, educationID, learningformID, learnSystem, (int)pararms.page, (int)pararms.rows));
  207. }
  208. /// <summary>
  209. /// 删除照片(批量删除)
  210. /// </summary>
  211. /// <param name="newStudentIDs"></param>
  212. /// <returns></returns>
  213. [HttpPost]
  214. public ActionResult PicDelete(string newStudentIDs)
  215. {
  216. try
  217. {
  218. List<Guid?> list = newStudentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  219. newStudentCollegeServices.PicDelete(list);
  220. return Json(new ReturnMessage()
  221. {
  222. IsSuccess = true,
  223. Message = "删除照片成功。"
  224. });
  225. }
  226. catch (Exception ex)
  227. {
  228. return Json(new ReturnMessage()
  229. {
  230. IsSuccess = false,
  231. Message = "删除照片失败:" + ex.Message
  232. });
  233. }
  234. }
  235. /// <summary>
  236. /// 取消分配
  237. /// </summary>
  238. /// <param name="newStudentIDs"></param>
  239. /// <returns></returns>
  240. [HttpPost]
  241. public ActionResult CancleAssign(string newStudentIDs)
  242. {
  243. try
  244. {
  245. List<Guid?> list = newStudentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  246. string result = newStudentCollegeServices.NewStudentCollegeCancleAssign(list);
  247. return Json(new ReturnMessage()
  248. {
  249. IsSuccess = true,
  250. Message = "取消分配成功" + result + "。"
  251. });
  252. }
  253. catch (Exception ex)
  254. {
  255. return Json(new ReturnMessage()
  256. {
  257. IsSuccess = false,
  258. Message = "取消分配失败,原因:" + ex.Message
  259. });
  260. }
  261. }
  262. /// <summary>
  263. /// 提交(需对招生专业进行验证,再提交,同时生成录取通知书编号(默认:年级+院系所代码+5位流水号))
  264. /// 注:个性化生成录取通知书编号(暂不考虑)
  265. /// </summary>
  266. /// <param name="newStudentIDs"></param>
  267. /// <returns></returns>
  268. [HttpPost]
  269. public ActionResult SubmitAssign(string newStudentIDs)
  270. {
  271. try
  272. {
  273. List<Guid?> list = newStudentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  274. string result = newStudentCollegeServices.NewStudentCollegeSubmitAssign(list);
  275. return Json(new ReturnMessage()
  276. {
  277. IsSuccess = true,
  278. Message = "提交成功" + result + "。"
  279. });
  280. }
  281. catch (Exception ex)
  282. {
  283. return Json(new ReturnMessage()
  284. {
  285. IsSuccess = false,
  286. Message = "提交失败,原因:" + ex.Message
  287. });
  288. }
  289. }
  290. /// <summary>
  291. /// 导入照片
  292. /// </summary>
  293. /// <param name="errorFile"></param>
  294. /// <param name="operationTips"></param>
  295. /// <returns></returns>
  296. [HttpGet]
  297. public ActionResult PicImport(string errorFile, string operationTips)
  298. {
  299. ViewBag.ErrorFile = errorFile;
  300. if (string.IsNullOrEmpty(operationTips))
  301. {
  302. operationTips = "点击查看失败原因...";
  303. }
  304. ViewBag.operationTips = operationTips;
  305. return View();
  306. }
  307. /// <summary>
  308. /// 导入照片
  309. /// </summary>
  310. /// <param name="file"></param>
  311. /// <param name="importPicType"></param>
  312. /// <returns></returns>
  313. [HttpPost]
  314. public ActionResult PicImport(HttpPostedFileBase file, string importPicType)
  315. {
  316. try
  317. {
  318. if (file.ContentLength <= 0)
  319. {
  320. throw new Exception("请选择你要上传的照片(注:格式为zip或rar的压缩包文件)。");
  321. }
  322. var acceptFileExtensions = new[] { ".zip", ".rar" };
  323. var fileExtensionName = Path.GetExtension(file.FileName);
  324. if (!acceptFileExtensions.Contains(fileExtensionName))
  325. {
  326. throw new Exception("格式错误,只允许上传zip或rar格式的压缩包文件。");
  327. }
  328. string fileSourceWebPath = null;
  329. string errorSourceWebPath = null;
  330. var photoPathList = FileUploadHelper.UploadFileAndExtractFile(file, out fileSourceWebPath, out errorSourceWebPath);
  331. System.IO.File.Delete(Server.MapPath(fileSourceWebPath));
  332. if (photoPathList == null || photoPathList.Count <= 0)
  333. {
  334. throw new Exception("压缩包中文件为空。");
  335. }
  336. var acceptPicExtensions = new[] { ".jpg", ".jpeg", ".png", ".bmp" };
  337. List<string> newPhotoPathList = new List<string>();
  338. foreach (var photoPath in photoPathList)
  339. {
  340. string photoExtensionName = Path.GetExtension(photoPath).ToLower();
  341. if (acceptPicExtensions.Contains(photoExtensionName))
  342. {
  343. newPhotoPathList.Add(photoPath);
  344. }
  345. else
  346. {
  347. throw new Exception("压缩包中含有不支持的照片格式。");
  348. }
  349. }
  350. int? inCount = 0;
  351. int? errCount = 0;
  352. var errDataTable = new DataTable();
  353. newStudentCollegeServices.NewStudentCollegePicImport(newPhotoPathList, importPicType, out inCount, out errCount, out errDataTable);
  354. if (errDataTable != null && errDataTable.Rows.Count > 0)
  355. {
  356. NpoiExcelHelper npoiExcelHelper = new NpoiExcelHelper();
  357. npoiExcelHelper.SaveInServer(errDataTable, Server.MapPath(errorSourceWebPath));
  358. string errorWebPath = string.Format("{0}", errorSourceWebPath);
  359. ViewBag.ErrorFile = errorWebPath;
  360. string Errinfo = string.Format("提示:{0}个照片导入成功,{1}个照片导入失败,点击查看。", inCount, errCount);
  361. ViewBag.operationTips = Errinfo;
  362. return RedirectToAction("MsgShow", "Common", new
  363. {
  364. WindowID = "none",
  365. msg = Errinfo,
  366. url = Url.Action("PicImport").AddMenuParameter() + "&errorFile=" + errorWebPath + "&operationTips=" + Errinfo + "&WindowID=" + Request["WindowID"]
  367. });
  368. }
  369. else
  370. {
  371. string successInfo = string.Format("提示:{0}个照片导入成功。", inCount);
  372. return RedirectToAction("MsgShow", "Common", new
  373. {
  374. WindowID = Request["WindowID"],
  375. msg = successInfo,
  376. url = Url.Action("List").AddMenuParameter()
  377. });
  378. }
  379. }
  380. catch (Exception ex)
  381. {
  382. return RedirectToAction("MsgShow", "Common", new
  383. {
  384. WindowID = "none",
  385. msg = "导入照片失败,原因:" + ex.Message,
  386. url = Url.Action("PicImport").AddMenuParameter() + "&WindowID=" + Request["WindowID"]
  387. });
  388. }
  389. }
  390. /// <summary>
  391. /// Excel导入名单(匹配相应的配置表,个性化配置)
  392. /// </summary>
  393. /// <param name="errorFile"></param>
  394. /// <param name="operationTips"></param>
  395. /// <returns></returns>
  396. [HttpGet]
  397. public ActionResult Import(string errorFile, string operationTips)
  398. {
  399. ViewBag.ErrorFile = errorFile;
  400. if (string.IsNullOrEmpty(operationTips))
  401. {
  402. operationTips = "点击查看失败原因...";
  403. }
  404. ViewBag.operationTips = operationTips;
  405. return View();
  406. }
  407. /// <summary>
  408. /// Excel导入名单(匹配相应的配置表,个性化配置)
  409. /// </summary>
  410. /// <param name="file"></param>
  411. /// <returns></returns>
  412. [HttpPost]
  413. public ActionResult Import(HttpPostedFileBase file)
  414. {
  415. try
  416. {
  417. if (!NpoiExcelHelper.GetIsCompatible(file.FileName))
  418. {
  419. throw new Exception("格式错误,只允许导入xls或xlsx格式的Excel文件。");
  420. }
  421. //注:与Excel模板一一对应(只读取Excel模板中的有效列)
  422. Dictionary<string, string> cellheader = new Dictionary<string, string>
  423. {
  424. { "ExamineeNum", "ksh" }, //考生号
  425. { "AdmissionTicketNo", "zkzh" }, //准考证号
  426. { "Name", "xm" }, //姓名
  427. { "SexStr", "xbdm" }, //性别代码
  428. { "NationStr", "mzdm" }, //民族代码
  429. { "PoliticsStr", "zzmmdm" }, //政治面貌代码
  430. { "BirthDateStr", "csrq" }, //出生日期
  431. { "gzrq", "gzrq" }, //gz日期
  432. { "byrq", "byrq" }, //毕业日期(以前读的学校的毕业日期)
  433. { "byxx", "byxx" }, //毕业学校
  434. { "wyyzdm", "wyyzdm" }, //外语语种代码
  435. { "zslbdm", "zslbdm" }, //招生类别代码
  436. { "zylbdm", "zylbdm" }, //职业类别代码
  437. { "whcddm", "whcddm" }, //文化程度代码
  438. { "FeaturesStr", "kstzbz" }, //考生特征标记
  439. { "IDNumber", "sfzh" }, //身份证号
  440. { "ZIPCode", "yzbm" }, //邮政编码
  441. { "Telephone", "lxdh" }, //联系电话
  442. { "Address", "txdz" }, //通讯地址
  443. { "TerritorialStr", "xzqhdm" }, //行政区划代码
  444. { "bh", "bh" }, //bh
  445. { "kslsczbz", "kslsczbz" },
  446. { "tdzyh", "tdzyh" },
  447. { "zydh1", "zydh1" },
  448. { "zydh2", "zydh2" },
  449. { "zydh3", "zydh3" },
  450. { "zydh4", "zydh4" },
  451. { "zydh5", "zydh5" },
  452. { "zydh6", "zydh6" },
  453. { "fczytj", "fczytj" },
  454. { "ffdy", "ffdy" },
  455. { "sfzltd", "sfzltd" },
  456. { "cjx01", "cjx01" },
  457. { "cjx02", "cjx02" },
  458. { "cjx03", "cjx03" },
  459. { "cjx04", "cjx04" },
  460. { "cjx05", "cjx05" },
  461. { "cjx06", "cjx06" },
  462. { "cjx07", "cjx07" },
  463. { "cjx08", "cjx08" },
  464. { "cjx10", "cjx10" },
  465. { "cjx11", "cjx11" },
  466. { "cjx13", "cjx13" },
  467. { "cjx14", "cjx14" },
  468. { "cjx15", "cjx15" },
  469. { "cjx16", "cjx16" },
  470. { "cjx17", "cjx17" },
  471. { "cjx18", "cjx18" },
  472. { "cjx19", "cjx19" },
  473. { "cjx31", "cjx31" },
  474. { "cjx32", "cjx32" },
  475. { "cjx34", "cjx34" },
  476. { "cjx35", "cjx35" },
  477. { "cjx36", "cjx36" },
  478. { "cjx37", "cjx37" },
  479. { "cjx38", "cjx38" },
  480. { "cjx91", "cjx91" },
  481. { "cjx92", "cjx92" },
  482. { "cjx93", "cjx93" },
  483. { "ScoreStr", "zf" }, //总分
  484. { "pxzf", "pxzf" }, //px总分
  485. { "ccdm", "ccdm" }, //层次代码
  486. { "tdzysxdm", "tdzysxdm" }, //td专业sx代码
  487. { "bkzysxdm", "bkzysxdm" }, //bk专业sx代码
  488. { "tdfs", "tdfs" }, //投档分数
  489. { "tdzydm", "tdzydm" }, //投档专业代码
  490. { "lqyxdm", "lqyxdm" }, //录取院校代码
  491. { "lqccdm", "lqccdm" }, //录取层次代码
  492. { "lqzysxdm", "lqzysxdm" }, //录取专业sx代码
  493. { "CustomStandardCode", "lqzy" }, //录取专业(省招代码),取后4位
  494. { "tdyydm", "tdyydm" },
  495. { "kstzbz", "kstzbz" },
  496. { "tdcs", "tdcs" },
  497. { "Remark", "bz" }, //备注
  498. { "ErrorMessage", "未导入原因" }
  499. };
  500. int? inCount = 0;
  501. int? upCount = 0;
  502. int? errCount = 0;
  503. List<NewStudentView> errList = new List<NewStudentView>();
  504. string sourceWebPath = FileUploadHelper.UploadFile(file);
  505. var sourcePhysicalPath = Server.MapPath(sourceWebPath);
  506. newStudentCollegeServices.NewStudentCollegeImport(cellheader, out inCount, out upCount, out errList, out errCount, sourcePhysicalPath);
  507. System.IO.File.Delete(sourcePhysicalPath);
  508. if (errList.Count() > 0)
  509. {
  510. string errorWebPath = string.Format("{0}", NpoiExcelHelper.EntityListToExcel2003(cellheader, errList, "招生信息导入失败文件", sourcePhysicalPath));
  511. ViewBag.ErrorFile = errorWebPath;
  512. string Errinfo = string.Format("提示:{0}条招生信息导入成功,{1}条招生信息更新成功,{2}条招生信息导入失败,点击查看。", inCount, upCount, errCount);
  513. ViewBag.operationTips = Errinfo;
  514. return RedirectToAction("MsgShow", "Common", new
  515. {
  516. WindowID = "none",
  517. msg = Errinfo,
  518. url = Url.Action("Import").AddMenuParameter() + "&errorFile=" + errorWebPath + "&operationTips="
  519. + Errinfo + "&WindowID=" + Request["WindowID"]
  520. });
  521. }
  522. else
  523. {
  524. string successInfo = string.Format("提示:{0}条招生信息导入成功,{1}条招生信息更新成功。", inCount, upCount);
  525. return RedirectToAction("MsgShow", "Common", new
  526. {
  527. WindowID = Request["WindowID"],
  528. msg = successInfo,
  529. url = Url.Action("List").AddMenuParameter()
  530. });
  531. }
  532. }
  533. catch (Exception ex)
  534. {
  535. return RedirectToAction("MsgShow", "Common", new
  536. {
  537. WindowID = "none",
  538. msg = "导入失败,原因:" + ex.Message,
  539. url = Url.Action("Import").AddMenuParameter() + "&WindowID=" + Request["WindowID"]
  540. });
  541. }
  542. }
  543. /// <summary>
  544. /// Excel导出
  545. /// </summary>
  546. /// <param name="pararms"></param>
  547. /// <returns></returns>
  548. [HttpPost]
  549. public ActionResult Excel(QueryParamsModel pararms)
  550. {
  551. NpoiExcelHelper neh = new NpoiExcelHelper();
  552. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  553. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  554. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  555. var gradeID = Request.Form["DictionaryGrade"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo<int>();
  556. var standardID = Request.Form["DictionaryStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStandard"].ParseStrTo<int>();
  557. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  558. var learningformID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  559. var learnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  560. var isPhotoUrl = Request.Form["IsPhotoUrlDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsPhotoUrlDropdown"].ParseStrTo<int>();
  561. var dt = newStudentCollegeServices.GetNewStudentCollegeViewList(configuretView, campusID, collegeID, gradeID, standardID, educationID, learningformID, learnSystem, isPhotoUrl)
  562. .Select(x => new
  563. {
  564. x.ExamineeNum,
  565. x.AdmissionTicketNo,
  566. x.Name,
  567. x.SexName,
  568. x.NationName,
  569. x.PoliticsName,
  570. BirthDate = x.BirthDate.HasValue ? x.BirthDate.Value.ToString("yyyy-MM-dd") : "",
  571. x.CertificatesTypeName,
  572. x.IDNumber,
  573. x.GradeID,
  574. x.SemesterName,
  575. x.StandardCode,
  576. x.StandardID,
  577. x.StandardName,
  578. x.EducationName,
  579. x.LearningformName,
  580. LearnSystem = x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("#.#") : null,
  581. EntranceDate = x.EntranceDate.HasValue ? x.EntranceDate.Value.ToString("yyyy-MM-dd") : "",
  582. x.Score,
  583. x.Telephone,
  584. x.Address,
  585. x.Dormitory,
  586. x.RecruitPictureUrl,
  587. x.CollegeNo,
  588. x.CollegeName,
  589. x.AssignStatusName,
  590. x.Remark
  591. }).ToTable();
  592. string[] liststring = {
  593. "考生号", "准考证号","姓名", "性别", "民族", "政治面貌", "出生日期", "证件类型", "身份证号",
  594. "年级", "学期", "专业代码", "专业ID(Value)", "专业名称", RSL.Get("EducationID"), "学习形式", "学制",
  595. "入学日期", "总分", "联系电话", "通讯地址", "宿舍地址", "照片Url", RSL.Get("CollegeCode"),
  596. RSL.Get("CollegeName"), "分配状态", "备注"
  597. };
  598. neh.Export(dt, liststring, "新生分配信息" + DateTime.Now.ToString("yyyyMMdd"));
  599. return Json(new ReturnMessage()
  600. {
  601. IsSuccess = true,
  602. Message = "导出成功。"
  603. });
  604. }
  605. }
  606. }