SOCTemplateController.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.CommonLogic.DQPSystem;
  7. using EMIS.ViewModel;
  8. using EMIS.Web.Controls;
  9. using Bowin.Web.Controls.Mvc;
  10. using Bowin.Common.Data;
  11. using EMIS.Utility;
  12. using Bowin.Common.Exceptions;
  13. using Bowin.Common.Utility;
  14. using EMIS.ViewModel.DQPSystem;
  15. namespace EMIS.Web.Controllers.DQPSystem
  16. {
  17. [Authorization]
  18. public class SOCTemplateController : Controller
  19. {
  20. //
  21. // GET: /SOCTemplate/
  22. public ISOCTemplateServices SOCTemplateServices { get; set; }
  23. public ActionResult List()
  24. {
  25. return View();
  26. }
  27. [HttpPost]
  28. public ActionResult List(QueryParamsModel pararms)
  29. {
  30. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  31. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  32. var facultymajorID = pararms.getExtraGuid("FacultymajorComboGrid");
  33. var departmentID = pararms.getExtraGuid("DepartmentComboGrid");
  34. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  35. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  36. var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
  37. var coursematerialID = pararms.getExtraGuid("CoursematerialIDDropdownGridBo");
  38. var schoolyearNumID = pararms.getExtraInt("DictionarySchoolYearNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolYearNum");
  39. var schoolcodeID = pararms.getExtraInt("DictionarySchoolcode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolcode");
  40. var isEnable = pararms.getExtraInt("DictionaryIsEnable") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsEnable");
  41. var result = SOCTemplateServices.GetSOCTemplateViewGrid(configuretView, standardID, facultymajorID, departmentID, educationID, learningformID, LearnSystem, coursematerialID, schoolyearNumID, schoolcodeID, isEnable, (int)pararms.page, (int)pararms.rows);
  42. return Json(result);
  43. }
  44. [HttpGet]
  45. public ActionResult TemplateDetail(Guid? templateID)
  46. {
  47. ViewBag.TemplateID = templateID;
  48. return View();
  49. }
  50. [HttpPost]
  51. public ActionResult TemplateDetail(QueryParamsModel pararms)
  52. {
  53. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  54. var templateID = Request["templateID"].ParseStrTo<Guid>();
  55. return Json(SOCTemplateServices.GetSOCTemplateDetailViewGrid(templateID, (int)pararms.page, (int)pararms.rows));
  56. }
  57. //[HttpPost]
  58. //public ActionResult GetNewGuidForSOCTemplateItemID(int count)
  59. //{
  60. // var SOCTemplateItemID = Guid.NewGuid();
  61. // return Json(SOCTemplateItemID);
  62. //}
  63. /// <summary>
  64. /// 复制新增
  65. /// </summary>
  66. /// <param name="graduationApplyID"></param>
  67. /// <returns></returns>
  68. public ActionResult CopyAdd(Guid? templateID)
  69. {
  70. SOCTemplateView SOCTemplateView = new SOCTemplateView();
  71. SOCTemplateView = SOCTemplateServices.GetSOCTemplateViewByID(templateID);
  72. return View("Edit", SOCTemplateView);
  73. }
  74. /// <summary>
  75. /// 复制新增
  76. /// </summary>
  77. /// <param name="graduationApplyView"></param>
  78. /// <returns></returns>
  79. [HttpPost]
  80. public ActionResult CopyAdd(SOCTemplateView SOCTemplateView)
  81. {
  82. SOCTemplateView.SOCTemplateID = Guid.Empty;
  83. return this.Edit(SOCTemplateView);
  84. }
  85. public ActionResult Edit(Guid? templateID)
  86. {
  87. var SOCTemplateView = new SOCTemplateView();
  88. if (templateID.HasValue)
  89. {
  90. SOCTemplateView = SOCTemplateServices.GetSOCTemplateViewByID(templateID);
  91. }
  92. return View(SOCTemplateView);
  93. }
  94. [HttpPost]
  95. public ActionResult Edit(SOCTemplateView SOCTemplateView)
  96. {
  97. try
  98. {
  99. //var count = Session.Count;
  100. List<FileUploadView> filelist = new List<FileUploadView>();
  101. //for (int i = 0; i < count; i++)
  102. //{
  103. // var file = Session[i];
  104. // if (file.GetType() == typeof(List<FileUploadView>))
  105. // {
  106. // filelist = (List<FileUploadView>)file;
  107. // }
  108. //}
  109. var TDList = DataGrid.GetTableData<SOCTemplateDetailView>("dgSOCTemplateDetailList");//获取底部列表项数据
  110. if (TDList.Count <= 0)
  111. {
  112. return Json(new ReturnMessage()
  113. {
  114. IsSuccess = false,
  115. Message = "保存失败,原因:SOC不能为空。"
  116. });
  117. }
  118. else
  119. {
  120. var detailIDList = TDList.Select(x => x.SOCTemplateItemID).ToList();
  121. foreach (var id in detailIDList)
  122. {
  123. var sessionName = FileUploadHelper.GetFileUploadSessionName(id);
  124. var sessionfileList = (List<FileUploadView>)Session[sessionName];
  125. if (sessionfileList != null)
  126. {
  127. foreach (var file in sessionfileList)
  128. {
  129. filelist.Add(file);
  130. }
  131. }
  132. }
  133. SOCTemplateServices.SOCTemplateEdit(SOCTemplateView,TDList,filelist);
  134. //StockOutServices.Save(stockOutView, TMList, user.UserID, type);
  135. }
  136. return Json(new ReturnMessage()
  137. {
  138. IsSuccess = true,
  139. Message = "保存成功。"
  140. });
  141. }
  142. catch (Exception ex)
  143. {
  144. return Json(new ReturnMessage()
  145. {
  146. IsSuccess = false,
  147. Message = "保存失败,原因:" + ex.Message
  148. });
  149. }
  150. }
  151. [HttpGet]
  152. public ActionResult Upload(Guid? SOCTemplateItemID)
  153. {
  154. SOCTemplateDetailView templateDetailView = new SOCTemplateDetailView();
  155. templateDetailView.SOCTemplateItemID = SOCTemplateItemID.Value;
  156. return View(templateDetailView);
  157. }
  158. [HttpPost]
  159. public ActionResult Upload()
  160. {
  161. return Json("上传成功");
  162. }
  163. [HttpPost]
  164. public ActionResult GetFileListByItemID(string TemplateDetailID)
  165. {
  166. var templateID = TemplateDetailID.ParseStrTo<Guid>();
  167. var sessionName = FileUploadHelper.GetFileUploadSessionName(templateID ?? Guid.Empty);
  168. var fileList = (List<FileUploadView>)Session[sessionName];
  169. //var count = Session.Count;
  170. //List<FileUploadView> filelist = new List<FileUploadView>();
  171. //for (int i = 0; i < count; i++)
  172. //{
  173. // var file = Session[i];
  174. // if (file.GetType() == typeof(List<FileUploadView>))
  175. // {
  176. // filelist = (List<FileUploadView>)file;
  177. // }
  178. //}
  179. //ViewBag.FileList = filelist;
  180. //foreach (var file in filelist)
  181. //{
  182. //}
  183. return Json(fileList);
  184. }
  185. /// <summary>
  186. /// 生成
  187. /// </summary>
  188. /// <returns></returns>
  189. [HttpGet]
  190. public ActionResult Generate()
  191. {
  192. return View();
  193. }
  194. /// <summary>
  195. /// 生成
  196. /// </summary>
  197. /// <param name="schoolYearID"></param>
  198. /// <returns></returns>
  199. [HttpPost]
  200. public ActionResult Generate(QueryParamsModel pararms)
  201. {
  202. try
  203. {
  204. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  205. var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  206. var facultymajorID = Request.Form["FacultymajorDropDown"].ParseStrTo<Guid>();
  207. var coursematerialID = Request.Form["CoursematerialDropDown"].ParseStrTo<Guid>();
  208. SOCTemplateServices.GenerateTemplate(collegeID, standardID, facultymajorID, coursematerialID);
  209. return Json(new ReturnMessage()
  210. {
  211. IsSuccess = true,
  212. Message = "生成成功。"
  213. });
  214. }
  215. catch (Exception ex)
  216. {
  217. return Json(new ReturnMessage()
  218. {
  219. IsSuccess = false,
  220. Message = "生成失败:" + ex.Message
  221. });
  222. }
  223. }
  224. public ActionResult Delete(string SOCTemplateIDs)
  225. {
  226. try
  227. {
  228. List<Guid?> list = new List<Guid?>();
  229. for (int i = 0; i < SOCTemplateIDs.Split(',').Length; i++)
  230. {
  231. if (!string.IsNullOrEmpty(SOCTemplateIDs.Split(',')[i]))
  232. {
  233. Guid SOCTemplateID = new Guid(SOCTemplateIDs.Split(',')[i]);
  234. list.Add(SOCTemplateID);
  235. }
  236. }
  237. SOCTemplateServices.SOCTemplateDelete(list);
  238. return this.Json("删除成功!");
  239. }
  240. catch (Exception ex)
  241. {
  242. return this.Json("删除失败,原因:" + ex.Message);
  243. }
  244. }
  245. public ActionResult Excel()
  246. {
  247. NpoiExcelHelper neh = new NpoiExcelHelper();
  248. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  249. var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  250. var facultymajorID = Request.Form["FacultymajorComboGrid"].ParseStrTo<Guid>();
  251. var departmentID = Request.Form["DepartmentComboGrid"].ParseStrTo<Guid>();
  252. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  253. var learningformID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  254. var LearnSystem = Request.Form["DictionaryLearnSystem"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? "" : Request.Form["DictionaryLearnSystem"].ParseStrTo<int>().ToString();
  255. var coursematerialID = Request.Form["CoursematerialIDDropdownGridBo"].ParseStrTo<Guid>();
  256. var schoolyearNumID = Request.Form["DictionarySchoolYearNum"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolYearNum"].ParseStrTo<int>();
  257. var schoolcodeID = Request.Form["DictionarySchoolcode"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolcode"].ParseStrTo<int>();
  258. var isEnable = Request.Form["DictionaryIsEnable"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsEnable"].ParseStrTo<int>();
  259. var SOCTemplateIDString = Request.Form["SelectedID"];
  260. var SOCTemplateIDList = SOCTemplateIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  261. var dt = SOCTemplateServices.GetSOCTemplateViewList(configuretView, standardID, facultymajorID, departmentID, educationID, learningformID, LearnSystem, coursematerialID, schoolyearNumID, schoolcodeID, isEnable, SOCTemplateIDList)
  262. .Select(x => new
  263. {
  264. x.StandardCode,
  265. x.StandardName,
  266. x.FacultymajorName,
  267. x.EducationName,
  268. x.LearningformName,
  269. x.LearnSystem,
  270. x.CourseCode,
  271. x.CourseName,
  272. x.Credit,
  273. x.SchoolyearNumName,
  274. x.SchoolcodeName,
  275. x.DepartmentName,
  276. x.RecordStatusStr,
  277. x.SOCCount
  278. }).ToTable();
  279. string[] liststring = {
  280. "专业代码", "专业名称", "院系专业", RSL.Get("EducationID"), "学习形式", "学制", "课程代码", "课程名称", "课程学分", "开课学年", "学期", "开课教研室", "是否可用", "SOC个数"
  281. };
  282. neh.Export(dt, liststring, "课程SOC设置信息" + DateTime.Now.ToString("yyyyMMdd"));
  283. return Json(new ReturnMessage()
  284. {
  285. IsSuccess = true,
  286. Message = "导出成功。"
  287. });
  288. }
  289. }
  290. }