MinorStandardSettingServices.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.ViewModel;
  6. using Bowin.Common.Linq.Entity;
  7. using EMIS.ViewModel.MinorManage.MinorSetting;
  8. using System.Linq.Expressions;
  9. using EMIS.Entities;
  10. using Bowin.Common.Linq;
  11. using EMIS.DataLogic.MinorManage.MinorSetting;
  12. namespace EMIS.CommonLogic.MinorManage.MinorSetting
  13. {
  14. public class MinorStandardSettingServices : BaseServices, IMinorStandardSettingServices
  15. {
  16. public MinorStandardSettingDAL minorStandardSettingDAL { get; set; }
  17. /// <summary>
  18. /// 查询辅修专业设置列表
  19. /// </summary>
  20. /// <param name="configuretView"></param>
  21. /// <param name="minorStandardID"></param>
  22. /// <param name="standardID"></param>
  23. /// <param name="pageIndex"></param>
  24. /// <param name="pageSize"></param>
  25. /// <returns></returns>
  26. public IGridResultSet<MinorStandardSettingView> GetMinorControlViewGrid(ConfiguretView configuretView, int? minorStandardID, int? standardID, int pageIndex, int pageSize)
  27. {
  28. Expression<Func<CF_MinorStandardSetting, bool>> exp = x => true;
  29. if (minorStandardID.HasValue)
  30. {
  31. exp = exp.And(x => x.MinorStandardID == minorStandardID);
  32. }
  33. if (standardID.HasValue)
  34. {
  35. exp = exp.And(x => x.StandardID == standardID);
  36. }
  37. var query = minorStandardSettingDAL.GetMinorStandardSettingViewQueryable(exp);
  38. if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
  39. {
  40. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  41. }
  42. query = query.OrderByDescending(x => x.StandardID).ThenByDescending(x => x.MinorStandardID);
  43. return query.ToGridResultSet<MinorStandardSettingView>(pageIndex, pageSize);
  44. }
  45. /// <summary>
  46. /// 查询辅修专业设置列表(Excel)
  47. /// </summary>
  48. /// <param name="configuretView"></param>
  49. /// <param name="minorStandardID"></param>
  50. /// <param name="standardID"></param>
  51. /// <param name="idList"></param>
  52. /// <returns></returns>
  53. public List<MinorStandardSettingView> GetMinorControlViewList(ConfiguretView configuretView, int? minorStandardID, int? standardID, List<Guid?> idList)
  54. {
  55. Expression<Func<CF_MinorStandardSetting, bool>> exp = x => true;
  56. if (minorStandardID.HasValue)
  57. {
  58. exp = exp.And(x => x.MinorStandardID == minorStandardID);
  59. }
  60. if (standardID.HasValue)
  61. {
  62. exp = exp.And(x => x.StandardID == standardID);
  63. }
  64. if (idList.Count > 0 && idList != null)
  65. {
  66. exp = exp.And(x => idList.Contains(x.MinorStandardSettingID));
  67. }
  68. var query = minorStandardSettingDAL.GetMinorStandardSettingViewQueryable(exp);
  69. if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
  70. {
  71. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  72. }
  73. query = query.OrderByDescending(x => x.StandardID).ThenByDescending(x => x.MinorStandardID);
  74. return query.ToList();
  75. }
  76. /// <summary>
  77. /// 查询对应的辅修专业设置
  78. /// </summary>
  79. /// <param name="retakeOpenControlID"></param>
  80. /// <returns></returns>
  81. public MinorStandardSettingView GetMinorStandardSettingView(Guid? minorStandardSettingID)
  82. {
  83. var query = minorStandardSettingDAL.GetMinorStandardSettingViewQueryable(x => x.MinorStandardSettingID == minorStandardSettingID);
  84. return query.FirstOrDefault();
  85. }
  86. /// <summary>
  87. /// 辅修专业设置编辑(新增、修改)
  88. /// </summary>
  89. /// <param name="retakeOpenControlView"></param>
  90. public void MinorStandardSettingEdit(MinorStandardSettingView minorStandardSettingView)
  91. {
  92. try
  93. {
  94. CF_MinorStandardSetting minorStandardSetting = new CF_MinorStandardSetting();
  95. if (minorStandardSettingView.MinorStandardSettingID == null || minorStandardSettingView.MinorStandardSettingID == Guid.Empty)
  96. {
  97. //新增、复制新增
  98. minorStandardSetting = minorStandardSettingDAL.minorStandardSettingRepository
  99. .GetSingle(x => x.StandardID == minorStandardSettingView.StandardID && x.MinorStandardID == minorStandardSettingView.MinorStandardID);
  100. if (minorStandardSetting != null)
  101. {
  102. throw new Exception("已存在相同的辅修专业设置信息。");
  103. }
  104. minorStandardSetting = new CF_MinorStandardSetting();
  105. minorStandardSetting.MinorStandardSettingID = Guid.NewGuid();
  106. minorStandardSetting.StandardID = minorStandardSettingView.StandardID;
  107. minorStandardSetting.MinorStandardID = minorStandardSettingView.MinorStandardID;
  108. SetNewStatus(minorStandardSetting);
  109. UnitOfWork.Add(minorStandardSetting);
  110. }
  111. else
  112. {
  113. //修改
  114. minorStandardSetting = minorStandardSettingDAL.minorStandardSettingRepository
  115. .GetSingle(x => x.MinorStandardSettingID != minorStandardSettingView.MinorStandardSettingID
  116. && x.StandardID == minorStandardSettingView.StandardID && x.MinorStandardID == minorStandardSettingView.MinorStandardID);
  117. if (minorStandardSetting != null)
  118. {
  119. throw new Exception("已存在相同的辅修专业设置信息。");
  120. }
  121. minorStandardSetting = minorStandardSettingDAL.minorStandardSettingRepository
  122. .GetSingle(x => x.MinorStandardSettingID == minorStandardSettingView.MinorStandardSettingID);
  123. if (minorStandardSetting == null)
  124. {
  125. throw new Exception("数据有误,请核查。");
  126. }
  127. //minorStandardSetting.MinorStandardSettingID = minorStandardSettingView.MinorStandardSettingID
  128. minorStandardSetting.StandardID = minorStandardSettingView.StandardID;
  129. minorStandardSetting.MinorStandardID = minorStandardSettingView.MinorStandardID;
  130. SetModifyStatus(minorStandardSetting);
  131. }
  132. UnitOfWork.Commit();
  133. }
  134. catch (Exception ex)
  135. {
  136. throw new Exception(ex.Message);
  137. }
  138. }
  139. /// <summary>
  140. /// 辅修专业设置删除
  141. /// </summary>
  142. /// <param name="openControlIDList"></param>
  143. public void MinorStandardSettingDelete(IList<Guid?> minorStandardSettingIDList)
  144. {
  145. try
  146. {
  147. if (minorStandardSettingIDList.Count > 0)
  148. {
  149. UnitOfWork.Delete<CF_MinorStandardSetting>(x => minorStandardSettingIDList.Contains(x.MinorStandardSettingID));
  150. }
  151. }
  152. catch (Exception ex)
  153. {
  154. throw new Exception(ex.Message);
  155. }
  156. }
  157. /// <summary>
  158. /// 查找标准专业(排除已选专业)
  159. /// </summary>
  160. /// <param name="standardID"></param>
  161. /// <param name="pageIndex"></param>
  162. /// <param name="pageSize"></param>
  163. /// <returns></returns>
  164. public IGridResultSet<MinorStandardSettingView> GetStandardNotSelectID(int? standardID, int pageIndex, int pageSize)
  165. {
  166. Expression<Func<Sys_DictionaryItem, bool>> exp = x => true;
  167. exp = exp.And(x => x.DictionaryCode == "CF_Standard");
  168. if(standardID.HasValue)
  169. {
  170. exp = exp.And(x => x.Value != standardID);
  171. }
  172. var query = minorStandardSettingDAL.GetStandardNotHaveSelect(exp);
  173. return query.ToGridResultSet<MinorStandardSettingView>(pageIndex, pageSize);
  174. }
  175. }
  176. }