SpecialtyCourseController.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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.Web.Controls.Mvc;
  8. using Bowin.Common.Exceptions;
  9. using Bowin.Common.Utility;
  10. using Bowin.Common.Data;
  11. using EMIS.Utility;
  12. using EMIS.Web.Controls;
  13. using EMIS.Entities;
  14. using EMIS.ViewModel;
  15. using EMIS.ViewModel.CultureplanManage;
  16. using EMIS.CommonLogic.CultureplanManage.PlanManagement;
  17. namespace EMIS.Web.Controllers.CultureplanManage.PlanManagement
  18. {
  19. [Authorization]
  20. public class SpecialtyCourseController : Controller
  21. {
  22. public ISpecialtyCourseServices SpecialtyCourseServices { 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 collegeID = pararms.getExtraGuid("CollegeDropdown");
  41. var departmentID = pararms.getExtraGuid("DepartmentDropdown");
  42. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  43. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  44. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  45. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  46. var coursematerialID = pararms.getExtraGuid("CourseComboGrid");
  47. var courseTypeID = pararms.getExtraInt("DictionaryCourseType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryCourseType");
  48. var starttermID = pararms.getExtraInt("DictionaryStartterm") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStartterm");
  49. var teachingModeID = pararms.getExtraInt("DictionaryTeachingMode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryTeachingMode");
  50. var handleModeID = pararms.getExtraInt("DictionaryHandleMode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryHandleMode");
  51. var isEnable = pararms.getExtraInt("DictionaryIsEnable") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsEnable");
  52. return base.Json(SpecialtyCourseServices.GetSpecialtyCourseViewGrid(configuretView, collegeID, departmentID, standardID,
  53. educationID, learningformID, learnSystem, coursematerialID, courseTypeID, starttermID, teachingModeID, handleModeID,
  54. isEnable, (int)pararms.page, (int)pararms.rows));
  55. }
  56. /// <summary>
  57. /// 复制新增
  58. /// </summary>
  59. /// <param name="specialtyCourseID"></param>
  60. /// <returns></returns>
  61. public ActionResult CopyAdd(Guid specialtyCourseID)
  62. {
  63. SpecialtyCourseView specialtyCourseView = new SpecialtyCourseView();
  64. specialtyCourseView = SpecialtyCourseServices.GetSpecialtyCourseView(specialtyCourseID);
  65. return View("Edit", specialtyCourseView);
  66. }
  67. /// <summary>
  68. /// 复制新增
  69. /// </summary>
  70. /// <param name="specialtyCourseView"></param>
  71. /// <returns></returns>
  72. [HttpPost]
  73. public ActionResult CopyAdd(SpecialtyCourseView specialtyCourseView)
  74. {
  75. specialtyCourseView.SpecialtyCourseID = Guid.Empty;
  76. return this.Edit(specialtyCourseView);
  77. }
  78. /// <summary>
  79. /// 编辑(新增、修改,业务主键:专业信息ID、开课学期、课程信息ID)
  80. /// </summary>
  81. /// <param name="specialtyCourseID"></param>
  82. /// <returns></returns>
  83. public ActionResult Edit(Guid? specialtyCourseID)
  84. {
  85. SpecialtyCourseView specialtyCourseView = new SpecialtyCourseView();
  86. if (specialtyCourseID.HasValue && specialtyCourseID != Guid.Empty)
  87. {
  88. specialtyCourseView = SpecialtyCourseServices.GetSpecialtyCourseView(specialtyCourseID);
  89. }
  90. else
  91. {
  92. specialtyCourseView.CourseStructureID = (int)CF_CourseStructure.ClassroomTeaching;
  93. specialtyCourseView.CourseCategoryID = (int)CF_CourseCategory.Publiccourse;
  94. specialtyCourseView.CourseQualityID = (int)CF_CourseQuality.Required;
  95. specialtyCourseView.Credit = 0;
  96. specialtyCourseView.TheoryCourse = 0;
  97. specialtyCourseView.Practicehours = 0;
  98. specialtyCourseView.Trialhours = 0;
  99. specialtyCourseView.Totalhours = 0;
  100. specialtyCourseView.TheoryWeeklyNum = 0;
  101. specialtyCourseView.PracticeWeeklyNum = 0;
  102. specialtyCourseView.TrialWeeklyNum = 0;
  103. specialtyCourseView.SchoolweeksNum = 0;
  104. specialtyCourseView.WeeklyHours = 0;
  105. specialtyCourseView.WeeklyNum = 0;
  106. specialtyCourseView.StartWeeklyNum = 1;
  107. specialtyCourseView.EndWeeklyNum = 16;
  108. specialtyCourseView.IsNeedMaterial = true;
  109. specialtyCourseView.CourseFineID = (int)CF_CourseFine.No;
  110. specialtyCourseView.TeachinglanguageID = (int)CF_Teachinglanguage.Chinese;
  111. specialtyCourseView.ExaminationModeID = (int)CF_ExaminationMode.WrittenExam;
  112. specialtyCourseView.ResultTypeID = (int)CF_ResultType.Percentage;
  113. specialtyCourseView.HandleModeID = (int)CF_HandleMode.RequiredCourse;
  114. specialtyCourseView.ResultTypeID = (int)CF_ResultType.Percentage;
  115. specialtyCourseView.IsEnable = true;
  116. }
  117. return View(specialtyCourseView);
  118. }
  119. /// <summary>
  120. /// 编辑(新增、修改,业务主键:专业信息ID、开课学期、课程信息ID)
  121. /// </summary>
  122. /// <param name="specialtyCourseView"></param>
  123. /// <returns></returns>
  124. [HttpPost]
  125. public ActionResult Edit(SpecialtyCourseView specialtyCourseView)
  126. {
  127. try
  128. {
  129. SpecialtyCourseServices.SpecialtyCourseEdit(specialtyCourseView);
  130. return Json(new ReturnMessage()
  131. {
  132. IsSuccess = true,
  133. Message = "保存成功。"
  134. });
  135. }
  136. catch (Exception ex)
  137. {
  138. return Json(new ReturnMessage()
  139. {
  140. IsSuccess = false,
  141. Message = "保存失败:" + ex.Message
  142. });
  143. }
  144. }
  145. /// <summary>
  146. /// 删除
  147. /// </summary>
  148. /// <param name="specialtyCourseIDs"></param>
  149. /// <returns></returns>
  150. [HttpPost]
  151. public ActionResult Delete(string specialtyCourseIDs)
  152. {
  153. try
  154. {
  155. List<Guid?> list = specialtyCourseIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  156. .Select(x => (Guid?)new Guid(x)).ToList();
  157. SpecialtyCourseServices.SpecialtyCourseDelete(list);
  158. return base.Json(new ReturnMessage()
  159. {
  160. IsSuccess = true,
  161. Message = "删除成功。"
  162. });
  163. }
  164. catch (Exception ex)
  165. {
  166. return base.Json(new ReturnMessage()
  167. {
  168. IsSuccess = false,
  169. Message = "删除失败,原因:" + ex.Message
  170. });
  171. }
  172. }
  173. /// <summary>
  174. /// 查询对应的授课方式List
  175. /// </summary>
  176. /// <param name="pararms"></param>
  177. /// <returns></returns>
  178. [HttpPost]
  179. public ActionResult TeachingModeTypeList(QueryParamsModel pararms)
  180. {
  181. List<string> list = new List<string>();
  182. var specialtyCourseID = Request["specialtyCourseID"].ParseStrTo<Guid>();
  183. if (specialtyCourseID.HasValue && specialtyCourseID != Guid.Empty)
  184. {
  185. list = SpecialtyCourseServices.GetTeachingModeTypeList(specialtyCourseID);
  186. }
  187. else
  188. {
  189. list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory).ToString());
  190. }
  191. return base.Json(list);
  192. }
  193. /// <summary>
  194. /// 查询对应的授课地点List
  195. /// </summary>
  196. /// <param name="specialtyCourseID"></param>
  197. /// <returns></returns>
  198. [HttpPost]
  199. public ActionResult TeachingPlaceList(QueryParamsModel pararms)
  200. {
  201. List<string> list = new List<string>();
  202. var specialtyCourseID = Request["specialtyCourseID"].ParseStrTo<Guid>();
  203. if (specialtyCourseID.HasValue && specialtyCourseID != Guid.Empty)
  204. {
  205. list = SpecialtyCourseServices.GetTeachingPlaceList(specialtyCourseID);
  206. }
  207. else
  208. {
  209. list.Add(((int)EMIS.ViewModel.EM_TeachingPlace.Multimedia).ToString());
  210. }
  211. return base.Json(list);
  212. }
  213. /// <summary>
  214. /// Excel导入
  215. /// </summary>
  216. /// <param name="errorFile"></param>
  217. /// <param name="operationTips"></param>
  218. /// <returns></returns>
  219. [HttpGet]
  220. public ActionResult Import(string errorFile, string operationTips)
  221. {
  222. ViewBag.ErrorFile = errorFile;
  223. if (string.IsNullOrEmpty(operationTips))
  224. {
  225. operationTips = "点击查看失败原因...";
  226. }
  227. ViewBag.operationTips = operationTips;
  228. return View();
  229. }
  230. /// <summary>
  231. /// Excel导入
  232. /// </summary>
  233. /// <param name="file"></param>
  234. /// <returns></returns>
  235. [HttpPost]
  236. public ActionResult Import(HttpPostedFileBase file)
  237. {
  238. try
  239. {
  240. if (!NpoiExcelHelper.GetIsCompatible(file.FileName))
  241. {
  242. throw new Exception("格式错误,只允许导入xls或xlsx格式的Excel文件。");
  243. }
  244. Dictionary<string, string> cellheader = new Dictionary<string, string>
  245. {
  246. { "StandardCodeStr", "专业代码" },
  247. { "StandardNameStr", "专业名称" },
  248. { "EducationStr", RSL.Get("EducationName") },
  249. { "LearningformStr", "学习形式" },
  250. { "LearnSystemStr", "学制" },
  251. { "StarttermStr", "开课学期" },
  252. { "CourseCode", "课程代码" },
  253. { "CourseName", "课程名称" },
  254. { "CourseStructureStr", "课程结构" },
  255. { "CourseCategoryStr", "课程属性" },
  256. { "CourseTypeStr", "课程类型" },
  257. { "CourseQualityStr", "课程性质" },
  258. { "CreditStr", "课程学分" },
  259. { "TheoryCourseStr", "理论学时" },
  260. { "PracticehoursStr", "实践学时" },
  261. { "TrialhoursStr", "实验学时" },
  262. { "DepartmentName", "开课教研室" },
  263. { "IsSpecialtycoreStr", "是否专业核心" },
  264. { "IsCooperationStr", "是否合作开发" },
  265. { "IsRequiredStr", RSL.Get("IsRequired") },
  266. { "IsElectiveStr", "是否网上选修" },
  267. { "IsNetworkCourseStr", "是否网络课程" },
  268. { "IsMainCourseStr", "是否学位课程" },
  269. { "IsNeedMaterialStr", "是否需要教材" },
  270. { "CourseFineStr", "精品课程" },
  271. { "PracticeTypeStr", "实践类型" },
  272. { "TeachinglanguageStr", "授课语言" },
  273. { "ExaminationModeStr", "考试方式" },
  274. { "ResultTypeStr", "成绩类型" },
  275. { "HandleModeStr", "处理方式" },
  276. { "TeachingModeIDListStr", "授课方式" },
  277. { "TeachingPlaceIDListStr", "授课地点" },
  278. { "Remark", "备注" },
  279. { "ErrorMessage", "未导入原因" }
  280. };
  281. StringBuilder errorMsg = new StringBuilder(); // 错误信息
  282. string sourceWebPath = FileUploadHelper.UploadFile(file);
  283. var sourcePhysicalPath = Server.MapPath(sourceWebPath);
  284. List<SpecialtyCourseView> errList = new List<SpecialtyCourseView>();
  285. List<SpecialtyCourseView> dataList = new List<SpecialtyCourseView>();
  286. int? inCount = 0; //导入个数
  287. int? upCount = 0; //更新个数
  288. int? errCount = 0; //失败个数
  289. //导入
  290. SpecialtyCourseServices.SpecialtyCourseImport(cellheader, out inCount, out upCount, out errList, out errCount, sourcePhysicalPath);
  291. System.IO.File.Delete(sourcePhysicalPath);//删除本地缓存文件
  292. if (errList.Count() > 0)
  293. {
  294. //获取错误数据文件路径
  295. string errorWebPath = string.Format("{0}", NpoiExcelHelper
  296. .EntityListToExcel2003(cellheader, errList, "专业课程信息导入失败文件", sourcePhysicalPath));
  297. ViewBag.ErrorFile = errorWebPath;
  298. string Errinfo = string.Format("提示:{0}条专业课程信息导入成功,{1}条专业课程信息更新成功,{2}条专业课程信息导入失败,点击查看。",
  299. inCount, upCount, errCount);
  300. ViewBag.operationTips = Errinfo;
  301. return RedirectToAction("MsgShow", "Common", new
  302. {
  303. WindowID = "none",
  304. msg = Errinfo,
  305. url = Url.Action("Import").AddMenuParameter() + "&errorFile=" + errorWebPath + "&operationTips="
  306. + Errinfo + "&WindowID=" + Request["WindowID"]
  307. });
  308. }
  309. else
  310. {
  311. string successInfo = string.Format("提示:{0}条专业课程信息导入成功,{1}条专业课程信息更新成功。", inCount, upCount);
  312. return RedirectToAction("MsgShow", "Common", new
  313. {
  314. WindowID = Request["WindowID"],
  315. msg = successInfo,
  316. url = Url.Action("List").AddMenuParameter()
  317. });
  318. }
  319. }
  320. catch (Exception ex)
  321. {
  322. return RedirectToAction("MsgShow", "Common", new
  323. {
  324. WindowID = "none",
  325. msg = "导入失败,原因:" + ex.Message,
  326. url = Url.Action("Import").AddMenuParameter() + "&WindowID=" + Request["WindowID"]
  327. });
  328. }
  329. }
  330. /// <summary>
  331. /// Excel导出
  332. /// </summary>
  333. /// <returns></returns>
  334. [HttpPost]
  335. public ActionResult Excel()
  336. {
  337. NpoiExcelHelper neh = new NpoiExcelHelper();
  338. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  339. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  340. var departmentID = Request.Form["DepartmentDropdown"].ParseStrTo<Guid>();
  341. var standardID = Request.Form["DictionaryStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStandard"].ParseStrTo<int>();
  342. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  343. var learningformID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  344. var learnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  345. var coursematerialID = Request.Form["CourseComboGrid"].ParseStrTo<Guid>();
  346. var courseTypeID = Request.Form["DictionaryCourseType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryCourseType"].ParseStrTo<int>();
  347. var starttermID = Request.Form["DictionaryStartterm"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStartterm"].ParseStrTo<int>();
  348. var teachingModeID = Request.Form["DictionaryTeachingMode"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryTeachingMode"].ParseStrTo<int>();
  349. var handleModeID = Request.Form["DictionaryHandleMode"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryHandleMode"].ParseStrTo<int>();
  350. var isEnable = Request.Form["DictionaryIsEnable"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsEnable"].ParseStrTo<int>();
  351. var dt = SpecialtyCourseServices.GetSpecialtyCourseViewList(configuretView, collegeID, departmentID, standardID, educationID,
  352. learningformID, learnSystem, coursematerialID, courseTypeID, starttermID, teachingModeID, handleModeID, isEnable)
  353. .Select(x => new
  354. {
  355. x.StandardID,
  356. x.StandardCode,
  357. x.StandardName,
  358. x.EducationName,
  359. x.LearningformName,
  360. LearnSystem = x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("#.#") : null,
  361. x.StarttermName,
  362. x.CourseCode,
  363. x.CourseName,
  364. x.CourseStructureName,
  365. x.CourseCategoryName,
  366. x.CourseTypeName,
  367. x.CourseQualityName,
  368. Credit = x.Credit.HasValue ? x.Credit.Value.ToString("#.#") : null,
  369. x.TheoryCourse,
  370. x.Practicehours,
  371. x.Trialhours,
  372. x.Totalhours,
  373. x.TheoryWeeklyNum,
  374. x.PracticeWeeklyNum,
  375. x.TrialWeeklyNum,
  376. x.SchoolweeksNum,
  377. x.WeeklyHours,
  378. x.WeeklyNum,
  379. x.StartWeeklyNum,
  380. x.EndWeeklyNum,
  381. x.StartEndWeeklyNum,
  382. x.DepartmentName,
  383. x.IsSpecialtycoreName,
  384. x.IsCooperationName,
  385. x.IsRequiredName,
  386. x.IsElectiveName,
  387. x.IsNetworkCourseName,
  388. x.IsMainCourseName,
  389. x.IsNeedMaterialName,
  390. x.CourseFineName,
  391. x.PracticeTypeName,
  392. x.TeachinglanguageName,
  393. x.ExaminationModeName,
  394. x.ResultTypeName,
  395. x.HandleModeName,
  396. x.TeachingModeIDListName,
  397. x.TeachingPlaceIDListName,
  398. x.Remark
  399. }).ToTable();
  400. string[] liststring = {
  401. "专业ID(Value)", "专业代码", "专业名称", RSL.Get("EducationID"), "学习形式", "学制", "开课学期",
  402. "课程代码", "课程名称", "课程结构", "课程属性", "课程类型", "课程性质", "课程学分", "理论学时",
  403. "实践学时", "实验学时", "总学时", "理论周次", "实践周次", "实验周次", "总周次", "周学时",
  404. "每周次数", "开始周次", "结束周次", "起止周次", "开课教研室", "是否专业核心", "是否合作开发",
  405. RSL.Get("IsRequired"), "是否网上选修", "是否网络课程", "是否学位课程", "是否需要教材",
  406. "精品课程", "实践类型", "授课语言", "考试方式", "成绩类型", "处理方式", "授课方式",
  407. "授课地点", "备注"
  408. };
  409. neh.Export(dt, liststring, "专业课程信息" + DateTime.Now.ToString("yyyyMMdd"));
  410. return Json(new ReturnMessage()
  411. {
  412. IsSuccess = true,
  413. Message = "导出成功。"
  414. });
  415. }
  416. }
  417. }