PlanApplicationController.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Bowin.Web.Controls.Mvc;
  7. using Bowin.Common.Exceptions;
  8. using Bowin.Common.Utility;
  9. using Bowin.Common.Data;
  10. using Bowin.Common.JSON;
  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.ViewModel.CultureplanManage.PlanManagement;
  17. using EMIS.CommonLogic.CultureplanManage.PlanManagement;
  18. namespace EMIS.Web.Controllers.CultureplanManage.PlanManagement
  19. {
  20. [Authorization]
  21. public class PlanApplicationController : Controller
  22. {
  23. public IPlanApplicationServices PlanApplicationServices { get; set; }
  24. /// <summary>
  25. /// 计划申请页面
  26. /// </summary>
  27. /// <returns></returns>
  28. public ActionResult List()
  29. {
  30. return View();
  31. }
  32. /// <summary>
  33. /// 计划申请页面列表查询
  34. /// </summary>
  35. /// <param name="pararms"></param>
  36. /// <returns></returns>
  37. [HttpPost]
  38. public ActionResult List(QueryParamsModel pararms)
  39. {
  40. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  41. var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
  42. var campusID = pararms.getExtraGuid("CampusDropdown");
  43. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  44. var yearID = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
  45. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  46. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  47. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  48. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  49. var grademajorID = pararms.getExtraGuid("GrademajorComboGrid");
  50. var coursematerialID = pararms.getExtraGuid("CourseComboGrid");
  51. var handleModeID = pararms.getExtraInt("DictionaryHandleMode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryHandleMode");
  52. var approvalStatus = pararms.getExtraInt("DictionaryApprovalStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus");
  53. return base.Json(PlanApplicationServices.GetPlanApplicationViewGrid(configuretView, schoolyearID, campusID, collegeID,
  54. yearID, standardID, educationID, learningformID, learnSystem, grademajorID, coursematerialID, handleModeID,
  55. approvalStatus, (int)pararms.page, (int)pararms.rows));
  56. }
  57. /// <summary>
  58. /// 复制新增
  59. /// </summary>
  60. /// <param name="planApplicationID"></param>
  61. /// <returns></returns>
  62. public ActionResult CopyAdd(Guid planApplicationID)
  63. {
  64. PlanApplicationView planApplicationView = new PlanApplicationView();
  65. planApplicationView = PlanApplicationServices.GetPlanApplicationView(planApplicationID);
  66. return View("Edit", planApplicationView);
  67. }
  68. /// <summary>
  69. /// 复制新增
  70. /// </summary>
  71. /// <param name="planApplicationView"></param>
  72. /// <returns></returns>
  73. [HttpPost]
  74. public ActionResult CopyAdd(PlanApplicationView planApplicationView)
  75. {
  76. planApplicationView.PlanApplicationID = Guid.Empty;
  77. return this.Edit(planApplicationView);
  78. }
  79. /// <summary>
  80. /// 编辑(新增、修改,业务主键:学年学期ID、年级专业ID、课程信息ID)
  81. /// </summary>
  82. /// <param name="planApplicationID"></param>
  83. /// <returns></returns>
  84. public ActionResult Edit(Guid? planApplicationID)
  85. {
  86. PlanApplicationView planApplicationView = new PlanApplicationView();
  87. if (planApplicationID.HasValue && planApplicationID != Guid.Empty)
  88. {
  89. planApplicationView = PlanApplicationServices.GetPlanApplicationView(planApplicationID);
  90. }
  91. else
  92. {
  93. planApplicationView.SchoolyearID = BaseExtensions.GetCurrentSchoolYearID();
  94. planApplicationView.CourseStructureID = (int)CF_CourseStructure.ClassroomTeaching;
  95. planApplicationView.CourseCategoryID = (int)CF_CourseCategory.Publiccourse;
  96. planApplicationView.CourseQualityID = (int)CF_CourseQuality.Required;
  97. planApplicationView.Credit = 0;
  98. planApplicationView.TheoryCourse = 0;
  99. planApplicationView.Practicehours = 0;
  100. planApplicationView.Trialhours = 0;
  101. planApplicationView.Totalhours = 0;
  102. planApplicationView.TheoryWeeklyNum = 0;
  103. planApplicationView.PracticeWeeklyNum = 0;
  104. planApplicationView.TrialWeeklyNum = 0;
  105. planApplicationView.SchoolweeksNum = 0;
  106. planApplicationView.WeeklyHours = 0;
  107. planApplicationView.WeeklyNum = 0;
  108. planApplicationView.StartWeeklyNum = 1;
  109. planApplicationView.EndWeeklyNum = 16;
  110. planApplicationView.IsNeedMaterial = true;
  111. planApplicationView.CourseFineID = (int)CF_CourseFine.No;
  112. planApplicationView.TeachinglanguageID = (int)CF_Teachinglanguage.Chinese;
  113. planApplicationView.ExaminationModeID = (int)CF_ExaminationMode.WrittenExam;
  114. planApplicationView.ResultTypeID = (int)CF_ResultType.Percentage;
  115. planApplicationView.HandleModeID = (int)CF_HandleMode.RequiredCourse;
  116. planApplicationView.ResultTypeID = (int)CF_ResultType.Percentage;
  117. }
  118. return View(planApplicationView);
  119. }
  120. /// <summary>
  121. /// 编辑(新增、修改,业务主键:学年学期ID、年级专业ID、课程信息ID)
  122. /// </summary>
  123. /// <param name="planApplicationView"></param>
  124. /// <returns></returns>
  125. [HttpPost]
  126. public ActionResult Edit(PlanApplicationView planApplicationView)
  127. {
  128. try
  129. {
  130. PlanApplicationServices.PlanApplicationEdit(planApplicationView);
  131. return Json(new ReturnMessage()
  132. {
  133. IsSuccess = true,
  134. Message = "保存成功。"
  135. });
  136. }
  137. catch (Exception ex)
  138. {
  139. return Json(new ReturnMessage()
  140. {
  141. IsSuccess = false,
  142. Message = "保存失败:" + ex.Message
  143. });
  144. }
  145. }
  146. /// <summary>
  147. /// 专业课程模版批量新增(业务主键:学年学期ID、年级专业ID、课程信息ID)
  148. /// </summary>
  149. /// <returns></returns>
  150. [HttpGet]
  151. public ActionResult PlanApplicationBatchAdd()
  152. {
  153. PlanApplicationView planApplicationView = new PlanApplicationView();
  154. return View(planApplicationView);
  155. }
  156. /// <summary>
  157. /// 专业课程模版批量新增(业务主键:学年学期ID、年级专业ID、课程信息ID)
  158. /// </summary>
  159. /// <param name="planApplicationView"></param>
  160. /// <returns></returns>
  161. public ActionResult PlanApplicationBatchAdd(PlanApplicationView planApplicationView)
  162. {
  163. try
  164. {
  165. var specialtyCourseViewList = Request["specialtyCourseViewList"].JsonToObject<List<SpecialtyCourseView>>();
  166. string result = PlanApplicationServices.PlanApplicationBatchAdd(specialtyCourseViewList, planApplicationView);
  167. return Json(new ReturnMessage()
  168. {
  169. IsSuccess = true,
  170. Message = "新增成功" + result + "。"
  171. });
  172. }
  173. catch (Exception ex)
  174. {
  175. return Json(new ReturnMessage()
  176. {
  177. IsSuccess = false,
  178. Message = "新增失败,原因:" + ex.Message
  179. });
  180. }
  181. }
  182. /// <summary>
  183. /// 查询对应的未申请专业课程信息SpecialtyCourseView
  184. /// </summary>
  185. /// <param name="pararms"></param>
  186. /// <returns></returns>
  187. [HttpPost]
  188. public ActionResult SpecialtyCourseNoApplyList(QueryParamsModel pararms)
  189. {
  190. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  191. var departmentID = pararms.getExtraGuid("DepartmentDropdown");
  192. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  193. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  194. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  195. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  196. var coursematerialID = pararms.getExtraGuid("CourseComboGrid");
  197. var starttermID = pararms.getExtraInt("DictionaryStartterm") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStartterm");
  198. var handleModeID = pararms.getExtraInt("DictionaryHandleMode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryHandleMode");
  199. var yearID = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
  200. var grademajorID = pararms.getExtraGuid("GrademajorID");
  201. return base.Json(PlanApplicationServices.GetSpecialtyCourseViewNoApplyGrid(configuretView, departmentID, standardID,
  202. educationID, learningformID, learnSystem, coursematerialID, starttermID, handleModeID,
  203. yearID, grademajorID, (int)pararms.page, (int)pararms.rows));
  204. }
  205. /// <summary>
  206. /// 删除
  207. /// </summary>
  208. /// <param name="planApplicationIDs"></param>
  209. /// <returns></returns>
  210. [HttpPost]
  211. public ActionResult Delete(string planApplicationIDs)
  212. {
  213. try
  214. {
  215. List<Guid?> list = planApplicationIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  216. .Select(x => (Guid?)new Guid(x)).ToList();
  217. PlanApplicationServices.PlanApplicationDelete(list);
  218. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  219. }
  220. catch (Exception ex)
  221. {
  222. string mge = ex.Message;
  223. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  224. if (num != null)
  225. {
  226. if (num.Number == 547)
  227. {
  228. mge = "请先删除与其关联的数据,如:专业计划等。";
  229. }
  230. }
  231. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + mge });
  232. }
  233. }
  234. /// <summary>
  235. /// 提交
  236. /// </summary>
  237. /// <param name="planApplicationIDs"></param>
  238. /// <returns></returns>
  239. [HttpPost]
  240. public ActionResult PlanApplicationSubmit(string planApplicationIDs)
  241. {
  242. try
  243. {
  244. List<Guid> list = planApplicationIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  245. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  246. string result = PlanApplicationServices.PlanApplicationSubmit(list, user.UserID, "");
  247. return Json(new ReturnMessage()
  248. {
  249. IsSuccess = true,
  250. Message = "提交成功" + result + "。"
  251. });
  252. }
  253. catch (Exception ex)
  254. {
  255. return Json(new ReturnMessage()
  256. {
  257. IsSuccess = false,
  258. Message = "提交失败,原因:" + ex.Message
  259. });
  260. }
  261. }
  262. /// <summary>
  263. /// 查询对应的授课方式List
  264. /// </summary>
  265. /// <param name="pararms"></param>
  266. /// <returns></returns>
  267. [HttpPost]
  268. public ActionResult TeachingModeTypeList(QueryParamsModel pararms)
  269. {
  270. List<string> list = new List<string>();
  271. var planApplicationID = Request["planApplicationID"].ParseStrTo<Guid>();
  272. if (planApplicationID.HasValue && planApplicationID != Guid.Empty)
  273. {
  274. list = PlanApplicationServices.GetTeachingModeTypeList(planApplicationID);
  275. }
  276. else
  277. {
  278. list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory).ToString());
  279. }
  280. return base.Json(list);
  281. }
  282. /// <summary>
  283. /// 查询对应的授课地点List
  284. /// </summary>
  285. /// <param name="specialtyCourseID"></param>
  286. /// <returns></returns>
  287. [HttpPost]
  288. public ActionResult TeachingPlaceList(QueryParamsModel pararms)
  289. {
  290. List<string> list = new List<string>();
  291. var planApplicationID = Request["planApplicationID"].ParseStrTo<Guid>();
  292. if (planApplicationID.HasValue && planApplicationID != Guid.Empty)
  293. {
  294. list = PlanApplicationServices.GetTeachingPlaceList(planApplicationID);
  295. }
  296. else
  297. {
  298. list.Add(((int)EMIS.ViewModel.EM_TeachingPlace.Multimedia).ToString());
  299. }
  300. return base.Json(list);
  301. }
  302. /// <summary>
  303. /// 导出Excel
  304. /// </summary>
  305. /// <returns></returns>
  306. [HttpPost]
  307. public ActionResult Excel()
  308. {
  309. NpoiExcelHelper neh = new NpoiExcelHelper();
  310. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  311. var schoolyearID = Request.Form["SchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  312. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  313. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  314. var yearID = Request.Form["DictionarySchoolyear"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolyear"].ParseStrTo<int>();
  315. var standardID = Request.Form["DictionaryStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStandard"].ParseStrTo<int>();
  316. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  317. var learningformID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  318. var learnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  319. var grademajorID = Request.Form["GrademajorComboGrid"].ParseStrTo<Guid>();
  320. var coursematerialID = Request.Form["CourseComboGrid"].ParseStrTo<Guid>();
  321. var handleModeID = Request.Form["DictionaryHandleMode"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryHandleMode"].ParseStrTo<int>();
  322. var approvalStatus = Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>();
  323. var dt = PlanApplicationServices.GetPlanApplicationViewList(configuretView, schoolyearID, campusID, collegeID, yearID,
  324. standardID, educationID, learningformID, learnSystem, grademajorID, coursematerialID, handleModeID, approvalStatus)
  325. .Select(x => new
  326. {
  327. x.SchoolyearCode,
  328. x.CollegeCode,
  329. x.CollegeName,
  330. x.GradeID,
  331. x.GrademajorCode,
  332. x.GrademajorName,
  333. x.SchoolyearNumName,
  334. x.SchoolcodeName,
  335. x.StarttermName,
  336. x.CourseCode,
  337. x.CourseName,
  338. x.CourseStructureName,
  339. x.CourseCategoryName,
  340. x.CourseTypeName,
  341. x.CourseQualityName,
  342. Credit = x.Credit.HasValue ? x.Credit.Value.ToString("#.#") : null,
  343. x.TheoryCourse,
  344. x.Practicehours,
  345. x.Trialhours,
  346. x.Totalhours,
  347. x.TheoryWeeklyNum,
  348. x.PracticeWeeklyNum,
  349. x.TrialWeeklyNum,
  350. x.SchoolweeksNum,
  351. x.WeeklyHours,
  352. x.WeeklyNum,
  353. x.StartWeeklyNum,
  354. x.EndWeeklyNum,
  355. x.DepartmentName,
  356. x.IsSpecialtycoreName,
  357. x.IsCooperationName,
  358. x.IsRequiredName,
  359. x.IsElectiveName,
  360. x.IsNetworkCourseName,
  361. x.IsMainCourseName,
  362. x.IsNeedMaterialName,
  363. x.CourseFineName,
  364. x.PracticeTypeName,
  365. x.TeachinglanguageName,
  366. x.ExaminationModeName,
  367. x.ResultTypeName,
  368. x.HandleModeName,
  369. x.TeachingModeIDListName,
  370. x.TeachingPlaceIDListName,
  371. x.CreateTime,
  372. x.ApprovalStatusName,
  373. x.Remark
  374. }).ToTable();
  375. string[] liststring = {
  376. "学年学期", RSL.Get("CollegeCode"), RSL.Get("CollegeName"), "年级", "年级专业编号", "年级专业名称",
  377. "开课学年", "学期", "开课学期", "课程代码", "课程名称", "课程结构", "课程属性", "课程类型",
  378. "课程性质", "课程学分", "理论学时", "实践学时", "实验学时", "总学时", "理论周次", "实践周次",
  379. "实验周次", "总周次", "周学时", "每周次数", "开始周次", "结束周次", "开课教研室", "是否专业核心",
  380. "是否合作开发", RSL.Get("IsRequired"), "是否网上选修", "是否网络课程", "是否学位课程", "是否需要教材",
  381. "精品课程", "实践类型", "授课语言", "考试方式", "成绩类型", "处理方式", "授课方式", "授课地点",
  382. "申请时间", "审核状态", "备注"
  383. };
  384. neh.Export(dt, liststring, "计划申请信息" + DateTime.Now.ToString("yyyyMMdd"));
  385. return Json(new ReturnMessage()
  386. {
  387. IsSuccess = true,
  388. Message = "导出成功。"
  389. });
  390. }
  391. }
  392. }