AdultSpecialtyPlanController.cs 32 KB

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