GrademajorController.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.ViewModel;
  7. using EMIS.Web.Controls;
  8. using EMIS.CommonLogic.Specialtyclass;
  9. using EMIS.ViewModel.Specialtyclass;
  10. using EMIS.Entities;
  11. using Bowin.Common.Utility;
  12. using Bowin.Common.Data;
  13. using Bowin.Web.Controls.Mvc;
  14. using Bowin.Common.Exceptions;
  15. using EMIS.Utility;
  16. using System.Text;
  17. namespace EMIS.Web.Controllers.Specialtyclass
  18. {
  19. [Authorization]
  20. public class GrademajorController : Controller
  21. {
  22. public IGrademajorServices GrademajorServices { get; set; }
  23. /// <summary>
  24. /// 年级专业页面
  25. /// </summary>
  26. /// <returns></returns>
  27. public ActionResult List()
  28. {
  29. return View();
  30. }
  31. /// <summary>
  32. /// 年级专业页面列表查询
  33. /// </summary>
  34. /// <param name="pararms"></param>
  35. /// <returns></returns>
  36. [HttpPost]
  37. public ActionResult List(QueryParamsModel pararms)
  38. {
  39. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  40. var schoolAreaID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea");
  41. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  42. var schoolyearID = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
  43. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  44. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  45. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  46. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  47. //在校状态
  48. var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
  49. return base.Json(GrademajorServices.GetGrademajorViewGrid(configuretView, schoolAreaID, collegeID, schoolyearID,
  50. standardID, educationID, learningformID, learnSystem, inSchoolStatus, (int)pararms.page, (int)pararms.rows));
  51. }
  52. /// <summary>
  53. /// 年级专业页面列表查询
  54. /// </summary>
  55. /// <param name="pararms"></param>
  56. /// <returns></returns>
  57. [HttpPost]
  58. public ActionResult StandardList(QueryParamsModel pararms)
  59. {
  60. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  61. var schoolAreaID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea");
  62. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  63. var schoolyearID = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
  64. //var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  65. //var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  66. //var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  67. //var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  68. //在校状态
  69. //var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
  70. return base.Json(GrademajorServices.GetStandardViewGrid(configuretView, schoolAreaID, collegeID, schoolyearID, (int)pararms.page, (int)pararms.rows));
  71. }
  72. /// <summary>
  73. /// 通过年级专业查询对应的标准专业
  74. /// </summary>
  75. /// <param name="pararms"></param>
  76. /// <returns></returns>
  77. [HttpPost]
  78. public ActionResult SchoolyearStandardList(QueryParamsModel pararms)
  79. {
  80. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  81. var schoolAreaID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea");
  82. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  83. var schoolyearID = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
  84. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  85. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  86. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  87. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  88. //在校状态
  89. var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
  90. return base.Json(GrademajorServices.GetSchoolyearStandardViewGrid(configuretView, schoolAreaID, collegeID, schoolyearID,
  91. standardID, educationID, learningformID, learnSystem, inSchoolStatus, (int)pararms.page, (int)pararms.rows));
  92. }
  93. /// <summary>
  94. /// 年级专业列表查询(无数据范围限制)
  95. /// </summary>
  96. /// <param name="pararms"></param>
  97. /// <returns></returns>
  98. [HttpPost]
  99. public ActionResult ListWithoutRange(QueryParamsModel pararms)
  100. {
  101. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  102. var schoolAreaID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea");
  103. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  104. var schoolyearID = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
  105. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  106. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  107. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  108. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  109. return base.Json(GrademajorServices.GetGrademajorViewGridWithoutRange(configuretView, schoolAreaID, collegeID,
  110. schoolyearID, standardID, educationID, learningformID, learnSystem, (int)pararms.page, (int)pararms.rows));
  111. }
  112. /// <summary>
  113. /// 年级专业中的专业信息StandardView(无数据范围)
  114. /// </summary>
  115. /// <param name="pararms"></param>
  116. /// <returns></returns>
  117. [HttpPost]
  118. public ActionResult GrademajorExcludeNotHaveStudentBindDropdownList(QueryParamsModel pararms)
  119. {
  120. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  121. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  122. var schoolyearID = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
  123. var list = GrademajorServices.GetStandardQueryableExcludeNotHaveStudentList(configuretView, collegeID, schoolyearID)
  124. .Select(x => new
  125. {
  126. x.StandardID,
  127. x.StandardCode,
  128. x.StandardName,
  129. x.StandardNameStr
  130. }).ToList();
  131. return Json(new { total = list.Count, rows = list });
  132. }
  133. /// <summary>
  134. /// 年级专业中的专业信息StandardView(无数据范围)
  135. /// </summary>
  136. /// <param name="pararms"></param>
  137. /// <returns></returns>
  138. [HttpPost]
  139. public ActionResult GrademajorBindComboGridOptions(QueryParamsModel pararms)
  140. {
  141. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  142. var schoolAreaID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea");
  143. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  144. var schoolyearID = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
  145. var result = GrademajorServices.GetStandardViewGrid(configuretView, schoolAreaID, collegeID, schoolyearID, (int)pararms.page, (int)pararms.rows);
  146. return base.Json(result);
  147. }
  148. /// <summary>
  149. /// 年级专业中的年级信息SchoolyearView(无数据范围)暂时不使用
  150. /// </summary>
  151. /// <param name="pararms"></param>
  152. /// <returns></returns>
  153. [HttpPost]
  154. public ActionResult SchoolyearBindComboGridOptions(QueryParamsModel pararms)
  155. {
  156. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  157. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  158. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  159. var result = GrademajorServices.GetSchoolyearViewGrid(configuretView, collegeID, standardID, (int)pararms.page, (int)pararms.rows);
  160. return base.Json(result);
  161. }
  162. /// <summary>
  163. /// 查询年级专业信息(院系所、专业信息,带数据范围)
  164. /// </summary>
  165. /// <param name="bindType"></param>
  166. /// <param name="collegeID"></param>
  167. /// <param name="standardID"></param>
  168. /// <returns></returns>
  169. [HttpPost]
  170. public ActionResult BindDropdownListByCollege(DropdownListBindType? bindType, Guid? collegeID, int? standardID)
  171. {
  172. List<DropdownListItem> list = this.GrademajorServices
  173. .GetGrademajorViewList(new ConfiguretView(), null, collegeID, null, standardID, null, null, null, null)
  174. .Select(x => new DropdownListItem
  175. {
  176. Text = x.Name,
  177. Value = x.GrademajorID
  178. }).ToList();
  179. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  180. DropdownList.FormatDropdownItemList(dbt, list);
  181. return base.Json(list);
  182. }
  183. /// <summary>
  184. /// 查询年级专业信息(院系所、年级、专业信息,带数据范围)
  185. /// </summary>
  186. /// <param name="bindType"></param>
  187. /// <param name="collegeID"></param>
  188. /// <param name="schoolyearID"></param>
  189. /// <param name="standardID"></param>
  190. /// <returns></returns>
  191. [HttpPost]
  192. public ActionResult BindComboGridByCollege(DropdownListBindType? bindType, Guid? collegeID,
  193. int? schoolyearID, int? standardID)
  194. {
  195. List<DropdownListItem> list = this.GrademajorServices
  196. .GetGrademajorViewList(new ConfiguretView(), null, collegeID, schoolyearID, standardID, null, null, null, null)
  197. .Select(x => new DropdownListItem
  198. {
  199. Text = x.Name,
  200. Value = x.GrademajorID
  201. }).ToList();
  202. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  203. DropdownList.FormatDropdownItemList(dbt, list);
  204. return base.Json(list);
  205. }
  206. /// <summary>
  207. /// 复制新增
  208. /// </summary>
  209. /// <param name="grademajorID"></param>
  210. /// <returns></returns>
  211. public ActionResult CopyAdd(Guid grademajorID)
  212. {
  213. GrademajorView grademajorView = new GrademajorView();
  214. grademajorView = GrademajorServices.GetGrademajorView(grademajorID);
  215. return View("Edit", grademajorView);
  216. }
  217. /// <summary>
  218. /// 复制新增
  219. /// </summary>
  220. /// <param name="grademajorView"></param>
  221. /// <returns></returns>
  222. [HttpPost]
  223. public ActionResult CopyAdd(GrademajorView grademajorView)
  224. {
  225. grademajorView.GrademajorID = Guid.Empty;
  226. return this.Edit(grademajorView);
  227. }
  228. /// <summary>
  229. /// 编辑(新增、修改,业务主键:年级专业编号或年级专业名称唯一)
  230. /// </summary>
  231. /// <param name="grademajorID"></param>
  232. /// <returns></returns>
  233. [HttpGet]
  234. public ActionResult Edit(Guid? grademajorID)
  235. {
  236. //临时性加参数控制、屏蔽列表进入无保存按钮权限
  237. ViewBag.Type = Request.Params["Type"];
  238. GrademajorView grademajorView = new GrademajorView();
  239. if (grademajorID.HasValue)
  240. {
  241. grademajorView = GrademajorServices.GetGrademajorView(grademajorID);
  242. }
  243. else
  244. {
  245. grademajorView.SchoolyearID = BaseExtensions.GetCurrentYearID();
  246. }
  247. return View(grademajorView);
  248. }
  249. /// <summary>
  250. /// 编辑(新增、修改,业务主键:年级专业编号或年级专业名称唯一)
  251. /// </summary>
  252. /// <param name="grademajorView"></param>
  253. /// <returns></returns>
  254. [HttpPost]
  255. public ActionResult Edit(GrademajorView grademajorView)
  256. {
  257. try
  258. {
  259. GrademajorServices.GrademajorEdit(grademajorView);
  260. return Json(new ReturnMessage()
  261. {
  262. IsSuccess = true,
  263. Message = "保存成功。"
  264. });
  265. }
  266. catch (Exception ex)
  267. {
  268. return Json(new ReturnMessage()
  269. {
  270. IsSuccess = false,
  271. Message = "保存失败,原因:" + ex.Message
  272. });
  273. }
  274. }
  275. /// <summary>
  276. /// 年级专业复制(批量添加)
  277. /// </summary>
  278. /// <returns></returns>
  279. public ActionResult BatchAdd()
  280. {
  281. return View();
  282. }
  283. /// <summary>
  284. /// 年级专业复制(批量添加)
  285. /// </summary>
  286. /// <param name="pararms"></param>
  287. /// <returns></returns>
  288. [HttpPost]
  289. public ActionResult BatchAdd(GrademajorView grademajorView)
  290. {
  291. try
  292. {
  293. var addCount = GrademajorServices.GrademajorBatchAdd(grademajorView);
  294. return Json(new ReturnMessage()
  295. {
  296. IsSuccess = true,
  297. Message = "添加成功(共添加了:" + addCount + "条)。"
  298. });
  299. }
  300. catch (Exception ex)
  301. {
  302. return Json(new ReturnMessage()
  303. {
  304. IsSuccess = false,
  305. Message = "添加失败,原因:" + ex.Message
  306. });
  307. }
  308. }
  309. /// <summary>
  310. /// 批量修改
  311. /// </summary>
  312. /// <returns></returns>
  313. public ActionResult BatchModifyControl(string grademajorIDs, int? schoolyearID, int? schoolcodeID)
  314. {
  315. try
  316. {
  317. string result = GrademajorServices.BatchModify(grademajorIDs, schoolyearID, schoolcodeID);
  318. return Json(new ReturnMessage()
  319. {
  320. IsSuccess = true,
  321. Message = result
  322. });
  323. }
  324. catch (Exception ex)
  325. {
  326. return Json(new ReturnMessage()
  327. {
  328. IsSuccess = false,
  329. Message = "批量修改失败,原因:" + ex.Message
  330. });
  331. }
  332. }
  333. /// <summary>
  334. /// 删除
  335. /// </summary>
  336. /// <param name="grademajorIDs"></param>
  337. /// <returns></returns>
  338. [HttpPost]
  339. public ActionResult Delete(string grademajorIDs)
  340. {
  341. try
  342. {
  343. List<Guid?> list = grademajorIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  344. .Select(x => (Guid?)new Guid(x)).ToList();
  345. GrademajorServices.GrademajorDelete(list);
  346. return base.Json("删除成功。");
  347. }
  348. catch (Exception ex)
  349. {
  350. string mge = ex.Message;
  351. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  352. if (num != null)
  353. {
  354. if (num.Number == 547)
  355. {
  356. mge = "请先删除所有关联的数据,如:班级信息、专业计划、执行计划、收费标准、毕业标准等";
  357. }
  358. }
  359. return base.Json("删除失败,原因:" + mge);
  360. }
  361. }
  362. /// <summary>
  363. /// 班级信息页面(查询对应的班级信息)
  364. /// </summary>
  365. /// <returns></returns>
  366. public ActionResult ClassmajorList()
  367. {
  368. return View();
  369. }
  370. /// <summary>
  371. /// 班级信息页面(查询对应的班级信息)
  372. /// </summary>
  373. /// <param name="pararms"></param>
  374. /// <returns></returns>
  375. [HttpPost]
  376. public ActionResult ClassmajorList(QueryParamsModel pararms)
  377. {
  378. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  379. var grademajorID = Request["grademajorID"].ParseStrTo<Guid>();
  380. int? inSchoolStatus = Request["DictionaryInschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["DictionaryInschoolStatus"].ParseStrTo<int>();
  381. return Json(GrademajorServices.GetClassmajorViewGrid(configuretView, grademajorID,
  382. inSchoolStatus, (int)pararms.page, (int)pararms.rows));
  383. }
  384. /// <summary>
  385. /// 查询年级专业所有班级学生
  386. /// </summary>
  387. /// <returns></returns>
  388. public ActionResult ClassStudentListView()
  389. {
  390. return View();
  391. }
  392. /// <summary>
  393. /// 查询年级专业所有班级学生
  394. /// </summary>
  395. /// <param name="pararms"></param>
  396. /// <returns></returns>
  397. [HttpPost]
  398. public ActionResult ClassStudentListView(QueryParamsModel pararms)
  399. {
  400. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  401. var grademajorID = Request["grademajorID"].ParseStrTo<Guid>();
  402. int? inSchoolStatus = Request["DictionaryInschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["DictionaryInschoolStatus"].ParseStrTo<int>();
  403. return Json(GrademajorServices.GetBaseStudentViewGrid(configuretView, grademajorID,
  404. inSchoolStatus, (int)pararms.page, (int)pararms.rows));
  405. }
  406. /// <summary>
  407. /// Excel导出
  408. /// </summary>
  409. /// <returns></returns>
  410. [HttpPost]
  411. public ActionResult Excel()
  412. {
  413. NpoiExcelHelper neh = new NpoiExcelHelper();
  414. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  415. var schoolAreaID = Request.Form["ddlSchoolArea"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlSchoolArea"].ParseStrTo<int>();
  416. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  417. var schoolyearID = Request.Form["DictionarySchoolyear"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolyear"].ParseStrTo<int>();
  418. var standardID = Request.Form["DictionaryStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStandard"].ParseStrTo<int>();
  419. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  420. var learningformID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  421. var learnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  422. //在校状态
  423. var inSchoolStatus = Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>();
  424. var dt = GrademajorServices.GetGrademajorViewList(configuretView, schoolAreaID, collegeID, schoolyearID, standardID,
  425. educationID, learningformID, learnSystem, inSchoolStatus)
  426. .Select(x => new
  427. {
  428. x.Code,
  429. x.Name,
  430. x.SchoolyearID,
  431. x.StandardCode,
  432. x.StandardID,
  433. x.StandardName,
  434. x.EducationName,
  435. x.LearningformName,
  436. LearnSystem = x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("#.#") : null,
  437. x.CollegeCode,
  438. x.CollegeName,
  439. x.GraduatingSemesterCode,
  440. x.StudentCount
  441. }).ToTable();
  442. string[] liststring = {
  443. "年级专业编号", "年级专业名称", "年级", "专业代码", "专业ID(Value)",
  444. "专业名称", RSL.Get("EducationID"), "学习形式", "学制",
  445. RSL.Get("CollegeCode"), RSL.Get("College"), "毕业学期", "人数"
  446. };
  447. var title = "年级专业信息";
  448. if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.No)
  449. {
  450. title = "年级专业信息(非在校)";
  451. }
  452. if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.Yes)
  453. {
  454. title = "年级专业信息(在校)";
  455. }
  456. neh.Export(dt, liststring, title + DateTime.Now.ToString("yyyyMMdd"));
  457. return Json(new ReturnMessage()
  458. {
  459. IsSuccess = true,
  460. Message = "导出成功。"
  461. });
  462. }
  463. /// <summary>
  464. /// 导出班级信息明细Excel
  465. /// </summary>
  466. /// <returns></returns>
  467. [HttpPost]
  468. public ActionResult Excel_Classmajor()
  469. {
  470. NpoiExcelHelper neh = new NpoiExcelHelper();
  471. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  472. var grademajorID = Request["grademajorID"].ParseStrTo<Guid>();
  473. int? inSchoolStatus = Request["DictionaryInschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["DictionaryInschoolStatus"].ParseStrTo<int>();
  474. var dt = GrademajorServices.GetClassmajorViewList(configuretView, grademajorID, inSchoolStatus)
  475. .Select(x => new
  476. {
  477. x.No,
  478. x.Name,
  479. x.ClassNum,
  480. x.SchoolyearID,
  481. x.SchoolcodeName,
  482. x.GraduatingSemesterCode,
  483. x.UserName,
  484. x.StudentCount,
  485. x.GrademajorCode,
  486. x.GrademajorName,
  487. x.FacultymajorCode,
  488. x.FacultymajorName
  489. }).ToTable();
  490. string[] liststring = {
  491. "班级编号", "班级名称", "班序", "年级", "入学学期", "毕业学期", "班主任",
  492. "人数", "年级专业编号", "年级专业名称", "院系专业编号", "院系专业名称"
  493. };
  494. var title = "年级专业班级信息";
  495. if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.No)
  496. {
  497. title = "年级专业班级信息(非在校)";
  498. }
  499. if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.Yes)
  500. {
  501. title = "年级专业班级信息(在校)";
  502. }
  503. neh.Export(dt, liststring, title + DateTime.Now.ToString("yyyyMMdd"));
  504. return Json(new ReturnMessage()
  505. {
  506. IsSuccess = true,
  507. Message = "导出成功。"
  508. });
  509. }
  510. /// <summary>
  511. /// 导出学生明细Excel
  512. /// </summary>
  513. /// <param name="pararms"></param>
  514. /// <returns></returns>
  515. [HttpPost]
  516. public ActionResult Excel_ClassStudent()
  517. {
  518. NpoiExcelHelper neh = new NpoiExcelHelper();
  519. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  520. var grademajorID = Request["grademajorID"].ParseStrTo<Guid>();
  521. int? inSchoolStatus = Request["DictionaryInschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["DictionaryInschoolStatus"].ParseStrTo<int>();
  522. var dt = GrademajorServices.GetBaseStudentViewList(configuretView, grademajorID, inSchoolStatus)
  523. .Select(x => new
  524. {
  525. x.LoginID,
  526. x.UserName,
  527. x.SexName,
  528. x.InSchoolStatusName,
  529. x.StudentStatusName,
  530. x.ClassmajorCode,
  531. x.ClassmajorName,
  532. x.SchoolyearID,
  533. x.GrademajorCode,
  534. x.GrademajorName,
  535. x.FacultymajorCode,
  536. x.FacultymajorName
  537. }).ToTable();
  538. string[] liststring = {
  539. "学号", "姓名", "性别", "在校状态", "学籍状态",
  540. "班级编号", "班级名称", "年级","年级专业编号", "年级专业名称",
  541. "院系专业编号", "院系专业名称"
  542. };
  543. var title = "年级专业学生信息";
  544. if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.No)
  545. {
  546. title = "年级专业学生信息(非在校)";
  547. }
  548. if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.Yes)
  549. {
  550. title = "年级专业学生信息(在校)";
  551. }
  552. neh.Export(dt, liststring, title + DateTime.Now.ToString("yyyyMMdd"));
  553. return Json(new ReturnMessage()
  554. {
  555. IsSuccess = true,
  556. Message = "导出成功。"
  557. });
  558. }
  559. /// <summary>
  560. /// Excel导入
  561. /// </summary>
  562. /// <param name="errorFile"></param>
  563. /// <param name="operationTips"></param>
  564. /// <returns></returns>
  565. [HttpGet]
  566. public ActionResult Import(string errorFile, string operationTips)
  567. {
  568. ViewBag.ErrorFile = errorFile;
  569. if (string.IsNullOrEmpty(operationTips))
  570. {
  571. operationTips = "点击查看失败原因...";
  572. }
  573. ViewBag.operationTips = operationTips;
  574. return View();
  575. }
  576. /// <summary>
  577. /// Excel导入
  578. /// </summary>
  579. /// <param name="file"></param>
  580. /// <returns></returns>
  581. [HttpPost]
  582. public ActionResult Import(HttpPostedFileBase file)
  583. {
  584. try
  585. {
  586. if (!NpoiExcelHelper.GetIsCompatible(file.FileName))
  587. {
  588. throw new Exception("格式错误,只允许导入xls或xlsx格式的Excel文件。");
  589. }
  590. Dictionary<string, string> cellheader = new Dictionary<string, string>
  591. {
  592. { "Code", "年级专业编号" },
  593. { "Name", "年级专业名称" },
  594. { "Abbreviation", "简称" },
  595. { "FacultymajorCode", "院系专业编号" },
  596. { "SchoolyearStr", "年级" },
  597. { "SchoolcodeStr", "入学学期" },
  598. { "Professional", "专业方向" },
  599. { "SchoolAreaStr", "校区" },
  600. { "Remark", "备注" },
  601. { "ErrorMessage", "未导入原因" }
  602. };
  603. StringBuilder errorMsg = new StringBuilder(); // 错误信息
  604. string sourceWebPath = FileUploadHelper.UploadFile(file);
  605. var sourcePhysicalPath = Server.MapPath(sourceWebPath);
  606. List<GrademajorView> errList = new List<GrademajorView>();
  607. List<GrademajorView> dataList = new List<GrademajorView>();
  608. int? inCount = 0; //导入个数
  609. int? upCount = 0; //更新个数
  610. int? errCount = 0; //失败个数
  611. //导入
  612. GrademajorServices.GrademajorImport(cellheader, out inCount, out upCount, out errList, out errCount, sourcePhysicalPath);
  613. System.IO.File.Delete(sourcePhysicalPath);//删除本地缓存文件
  614. if (errList.Count() > 0)
  615. {
  616. //获取错误数据文件路径
  617. string errorWebPath = string.Format("{0}", NpoiExcelHelper
  618. .EntityListToExcel2003(cellheader, errList, "年级专业信息导入失败文件", sourcePhysicalPath));
  619. ViewBag.ErrorFile = errorWebPath;
  620. string Errinfo = string.Format("提示:{0}条年级专业信息导入成功,{1}条年级专业信息更新成功,{2}条年级专业信息导入失败,点击查看。",
  621. inCount, upCount, errCount);
  622. ViewBag.operationTips = Errinfo;
  623. return RedirectToAction("MsgShow", "Common", new
  624. {
  625. WindowID = "none",
  626. msg = Errinfo,
  627. url = Url.Action("Import").AddMenuParameter() + "&errorFile=" + errorWebPath + "&operationTips="
  628. + Errinfo + "&WindowID=" + Request["WindowID"]
  629. });
  630. }
  631. else
  632. {
  633. string successInfo = string.Format("提示:{0}条年级专业信息导入成功,{1}条年级专业信息更新成功。", inCount, upCount);
  634. return RedirectToAction("MsgShow", "Common", new
  635. {
  636. WindowID = Request["WindowID"],
  637. msg = successInfo,
  638. url = Url.Action("List").AddMenuParameter()
  639. });
  640. }
  641. }
  642. catch (Exception ex)
  643. {
  644. return RedirectToAction("MsgShow", "Common", new
  645. {
  646. WindowID = "none",
  647. msg = "导入失败,原因:" + ex.Message,
  648. url = Url.Action("Import").AddMenuParameter() + "&WindowID=" + Request["WindowID"]
  649. });
  650. }
  651. }
  652. }
  653. }