OptionalCoursePlanController.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.ViewModel;
  7. using Bowin.Web.Controls.Mvc;
  8. using EMIS.Web.Controls;
  9. using EMIS.CommonLogic.CultureplanManage.PlanManagement;
  10. using EMIS.ViewModel.SelectCourse;
  11. using Bowin.Common.Exceptions;
  12. using EMIS.Entities;
  13. using Bowin.Common.Utility;
  14. using Bowin.Common.Data;
  15. using EMIS.CommonLogic.UniversityManage.SpecialtyClassManage;
  16. using EMIS.CommonLogic.CalendarManage;
  17. using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
  18. using EMIS.ViewModel.CultureplanManage.PlanManagement;
  19. using System.IO;
  20. using System.Text;
  21. using EMIS.Utility;
  22. using EMIS.ViewModel.EnrollManage.NewStudentManage;
  23. using EMIS.CommonLogic.SelectCourse;
  24. namespace EMIS.Web.Controllers.CultureplanManage.PlanManagement
  25. {
  26. [Authorization]
  27. public class OptionalCoursePlanController : Controller
  28. {
  29. public IOptionalCoursePlanServices optionalCourseSettingServices { get; set; }
  30. /// <summary>
  31. /// 限选计划页面
  32. /// </summary>
  33. /// <returns></returns>
  34. public ActionResult List()
  35. {
  36. return View();
  37. }
  38. /// <summary>
  39. /// 查询列表
  40. /// </summary>
  41. /// <param name="pararms"></param>
  42. /// <returns></returns>
  43. [HttpPost]
  44. public ActionResult List(QueryParamsModel pararms)
  45. {
  46. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  47. var coursematerialID = pararms.getExtraGuid("CoursematerialIDDropdownGridBo");
  48. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  49. var schoolYearNumID = pararms.getExtraInt("DictionarySchoolYearNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolYearNum");
  50. var schoolCodeID = pararms.getExtraInt("DictionarySchoolCode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolCode");
  51. var isEnable = pararms.getExtraInt("DictionaryIsEnable") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsEnable");
  52. var isOpen = pararms.getExtraInt("DictionaryIsOpen") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsOpen");
  53. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  54. var learningFormID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  55. var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
  56. return this.Json(optionalCourseSettingServices.GetOptionalCourseSettingViewGrid(configuretView, standardID, coursematerialID, schoolYearNumID, schoolCodeID, isEnable, isOpen, educationID, learningFormID,LearnSystem, (int)pararms.page, (int)pararms.rows));
  57. }
  58. /// <summary>
  59. /// 编辑
  60. /// </summary>
  61. /// <returns></returns>
  62. public ActionResult Edit(Guid? optionalCoursePlanID)
  63. {
  64. OptionalCoursePlanView optionalCourseSettingView = new OptionalCoursePlanView();
  65. if (optionalCoursePlanID.HasValue && optionalCoursePlanID != Guid.Empty)
  66. optionalCourseSettingView = optionalCourseSettingServices.GetOptionalCourseSettingView(optionalCoursePlanID);
  67. return View(optionalCourseSettingView);
  68. }
  69. /// <summary>
  70. /// 保存修改
  71. /// </summary>
  72. /// <param name="optionalCourseSettingView"></param>
  73. /// <returns></returns>
  74. [HttpPost]
  75. public ActionResult Edit(OptionalCoursePlanView optionalCourseSettingView)
  76. {
  77. try
  78. {
  79. optionalCourseSettingServices.OptionalCourseUpdate(optionalCourseSettingView);
  80. return Json(new ReturnMessage()
  81. {
  82. IsSuccess = true,
  83. Message = "保存成功!"
  84. });
  85. }
  86. catch (Exception ex)
  87. {
  88. return Json(new ReturnMessage()
  89. {
  90. IsSuccess = false,
  91. Message = "保存失败:" + ex.Message
  92. });
  93. }
  94. }
  95. [HttpPost]
  96. public ActionResult TeachingModeType(Guid? OptionalCourseID)
  97. {
  98. List<string> list = new List<string>();
  99. if (OptionalCourseID.HasValue && OptionalCourseID != Guid.Empty)
  100. list = optionalCourseSettingServices.GetTeachingModeType(OptionalCourseID);
  101. else
  102. list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory).ToString());
  103. return base.Json(list);
  104. }
  105. /// <summary>
  106. /// 删除
  107. /// </summary>
  108. /// <param name="optionalCourseIDs"></param>
  109. /// <returns></returns>
  110. [HttpPost]
  111. public ActionResult Delete(string optionalCoursePlanIDs)
  112. {
  113. try
  114. {
  115. List<Guid> list = new List<Guid>();
  116. for (int i = 0; i < optionalCoursePlanIDs.Split(',').Length; i++)
  117. {
  118. if (!string.IsNullOrEmpty(optionalCoursePlanIDs.Split(',')[i]))
  119. {
  120. Guid optionalCoursePlanID = new Guid(optionalCoursePlanIDs.Split(',')[i]);
  121. list.Add(optionalCoursePlanID);
  122. }
  123. }
  124. optionalCourseSettingServices.OptionalCourseDelete(list);
  125. return this.Json("删除成功");
  126. }
  127. catch (Exception ex)
  128. {
  129. string mge = ex.Message;
  130. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  131. if (num != null)
  132. {
  133. if (num.Number == 547)
  134. mge = "请先删除所有关联的数据!";
  135. }
  136. return this.Json("删除失败,原因:" + mge);
  137. }
  138. }
  139. /// <summary>
  140. /// 添加
  141. /// </summary>
  142. /// <returns></returns>
  143. public ActionResult Add(Guid? optionalCoursePlanID)
  144. {
  145. OptionalCoursePlanView optionalCourseSettingView = new OptionalCoursePlanView();
  146. if (optionalCoursePlanID.HasValue && optionalCoursePlanID != Guid.Empty)
  147. {
  148. optionalCourseSettingView = optionalCourseSettingServices.GetOptionalCourseSettingView(optionalCoursePlanID);
  149. }
  150. //默认值
  151. optionalCourseSettingView.CourseStructureID = 1;
  152. optionalCourseSettingView.CourseCategoryID = 2;
  153. optionalCourseSettingView.CourseTypeID = 4;
  154. optionalCourseSettingView.CourseQualityID = 5;
  155. optionalCourseSettingView.ExaminationModeID = (int)EMIS.ViewModel.CF_ExaminationMode.WrittenExam;
  156. optionalCourseSettingView.TeachinglanguageID = 1;
  157. optionalCourseSettingView.IsEnable = true;
  158. return View(optionalCourseSettingView);
  159. }
  160. ///<summary>
  161. /// 添加
  162. /// </summary>
  163. /// <param name="planApplicationView"></param>
  164. /// <returns></returns>
  165. [HttpPost]
  166. public ActionResult Add(OptionalCoursePlanView optionalCourseSettingView)
  167. {
  168. try
  169. {
  170. optionalCourseSettingServices.OptionalCourseAdd(optionalCourseSettingView);
  171. return Json(new ReturnMessage()
  172. {
  173. IsSuccess = true,
  174. Message = "保存成功!"
  175. });
  176. }
  177. catch (Exception ex)
  178. {
  179. return Json(new ReturnMessage()
  180. {
  181. IsSuccess = false,
  182. Message = "保存失败:" + ex.Message
  183. });
  184. }
  185. }
  186. ///<summary>
  187. ///导出Excel
  188. ///</summary>
  189. ///<returns></returns>
  190. [HttpPost]
  191. public ActionResult Excel()
  192. {
  193. NpoiExcelHelper neh = new NpoiExcelHelper();
  194. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  195. var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  196. var coursematerialID = Request.Form["CoursematerialIDDropdownGridBo"].ParseStrTo<Guid>();
  197. var schoolYearNumID = Request.Form["DictionarySchoolYearNum"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolYearNum"].ParseStrTo<int>();
  198. var schoolCodeID = Request.Form["DictionarySchoolCode"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolCode"].ParseStrTo<int>();
  199. var isEnable = Request.Form["DictionaryIsEnable"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsEnable"].ParseStrTo<int>();
  200. var isOpen = Request.Form["DictionaryIsOpen"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsOpen"].ParseStrTo<int>();
  201. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  202. var learningFormID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  203. var LearnSystem = "";
  204. //Request.Form["DictionaryLearnSystem"].ToString();
  205. var dt = optionalCourseSettingServices.GetOptionalCourseSettingViewList(configuretView, standardID, coursematerialID, schoolYearNumID, schoolCodeID, isEnable, isOpen,educationID,learningFormID, LearnSystem).Select(x => new
  206. {
  207. x.StandardCode,
  208. x.StandardName,
  209. x.CourseCode,
  210. x.CourseName,
  211. x.CourseTypeName,
  212. x.CourseCategoryName,
  213. x.CourseQualityName,
  214. x.SchoolcodeName,
  215. x.SchoolyearNumName,
  216. //x.Credit,
  217. //x.Totalhours,
  218. //x.TheoryCourse,
  219. //x.Practicehours,
  220. x.DepartmentName,
  221. x.IsEnableDesc,
  222. //x.IsOpenedDesc
  223. }).ToTable();
  224. string[] liststring = { "专业代码", "专业名称", "课程代码","课程名称","课程类型","课程属性", "课程性质", "学期",
  225. //"学分","总学时","理论学时","实践学时",
  226. "开课年级","教研室","是否启用"
  227. //,"是否开放"
  228. };
  229. neh.Export(dt, liststring, "限选计划信息");
  230. return Json(new ReturnMessage()
  231. {
  232. IsSuccess = true,
  233. Message = "导出成功!"
  234. });
  235. }
  236. //#region 13.0 新生信息导入
  237. //[HttpGet]
  238. //public ActionResult Import(string errorFile, string operationTips)
  239. //{
  240. // ViewBag.ErrorFile = errorFile;
  241. // if (string.IsNullOrEmpty(operationTips))
  242. // {
  243. // operationTips = "错误数据下载";
  244. // }
  245. // ViewBag.operationTips = operationTips;
  246. // return View();
  247. //}
  248. //[HttpPost]
  249. //public ActionResult Import(HttpPostedFileBase file)
  250. //{
  251. // try
  252. // {
  253. // //1.0 HSSFWorkbook:是操作Excel2003以前(包括2003)的版本,扩展名是.xls
  254. // //2.0 XSSFWorkbook:是操作Excel2007的版本,扩展名是.xlsx
  255. // var accept = new[] { ".xls", ".xlsx" };
  256. // var p = Path.GetExtension(file.FileName);
  257. // if (!accept.Contains(p))
  258. // {
  259. // throw new Exception("只允许上传xls和xlsx格式的Excel文件!");
  260. // }
  261. // Dictionary<string, string> cellheader = new Dictionary<string, string>
  262. // {
  263. // { "ExamineeNum", "考生号" }, { "Name", "姓名" },
  264. // { "SexStr", "性别" }, { "NationStr", "民族" },
  265. // { "PoliticsStr", "政治面貌" }, { "BirthDateStr", "出生日期" },
  266. // { "CertificatesTypeStr", "证件类型" }, { "IDNumber", "证件号码" },
  267. // { "EntranceDateStr", "入学日期" }, { "YearID", "年级" },
  268. // { "StandardName", "专业名称" }, { "LearnSystemStr", "学制" },
  269. // { "EducationStr", EMIS.Utility.RSL.Get("EducationID") }, { "LearningformStr", "学习形式" },
  270. // { "ScoreStr", "总分" }, { "Telephone", "联系电话" },
  271. // { "Address", "通讯地址" },{ "Remark", "备注" }
  272. // };
  273. // StringBuilder errorMsg = new StringBuilder(); // 错误信息
  274. // string sourceWebPath = FileUploadHelper.UploadFile(file);
  275. // var sourcePhysicalPath = Server.MapPath(sourceWebPath);
  276. // List<OptionalCoursePlanView> errList = new List<OptionalCoursePlanView>();
  277. // List<OptionalCoursePlanView> dataList = new List<OptionalCoursePlanView>();
  278. // int errCount = 0;
  279. // int OkCount = 0;
  280. // otionalCourseSettingServices.OptionalCoursePlanImport(cellheader, out OkCount, out errList, out errCount, sourcePhysicalPath);
  281. // System.IO.File.Delete(sourcePhysicalPath);//删除本地缓存文件
  282. // if (errList.Count() > 0)
  283. // {
  284. // //将异常文件路径显示
  285. // string errorWebPath = string.Format("{0}", NpoiExcelHelper.EntityListToExcel2003(cellheader, errList, "新生信息导入失败文件", sourcePhysicalPath));
  286. // ViewBag.ErrorFile = errorWebPath;
  287. // string Errinfo = string.Format("提示:成功导入{0}条记录,失败{1}条,详情请点击错误数据下载查看。", OkCount < 1 ? 0 : OkCount, errCount < 1 ? 0 : errCount);
  288. // ViewBag.operationTips = Errinfo;
  289. // //return RedirectToAction("Import", new { errorFile = errorWebPath, operationTips = Errinfo });
  290. // return RedirectToAction("MsgShow", "Common", new
  291. // {
  292. // WindowID = "none",
  293. // msg = "导入失败!",
  294. // url = Url.Action("Import").AddMenuParameter() + "&errorFile=" + errorWebPath + "&operationTips=" + Errinfo + "&WindowID=" + Request["WindowID"]
  295. // });
  296. // }
  297. // else
  298. // {
  299. // return RedirectToAction("MsgShow", "Common", new
  300. // {
  301. // WindowID = Request["WindowID"],
  302. // msg = "导入成功!",
  303. // url = Url.Action("List").AddMenuParameter()
  304. // });
  305. // }
  306. // }
  307. // catch (Exception ex)
  308. // {
  309. // return RedirectToAction("MsgShow", "Common", new
  310. // {
  311. // WindowID = Request["WindowID"],
  312. // msg = "导入失败,原因:" + ex.Message + "!",
  313. // url = Url.Action("List").AddMenuParameter()
  314. // });
  315. // }
  316. //#endregion
  317. //}
  318. }
  319. }