SpecialtyPlanController.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using System.Text;
  7. using Bowin.Common.Utility;
  8. using Bowin.Common.Data;
  9. using Bowin.Common.JSON;
  10. using Bowin.Web.Controls.Mvc;
  11. using Bowin.Common.Exceptions;
  12. using EMIS.Utility;
  13. using EMIS.Entities;
  14. using EMIS.ViewModel;
  15. using EMIS.Web.Controls;
  16. using EMIS.ViewModel.CultureplanManage;
  17. using EMIS.ViewModel.CultureplanManage.PlanManagement;
  18. using EMIS.CommonLogic.CultureplanManage.PlanManagement;
  19. using EMIS.CommonLogic.UniversityManage.SpecialtyClassManage;
  20. using EMIS.CommonLogic.CalendarManage;
  21. namespace EMIS.Web.Controllers.CultureplanManage.PlanManagement
  22. {
  23. [Authorization]
  24. public class SpecialtyPlanController : Controller
  25. {
  26. public ISpecialtyPlanServices SpecialtyPlanServices { get; set; }
  27. /// <summary>
  28. /// 专业计划页面(普教)
  29. /// </summary>
  30. /// <returns></returns>
  31. public ActionResult List()
  32. {
  33. return View();
  34. }
  35. /// <summary>
  36. /// 专业计划页面(普教)列表查询
  37. /// </summary>
  38. /// <param name="pararms"></param>
  39. /// <returns></returns>
  40. [HttpPost]
  41. public ActionResult List(QueryParamsModel pararms)
  42. {
  43. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  44. var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
  45. var campusID = pararms.getExtraGuid("CampusDropdown");
  46. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  47. var yearID = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
  48. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  49. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  50. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  51. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  52. var grademajorID = pararms.getExtraGuid("GrademajorComboGrid");
  53. var coursematerialID = pararms.getExtraGuid("CourseComboGrid");
  54. var teachingModeID = pararms.getExtraInt("DictionaryTeachingMode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryTeachingMode");
  55. var handleModeID = pararms.getExtraInt("DictionaryHandleMode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryHandleMode");
  56. return base.Json(SpecialtyPlanServices.GetSpecialtyPlanViewGrid(configuretView, schoolyearID, campusID, collegeID,
  57. yearID, standardID, educationID, learningformID, learnSystem, grademajorID, coursematerialID, teachingModeID,
  58. handleModeID, (int)pararms.page, (int)pararms.rows));
  59. }
  60. /// <summary>
  61. /// 专业计划统计报表(普教)
  62. /// 注:普教版本(年级专业)
  63. /// </summary>
  64. /// <returns></returns>
  65. public ActionResult Report()
  66. {
  67. return View();
  68. }
  69. /// <summary>
  70. /// 专业复制(根据年级、专业信息进行复制)
  71. /// </summary>
  72. /// <returns></returns>
  73. public ActionResult SpecialtyCopyList()
  74. {
  75. return View();
  76. }
  77. /// <summary>
  78. /// 专业复制(根据年级、专业信息进行复制)
  79. /// </summary>
  80. /// <param name="specialtyPlanView"></param>
  81. /// <returns></returns>
  82. [HttpPost]
  83. public ActionResult SpecialtyCopyList(SpecialtyPlanView specialtyPlanView)
  84. {
  85. try
  86. {
  87. SpecialtyPlanServices.SpecialtyPlanEdit(specialtyPlanView);
  88. return Json(new ReturnMessage()
  89. {
  90. IsSuccess = true,
  91. Message = "保存成功。"
  92. });
  93. }
  94. catch (Exception ex)
  95. {
  96. return Json(new ReturnMessage()
  97. {
  98. IsSuccess = false,
  99. Message = "保存失败:" + ex.Message
  100. });
  101. }
  102. }
  103. /// <summary>
  104. /// 年级复制(根据年级进行复制)
  105. /// </summary>
  106. /// <returns></returns>
  107. public ActionResult GradeCopyList()
  108. {
  109. return View();
  110. }
  111. /// <summary>
  112. /// 复制新增
  113. /// </summary>
  114. /// <param name="specialtyPlanID"></param>
  115. /// <returns></returns>
  116. public ActionResult CopyAdd(Guid specialtyPlanID)
  117. {
  118. SpecialtyPlanView specialtyPlanView = new SpecialtyPlanView();
  119. specialtyPlanView = SpecialtyPlanServices.GetSpecialtyPlanView(specialtyPlanID);
  120. return View("Edit", specialtyPlanView);
  121. }
  122. /// <summary>
  123. /// 复制新增
  124. /// </summary>
  125. /// <param name="specialtyPlanView"></param>
  126. /// <returns></returns>
  127. [HttpPost]
  128. public ActionResult CopyAdd(SpecialtyPlanView specialtyPlanView)
  129. {
  130. specialtyPlanView.SpecialtyPlanID = Guid.Empty;
  131. return this.Edit(specialtyPlanView);
  132. }
  133. /// <summary>
  134. /// 编辑(新增、修改,业务主键:学年学期ID、年级专业ID、课程信息ID)
  135. /// </summary>
  136. /// <param name="specialtyPlanID"></param>
  137. /// <returns></returns>
  138. public ActionResult Edit(Guid? specialtyPlanID)
  139. {
  140. SpecialtyPlanView specialtyPlanView = new SpecialtyPlanView();
  141. if (specialtyPlanID.HasValue && specialtyPlanID != Guid.Empty)
  142. {
  143. specialtyPlanView = SpecialtyPlanServices.GetSpecialtyPlanView(specialtyPlanID);
  144. }
  145. else
  146. {
  147. specialtyPlanView.SchoolyearID = BaseExtensions.GetCurrentSchoolYearID();
  148. specialtyPlanView.CourseStructureID = (int)CF_CourseStructure.ClassroomTeaching;
  149. specialtyPlanView.CourseCategoryID = (int)CF_CourseCategory.Publiccourse;
  150. specialtyPlanView.CourseQualityID = (int)CF_CourseQuality.Required;
  151. specialtyPlanView.Credit = 0;
  152. specialtyPlanView.TheoryCourse = 0;
  153. specialtyPlanView.Practicehours = 0;
  154. specialtyPlanView.Trialhours = 0;
  155. specialtyPlanView.Totalhours = 0;
  156. specialtyPlanView.TheoryWeeklyNum = 0;
  157. specialtyPlanView.PracticeWeeklyNum = 0;
  158. specialtyPlanView.TrialWeeklyNum = 0;
  159. specialtyPlanView.SchoolweeksNum = 0;
  160. specialtyPlanView.WeeklyHours = 0;
  161. specialtyPlanView.WeeklyNum = 0;
  162. specialtyPlanView.StartWeeklyNum = 1;
  163. specialtyPlanView.EndWeeklyNum = 16;
  164. specialtyPlanView.IsNeedMaterial = true;
  165. specialtyPlanView.CourseFineID = (int)CF_CourseFine.No;
  166. specialtyPlanView.TeachinglanguageID = (int)CF_Teachinglanguage.Chinese;
  167. specialtyPlanView.ExaminationModeID = (int)CF_ExaminationMode.WrittenExam;
  168. specialtyPlanView.ResultTypeID = (int)CF_ResultType.Percentage;
  169. specialtyPlanView.HandleModeID = (int)CF_HandleMode.RequiredCourse;
  170. specialtyPlanView.ResultTypeID = (int)CF_ResultType.Percentage;
  171. }
  172. return View(specialtyPlanView);
  173. }
  174. /// <summary>
  175. /// 编辑(新增、修改,业务主键:学年学期ID、年级专业ID、课程信息ID)
  176. /// </summary>
  177. /// <param name="specialtyPlanView"></param>
  178. /// <returns></returns>
  179. [HttpPost]
  180. public ActionResult Edit(SpecialtyPlanView specialtyPlanView)
  181. {
  182. try
  183. {
  184. SpecialtyPlanServices.SpecialtyPlanEdit(specialtyPlanView);
  185. return Json(new ReturnMessage()
  186. {
  187. IsSuccess = true,
  188. Message = "保存成功。"
  189. });
  190. }
  191. catch (Exception ex)
  192. {
  193. return Json(new ReturnMessage()
  194. {
  195. IsSuccess = false,
  196. Message = "保存失败:" + ex.Message
  197. });
  198. }
  199. }
  200. /// <summary>
  201. /// 专业课程模版批量新增(业务主键:学年学期ID、年级专业ID、课程信息ID)
  202. /// </summary>
  203. /// <returns></returns>
  204. [HttpGet]
  205. public ActionResult SpecialtyPlanBatchAdd()
  206. {
  207. SpecialtyPlanView specialtyPlanView = new SpecialtyPlanView();
  208. return View(specialtyPlanView);
  209. }
  210. /// <summary>
  211. /// 专业课程模版批量新增(业务主键:学年学期ID、年级专业ID、课程信息ID)
  212. /// </summary>
  213. /// <param name="specialtyPlanView"></param>
  214. /// <returns></returns>
  215. public ActionResult SpecialtyPlanBatchAdd(SpecialtyPlanView specialtyPlanView)
  216. {
  217. try
  218. {
  219. var specialtyCourseViewList = Request["specialtyCourseViewList"].JsonToObject<List<SpecialtyCourseView>>();
  220. string result = SpecialtyPlanServices.SpecialtyPlanBatchAdd(specialtyCourseViewList, specialtyPlanView);
  221. return Json(new ReturnMessage()
  222. {
  223. IsSuccess = true,
  224. Message = "新增成功" + result + "。"
  225. });
  226. }
  227. catch (Exception ex)
  228. {
  229. return Json(new ReturnMessage()
  230. {
  231. IsSuccess = false,
  232. Message = "新增失败,原因:" + ex.Message
  233. });
  234. }
  235. }
  236. /// <summary>
  237. /// 查询对应的未新增专业课程信息SpecialtyCourseView
  238. /// </summary>
  239. /// <param name="pararms"></param>
  240. /// <returns></returns>
  241. [HttpPost]
  242. public ActionResult SpecialtyCourseNoAddList(QueryParamsModel pararms)
  243. {
  244. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  245. var departmentID = pararms.getExtraGuid("DepartmentDropdown");
  246. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  247. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  248. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  249. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  250. var coursematerialID = pararms.getExtraGuid("CourseComboGrid");
  251. var starttermID = pararms.getExtraInt("DictionaryStartterm") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStartterm");
  252. var handleModeID = pararms.getExtraInt("DictionaryHandleMode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryHandleMode");
  253. var yearID = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
  254. var grademajorID = pararms.getExtraGuid("GrademajorID");
  255. return base.Json(SpecialtyPlanServices.GetSpecialtyCourseViewNoAddGrid(configuretView, departmentID, standardID,
  256. educationID, learningformID, learnSystem, coursematerialID, starttermID, handleModeID,
  257. yearID, grademajorID, (int)pararms.page, (int)pararms.rows));
  258. }
  259. /// <summary>
  260. /// 删除
  261. /// </summary>
  262. /// <param name="specialtyPlanIDs"></param>
  263. /// <returns></returns>
  264. [HttpPost]
  265. public ActionResult Delete(string specialtyPlanIDs)
  266. {
  267. try
  268. {
  269. List<Guid?> list = specialtyPlanIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  270. .Select(x => (Guid?)new Guid(x)).ToList();
  271. SpecialtyPlanServices.SpecialtyPlanDelete(list);
  272. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  273. }
  274. catch (Exception ex)
  275. {
  276. string mge = ex.Message;
  277. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  278. if (num != null)
  279. {
  280. if (num.Number == 547)
  281. {
  282. mge = "请先删除与其关联的数据,如:执行计划等。";
  283. }
  284. }
  285. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + mge });
  286. }
  287. }
  288. /// <summary>
  289. /// 专业计划执行
  290. /// </summary>
  291. /// <param name="specialtyPlanIDs"></param>
  292. /// <returns></returns>
  293. [HttpPost]
  294. public ActionResult SpecialtyPlanExecute(string specialtyPlanIDs)
  295. {
  296. try
  297. {
  298. List<Guid?> list = specialtyPlanIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  299. .Select(x => (Guid?)new Guid(x)).ToList();
  300. string result = SpecialtyPlanServices.SpecialtyPlanExecute(list);
  301. return Json(new ReturnMessage()
  302. {
  303. IsSuccess = true,
  304. Message = "执行成功" + result + "。"
  305. });
  306. }
  307. catch (Exception ex)
  308. {
  309. return Json(new ReturnMessage()
  310. {
  311. IsSuccess = false,
  312. Message = "执行失败,原因:" + ex.Message
  313. });
  314. }
  315. }
  316. /// <summary>
  317. /// 查询对应的授课方式List
  318. /// </summary>
  319. /// <param name="pararms"></param>
  320. /// <returns></returns>
  321. [HttpPost]
  322. public ActionResult TeachingModeTypeList(QueryParamsModel pararms)
  323. {
  324. List<string> list = new List<string>();
  325. var specialtyPlanID = Request["specialtyPlanID"].ParseStrTo<Guid>();
  326. if (specialtyPlanID.HasValue && specialtyPlanID != Guid.Empty)
  327. {
  328. list = SpecialtyPlanServices.GetTeachingModeTypeList(specialtyPlanID);
  329. }
  330. else
  331. {
  332. list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory).ToString());
  333. }
  334. return base.Json(list);
  335. }
  336. /// <summary>
  337. /// 查询对应的授课地点List
  338. /// </summary>
  339. /// <param name="pararms"></param>
  340. /// <returns></returns>
  341. [HttpPost]
  342. public ActionResult TeachingPlaceList(QueryParamsModel pararms)
  343. {
  344. List<string> list = new List<string>();
  345. var specialtyPlanID = Request["specialtyPlanID"].ParseStrTo<Guid>();
  346. if (specialtyPlanID.HasValue && specialtyPlanID != Guid.Empty)
  347. {
  348. list = SpecialtyPlanServices.GetTeachingPlaceList(specialtyPlanID);
  349. }
  350. else
  351. {
  352. list.Add(((int)EMIS.ViewModel.EM_TeachingPlace.Multimedia).ToString());
  353. }
  354. return base.Json(list);
  355. }
  356. /// <summary>
  357. /// 查询对应的专业计划范围信息
  358. /// </summary>
  359. /// <returns></returns>
  360. public ActionResult PlanRangeList()
  361. {
  362. return View();
  363. }
  364. /// <summary>
  365. /// 查询对应的专业计划范围信息
  366. /// </summary>
  367. /// <param name="pararms"></param>
  368. /// <returns></returns>
  369. [HttpPost]
  370. public ActionResult PlanRangeList(QueryParamsModel pararms)
  371. {
  372. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  373. var specialtyPlanID = Request["specialtyPlanID"].ParseStrTo<Guid>();
  374. var classmajorID = pararms.getExtraGuid("ClassmajorDropdown");
  375. var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
  376. return Json(SpecialtyPlanServices.GetPlanRangeViewGrid(configuretView, specialtyPlanID,
  377. classmajorID, inSchoolStatus, (int)pararms.page, (int)pararms.rows));
  378. }
  379. /// <summary>
  380. /// 专业计划范围信息Excel导出
  381. /// </summary>
  382. /// <returns></returns>
  383. [HttpPost]
  384. public ActionResult PlanRangeListExcel()
  385. {
  386. return null;
  387. }
  388. /// <summary>
  389. /// 查询对应的专业计划人数信息
  390. /// </summary>
  391. /// <returns></returns>
  392. public ActionResult PlanStudentList()
  393. {
  394. return View();
  395. }
  396. /// <summary>
  397. /// 查询对应的专业计划人数信息
  398. /// </summary>
  399. /// <param name="pararms"></param>
  400. /// <returns></returns>
  401. [HttpPost]
  402. public ActionResult PlanStudentList(QueryParamsModel pararms)
  403. {
  404. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  405. var specialtyPlanID = Request["specialtyPlanID"].ParseStrTo<Guid>();
  406. var classmajorID = pararms.getExtraGuid("ClassmajorDropdown");
  407. var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
  408. return Json(SpecialtyPlanServices.GetBaseStudentViewGrid(configuretView, specialtyPlanID,
  409. classmajorID, inSchoolStatus, (int)pararms.page, (int)pararms.rows));
  410. }
  411. /// <summary>
  412. /// 专业计划人数信息Excel导出
  413. /// </summary>
  414. /// <returns></returns>
  415. [HttpPost]
  416. public ActionResult PlanStudentListExcel()
  417. {
  418. return null;
  419. }
  420. /// <summary>
  421. /// 新增(数据库表,用于报表)
  422. /// </summary>
  423. /// <param name="SpecialtyPlans"></param>
  424. /// <returns></returns>
  425. public ActionResult CreateIDTempTable(string specialtyPlanIDs)
  426. {
  427. string tempTableName = Guid.NewGuid().ToString();
  428. tempTableName = tempTableName.Replace("-", "");
  429. List<Guid?> ids = new List<Guid?>();
  430. if (!string.IsNullOrEmpty(specialtyPlanIDs))
  431. {
  432. ids = specialtyPlanIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  433. }
  434. SpecialtyPlanServices.CreateIDTempTable(tempTableName, ids);
  435. return base.Json(tempTableName);
  436. }
  437. /// <summary>
  438. /// 删除(数据库表,用于报表)
  439. /// </summary>
  440. /// <param name="tempTableName"></param>
  441. /// <returns></returns>
  442. public ActionResult DeleteTempTable(string tempTableName)
  443. {
  444. try
  445. {
  446. SpecialtyPlanServices.DeleteTempTable(tempTableName);
  447. return base.Json(new ReturnMessage
  448. {
  449. IsSuccess = true,
  450. Message = "删除成功。"
  451. });
  452. }
  453. catch (Exception ex)
  454. {
  455. return base.Json(new ReturnMessage
  456. {
  457. IsSuccess = false,
  458. Message = "删除失败,原因:" + ex.Message
  459. });
  460. }
  461. }
  462. /// <summary>
  463. /// Excel导出
  464. /// </summary>
  465. /// <returns></returns>
  466. [HttpPost]
  467. public ActionResult Excel()
  468. {
  469. NpoiExcelHelper neh = new NpoiExcelHelper();
  470. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  471. var schoolyearID = Request.Form["SchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  472. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  473. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  474. var yearID = Request.Form["DictionarySchoolyear"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolyear"].ParseStrTo<int>();
  475. var standardID = Request.Form["DictionaryStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStandard"].ParseStrTo<int>();
  476. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  477. var learningformID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  478. var learnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  479. var grademajorID = Request.Form["GrademajorComboGrid"].ParseStrTo<Guid>();
  480. var coursematerialID = Request.Form["CourseComboGrid"].ParseStrTo<Guid>();
  481. var teachingModeID = Request.Form["DictionaryTeachingMode"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryTeachingMode"].ParseStrTo<int>();
  482. var handleModeID = Request.Form["DictionaryHandleMode"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryHandleMode"].ParseStrTo<int>();
  483. var dt = SpecialtyPlanServices.GetSpecialtyPlanViewList(configuretView, schoolyearID, campusID, collegeID, yearID,
  484. standardID, educationID, learningformID, learnSystem, grademajorID, coursematerialID, teachingModeID, handleModeID)
  485. .Select(x => new
  486. {
  487. x.SchoolyearCode,
  488. x.CollegeCode,
  489. x.CollegeName,
  490. x.GradeID,
  491. x.GrademajorCode,
  492. x.GrademajorName,
  493. x.SchoolyearNumName,
  494. x.SchoolcodeName,
  495. x.StarttermName,
  496. x.CourseCode,
  497. x.CourseName,
  498. x.CourseStructureName,
  499. x.CourseCategoryName,
  500. x.CourseTypeName,
  501. x.CourseQualityName,
  502. Credit = x.Credit.HasValue ? x.Credit.Value.ToString("#.#") : null,
  503. x.TheoryCourse,
  504. x.Practicehours,
  505. x.Trialhours,
  506. x.Totalhours,
  507. x.TheoryWeeklyNum,
  508. x.PracticeWeeklyNum,
  509. x.TrialWeeklyNum,
  510. x.SchoolweeksNum,
  511. x.WeeklyHours,
  512. x.WeeklyNum,
  513. x.StartWeeklyNum,
  514. x.EndWeeklyNum,
  515. x.DepartmentName,
  516. x.IsSpecialtycoreName,
  517. x.IsCooperationName,
  518. x.IsRequiredName,
  519. x.IsElectiveName,
  520. x.IsNetworkCourseName,
  521. x.IsMainCourseName,
  522. x.IsNeedMaterialName,
  523. x.CourseFineName,
  524. x.PracticeTypeName,
  525. x.TeachinglanguageName,
  526. x.ExaminationModeName,
  527. x.ResultTypeName,
  528. x.HandleModeName,
  529. x.TeachingModeIDListName,
  530. x.TeachingPlaceIDListName,
  531. x.PlanRange,
  532. x.StudentCount,
  533. x.PlanStatusName,
  534. x.Remark
  535. }).ToTable();
  536. string[] liststring = {
  537. "学年学期", RSL.Get("CollegeCode"), RSL.Get("CollegeName"), "年级", "年级专业编号", "年级专业名称",
  538. "开课学年", "学期", "开课学期", "课程代码", "课程名称", "课程结构", "课程属性", "课程类型",
  539. "课程性质", "课程学分", "理论学时", "实践学时", "实验学时", "总学时", "理论周次", "实践周次",
  540. "实验周次", "总周次", "周学时", "每周次数", "开始周次", "结束周次", "开课教研室", "是否专业核心",
  541. "是否合作开发", RSL.Get("IsRequired"), "是否网上选修", "是否网络课程", "是否学位课程", "是否需要教材",
  542. "精品课程", "实践类型", "授课语言", "考试方式", "成绩类型", "处理方式", "授课方式", "授课地点",
  543. "计划范围", "人数", "计划状态", "备注"
  544. };
  545. neh.Export(dt, liststring, "专业计划信息" + DateTime.Now.ToString("yyyyMMdd"));
  546. return Json(new ReturnMessage()
  547. {
  548. IsSuccess = true,
  549. Message = "导出成功。"
  550. });
  551. }
  552. /// <summary>
  553. /// Excel导入
  554. /// </summary>
  555. /// <param name="errorFile"></param>
  556. /// <param name="operationTips"></param>
  557. /// <returns></returns>
  558. [HttpGet]
  559. public ActionResult Import(string errorFile, string operationTips)
  560. {
  561. ViewBag.ErrorFile = errorFile;
  562. if (string.IsNullOrEmpty(operationTips))
  563. {
  564. operationTips = "点击查看失败原因...";
  565. }
  566. ViewBag.operationTips = operationTips;
  567. return View();
  568. }
  569. /// <summary>
  570. /// Excel导入
  571. /// </summary>
  572. /// <param name="file"></param>
  573. /// <returns></returns>
  574. [HttpPost]
  575. public ActionResult Import(HttpPostedFileBase file)
  576. {
  577. try
  578. {
  579. if (!NpoiExcelHelper.GetIsCompatible(file.FileName))
  580. {
  581. throw new Exception("格式错误,只允许导入xls或xlsx格式的Excel文件。");
  582. }
  583. Dictionary<string, string> cellheader = new Dictionary<string, string>
  584. {
  585. { "GrademajorName", "年级专业名称" },
  586. { "SchoolyearNumStr", "开课学年" },
  587. { "SchoolcodeStr", "学期" },
  588. { "SchoolyearCode", "学年学期" },
  589. { "CourseCode", "课程代码" },
  590. { "CourseName", "课程名称" },
  591. { "CourseStructureStr", "课程结构" },
  592. { "CourseCategoryStr", "课程属性" },
  593. { "CourseTypeStr", "课程类型" },
  594. { "CourseQualityStr", "课程性质" },
  595. { "CreditStr", "课程学分" },
  596. { "TheoryCourseStr", "理论学时" },
  597. { "PracticehoursStr", "实践学时" },
  598. { "TrialhoursStr", "实验学时" },
  599. { "TheoryWeeklyNumStr", "理论周次" },
  600. { "PracticeWeeklyNumStr", "实践周次" },
  601. { "TrialWeeklyNumStr", "实验周次" },
  602. { "DepartmentName", "开课教研室" },
  603. { "IsSpecialtycoreStr", "是否专业核心" },
  604. { "IsCooperationStr", "是否合作开发" },
  605. { "IsRequiredStr", RSL.Get("IsRequired") },
  606. { "IsElectiveStr", "是否网上选修" },
  607. { "IsNetworkCourseStr", "是否网络课程" },
  608. { "IsMainCourseStr", "是否学位课程" },
  609. { "IsNeedMaterialStr", "是否需要教材" },
  610. { "CourseFineStr", "精品课程" },
  611. { "PracticeTypeStr", "实践类型" },
  612. { "TeachinglanguageStr", "授课语言" },
  613. { "ExaminationModeStr", "考试方式" },
  614. { "ResultTypeStr", "成绩类型" },
  615. { "HandleModeStr", "处理方式" },
  616. { "TeachingModeIDListStr", "授课方式" },
  617. { "TeachingPlaceIDListStr", "授课地点" },
  618. { "Remark", "备注" },
  619. { "ErrorMessage", "未导入原因" }
  620. };
  621. StringBuilder errorMsg = new StringBuilder(); // 错误信息
  622. string sourceWebPath = FileUploadHelper.UploadFile(file);
  623. var sourcePhysicalPath = Server.MapPath(sourceWebPath);
  624. List<SpecialtyPlanView> errList = new List<SpecialtyPlanView>();
  625. List<SpecialtyPlanView> dataList = new List<SpecialtyPlanView>();
  626. int? inCount = 0; //导入个数
  627. int? upCount = 0; //更新个数
  628. int? errCount = 0; //失败个数
  629. //导入
  630. SpecialtyPlanServices.SpecialtyPlanImport(cellheader, out inCount, out upCount, out errList, out errCount, sourcePhysicalPath);
  631. System.IO.File.Delete(sourcePhysicalPath);//删除本地缓存文件
  632. if (errList.Count() > 0)
  633. {
  634. //获取错误数据文件路径
  635. string errorWebPath = string.Format("{0}", NpoiExcelHelper.EntityListToExcel2003(cellheader, errList, "专业计划信息导入失败文件", sourcePhysicalPath));
  636. ViewBag.ErrorFile = errorWebPath;
  637. string Errinfo = string.Format("提示:{0}条专业计划信息导入成功,{1}条专业计划信息更新成功,{2}条专业计划信息导入失败,点击查看。",
  638. inCount, upCount, errCount);
  639. ViewBag.operationTips = Errinfo;
  640. return RedirectToAction("MsgShow", "Common", new
  641. {
  642. WindowID = "none",
  643. msg = Errinfo,
  644. url = Url.Action("Import").AddMenuParameter() + "&errorFile=" + errorWebPath + "&operationTips="
  645. + Errinfo + "&WindowID=" + Request["WindowID"]
  646. });
  647. }
  648. else
  649. {
  650. string successInfo = string.Format("提示:{0}条专业计划信息导入成功,{1}条专业计划信息更新成功。", inCount, upCount);
  651. return RedirectToAction("MsgShow", "Common", new
  652. {
  653. WindowID = Request["WindowID"],
  654. msg = successInfo,
  655. url = Url.Action("List").AddMenuParameter()
  656. });
  657. }
  658. }
  659. catch (Exception ex)
  660. {
  661. return RedirectToAction("MsgShow", "Common", new
  662. {
  663. WindowID = "none",
  664. msg = "导入失败,原因:" + ex.Message,
  665. url = Url.Action("Import").AddMenuParameter() + "&WindowID=" + Request["WindowID"]
  666. });
  667. }
  668. }
  669. }
  670. }