ProjectFeeServices.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using EMIS.Entities;
  7. using Bowin.Common.Linq;
  8. using Bowin.Common.Linq.Entity;
  9. using EMIS.DataLogic.Common.AdministrativeOrgan;
  10. using EMIS.Utility;
  11. using System.Linq.Expressions;
  12. using EMIS.DataLogic.ExamManage;
  13. using EMIS.ViewModel.ExamManage;
  14. using EMIS.ViewModel;
  15. namespace EMIS.CommonLogic.ExamManage
  16. {
  17. public class ProjectFeeServices : BaseServices, IProjectFeeServices
  18. {
  19. public ProjectFeeDAL ProjectFeeDAL { get; set; }
  20. public Bowin.Common.Linq.Entity.IGridResultSet<EMIS.ViewModel.ProjectFeeTypeView> GetProjectFeeTypeGrid(ViewModel.ConfiguretView configuretView, int pageIndex, int pageSize)
  21. {
  22. //校区信息
  23. Expression<Func<Entities.EX_ExaminationProjectFeeType, bool>> expCampus = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE);
  24. var query = ProjectFeeDAL.GetProjectFeeTypeGrid(expCampus);
  25. //查询条件
  26. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  27. {
  28. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  29. }
  30. return query
  31. .OrderBy(x => x.ExaminationProjectFeeID)
  32. .ToGridResultSet<EMIS.ViewModel.ProjectFeeTypeView>(pageIndex, pageSize);
  33. }
  34. public IQueryable<EMIS.ViewModel.ProjectFeeTypeView> GetProjectFeeTypeList(Expression<Func<EMIS.Entities.EX_ExaminationProjectFeeType, bool>> expCampus)
  35. {
  36. return ProjectFeeDAL.GetProjectFeeTypeGrid(expCampus);
  37. }
  38. public IGridResultSet<EX_ExaminationType> GetExaminationTypeList(int pageIndex, int pageSize, params EMIS.ViewModel.ConfiguretView[] configuretViews)
  39. {
  40. //校区信息
  41. Expression<Func<EX_ExaminationType, bool>> expCampus = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE);
  42. var query = ProjectFeeDAL.GetExaminationType(expCampus);
  43. //查询条件
  44. foreach (var configuretView in configuretViews)
  45. {
  46. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  47. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  48. }
  49. return query
  50. .OrderBy(x => x.ExaminationTypeID)
  51. .ToGridResultSet<EMIS.Entities.EX_ExaminationType>(pageIndex, pageSize);
  52. }
  53. public List<EX_ExaminationType> GetExaminationTypeList()
  54. {
  55. //校区信息
  56. Expression<Func<EX_ExaminationType, bool>> exp = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE);
  57. var query = ProjectFeeDAL.GetExaminationType(exp);
  58. return query
  59. .OrderBy(x => x.Name)
  60. .ToList();
  61. }
  62. public IGridResultSet<EMIS.ViewModel.ExaminationProjectSubjectView> GetProjectSubjectListViewGrid(EMIS.ViewModel.ConfiguretView configuretView, int pageIndex, int pageSize)
  63. {
  64. Expression<Func<EX_ExaminationProjectSubject, bool>> expCampus = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE);
  65. var query = ProjectFeeDAL.GetProjectSubjectList(expCampus);
  66. //查询条件
  67. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  68. {
  69. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  70. }
  71. return query
  72. .OrderBy(x => x.ExaminationSubjectID)
  73. .ToGridResultSet<EMIS.ViewModel.ExaminationProjectSubjectView>(pageIndex, pageSize);
  74. }
  75. public List<EMIS.ViewModel.ExaminationProjectSubjectView> GetProjectSubjectListViewList(Guid? examinationProjectID)
  76. {
  77. Expression<Func<EX_ExaminationProjectSubject, bool>> exp = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE);
  78. if (examinationProjectID.HasValue)
  79. {
  80. exp = exp.And(x => x.ExaminationProjectID == examinationProjectID);
  81. }
  82. var query = ProjectFeeDAL.GetProjectSubjectList(exp).GroupBy(x => x.ExaminationSubjectID).Select(x => x.FirstOrDefault());
  83. return query
  84. .OrderBy(x => x.ExaminationSubjectID)
  85. .ToList();
  86. }
  87. public Bowin.Common.Linq.Entity.IGridResultSet<EMIS.ViewModel.ExaminationProjectFeeView> GetProjectFeeGrid(int pageIndex, int pageSize, params ViewModel.ConfiguretView[] configuretViews)
  88. {
  89. //校区信息
  90. Expression<Func<EX_ExaminationProjectFee, bool>> expCampus = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE);
  91. var query = ProjectFeeDAL.GetProjectFee(expCampus);
  92. //查询条件
  93. foreach (var configuretView in configuretViews)
  94. {
  95. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  96. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  97. }
  98. return query
  99. .OrderBy(x => x.ExaminationProjectFeeID)
  100. .ToGridResultSet<EMIS.ViewModel.ExaminationProjectFeeView>(pageIndex, pageSize);
  101. }
  102. public EMIS.ViewModel.ExaminationProjectFeeView GetProjectFeeView(Expression<Func<EX_ExaminationProjectFee, bool>> expCampus)
  103. {
  104. var query = ProjectFeeDAL.GetProjectFee(expCampus);
  105. return query.FirstOrDefault();
  106. }
  107. public IQueryable<EMIS.ViewModel.ExaminationProjectFeeView> GetProjectFeeList(params EMIS.ViewModel.ConfiguretView[] configuretViews)
  108. {
  109. System.Linq.Expressions.Expression<Func<EX_ExaminationProjectFee, bool>> expCampus = (x => true);
  110. var query = ProjectFeeDAL.GetProjectFee(expCampus);
  111. //查询条件
  112. foreach (var configuretView in configuretViews)
  113. {
  114. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  115. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  116. }
  117. return query
  118. .OrderBy(x => x.ExaminationProjectFeeID);
  119. }
  120. public Bowin.Common.Linq.Entity.IGridResultSet<EMIS.ViewModel.ExaminationProjectView> GetProjectListViewGrid(int pageIndex, int pageSize, params ViewModel.ConfiguretView[] configuretViews)
  121. {
  122. Expression<Func<EX_ExaminationProject, bool>> expCampus = (x => true);
  123. var query = ProjectFeeDAL.GetProectListViewGrid(expCampus);
  124. //查询条件
  125. foreach (var configuretView in configuretViews)
  126. {
  127. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  128. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  129. }
  130. var result = query
  131. .OrderBy(x => x.ExaminationType).ThenBy(x=>x.Name)
  132. .ToGridResultSet<EMIS.ViewModel.ExaminationProjectView>(pageIndex, pageSize);
  133. result.rows.ForEach(s =>
  134. {
  135. s.ProjectSubjects = s.EX_ExaminationProjectSubject.Select(q => (object)q.ExaminationSubjectID).ToList();
  136. });
  137. return result;
  138. }
  139. public IQueryable<EMIS.ViewModel.ExaminationProjectView> GetProjectList(params ViewModel.ConfiguretView[] configuretViews)
  140. {
  141. Expression<Func<EX_ExaminationProject, bool>> expCampus = (x => true);
  142. var query = ProjectFeeDAL.GetProectListViewGrid(expCampus);
  143. //查询条件
  144. foreach (var configuretView in configuretViews)
  145. {
  146. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  147. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  148. }
  149. return query;
  150. }
  151. public EMIS.ViewModel.ProjectFeeTypeView GetProjectFeeType(Guid? ProjectFeeTypeID)
  152. {
  153. try
  154. {
  155. var query = ProjectFeeDAL.GetProjectFeeType(x => x.ExaminationProjectFeeTypeID == ProjectFeeTypeID).SingleOrDefault();
  156. return query;
  157. }
  158. catch (Exception ex)
  159. {
  160. throw new Exception(ex.Message);
  161. }
  162. }
  163. public EMIS.ViewModel.ExaminationProjectFeeView GetProjectFee(Guid? ExaminationProjectFeeID)
  164. {
  165. try
  166. {
  167. var query = ProjectFeeDAL.GetProjectFee(x => x.ExaminationProjectFeeID == ExaminationProjectFeeID).SingleOrDefault();
  168. return query;
  169. }
  170. catch (Exception ex)
  171. {
  172. throw new Exception(ex.Message);
  173. }
  174. }
  175. public EMIS.ViewModel.ExaminationProjectView GetProjectView(Expression<Func<EX_ExaminationProject, bool>> expCampus)
  176. {
  177. try
  178. {
  179. var query = ProjectFeeDAL.GetProectListViewGrid(expCampus).FirstOrDefault();
  180. return query;
  181. }
  182. catch (Exception ex)
  183. {
  184. throw new Exception(ex.Message);
  185. }
  186. }
  187. public void ProjectFeeTypeEdit(EMIS.ViewModel.ProjectFeeTypeView view)
  188. {
  189. var entity = ProjectFeeDAL.ProjectFeeTypeRepository.Entities
  190. .SingleOrDefault(x => x.ExaminationProjectFeeTypeID == view.ExaminationProjectFeeTypeID);
  191. if (entity == null)
  192. {
  193. entity = new EMIS.Entities.EX_ExaminationProjectFeeType();
  194. entity.ExaminationProjectFeeTypeID = Guid.NewGuid();
  195. this.SetNewStatus(entity);
  196. ProjectFeeDAL.ProjectFeeTypeRepository.UnitOfWork.Add(entity);
  197. }
  198. entity.CreateTime = DateTime.Now;
  199. entity.ExaminationProjectFeeID = view.ExaminationProjectFeeID;
  200. entity.FeeTypeID = view.FeeTypeID;
  201. entity.Fee = view.Fee;
  202. entity.IsMaterial = view.IsMaterial;
  203. entity.IsRequiredForNew = view.IsRequiredForNew;
  204. entity.IsResit = view.IsResit;
  205. entity.IsTrainingFee = view.IsTrainingFee;
  206. this.SetModifyStatus(entity);
  207. ProjectFeeDAL.ProjectFeeTypeRepository.UnitOfWork.Commit();
  208. }
  209. public void ProjectFeeEdit(EMIS.ViewModel.ExaminationProjectFeeView view)
  210. {
  211. var entity = ProjectFeeDAL.ProjectFeeRepository.Entities
  212. .SingleOrDefault(x => x.ExaminationProjectFeeID == view.ExaminationProjectFeeID);
  213. if (entity == null)
  214. {
  215. entity = new EX_ExaminationProjectFee();
  216. this.SetNewStatus(entity);
  217. ProjectFeeDAL.ProjectFeeTypeRepository.UnitOfWork.Add(entity);
  218. }
  219. entity.CreateTime = DateTime.Now;
  220. entity.ExaminationProjectFeeID = view.ExaminationProjectFeeID;
  221. entity.Name = view.Name;
  222. entity.RecordStatus = view.RecordStatus;
  223. entity.ExaminationProjectID = view.ExaminationProjectID;
  224. this.SetModifyStatus(entity);
  225. ProjectFeeDAL.ProjectFeeRepository.UnitOfWork.Commit();
  226. }
  227. public bool ProjectFeeDelete(List<Guid?> ExaminationProjectFeeIDs)
  228. {
  229. try
  230. {
  231. UnitOfWork.Delete<EMIS.Entities.EX_ExaminationProjectFeeType>(x => ExaminationProjectFeeIDs.Contains(x.ExaminationProjectFeeID));
  232. UnitOfWork.Delete<EX_ExaminationProjectFee>(x => ExaminationProjectFeeIDs.Contains(x.ExaminationProjectFeeID));
  233. UnitOfWork.Commit();
  234. return true;
  235. }
  236. catch (Exception)
  237. {
  238. throw;
  239. }
  240. }
  241. public bool ProjectDelete(List<Guid?> ExaminationProjectIDs)
  242. {
  243. try
  244. {
  245. UnitOfWork.Delete<EX_ExaminationProjectSubject>(x => ExaminationProjectIDs.Contains(x.ExaminationProjectID));
  246. UnitOfWork.Delete<EX_ExaminationProject>(x => ExaminationProjectIDs.Contains(x.ExaminationProjectID));
  247. UnitOfWork.Commit();
  248. return true;
  249. }
  250. catch (Exception)
  251. {
  252. throw;
  253. }
  254. }
  255. public bool ProjectFeeTypeDelete(List<Guid?> ExaminationProjectFeeTypeIDs)
  256. {
  257. try
  258. {
  259. UnitOfWork.Delete<EMIS.Entities.EX_ExaminationProjectFeeType>(x => ExaminationProjectFeeTypeIDs.Contains(x.ExaminationProjectFeeTypeID));
  260. UnitOfWork.Commit();
  261. return true;
  262. }
  263. catch (Exception)
  264. {
  265. throw;
  266. }
  267. }
  268. public EMIS.ViewModel.ExaminationProjectView GetProject(Guid? ExaminationProjectID)
  269. {
  270. try
  271. {
  272. var query = ProjectFeeDAL.GetProectListViewGrid(x => x.ExaminationProjectID == ExaminationProjectID).SingleOrDefault();
  273. query.ProjectSubjects = query.EX_ExaminationProjectSubject.Select(q => (object)q.ExaminationSubjectID).ToList();
  274. return query;
  275. }
  276. catch (Exception ex)
  277. {
  278. throw new Exception(ex.Message);
  279. }
  280. }
  281. public void ProjectEdit(EMIS.ViewModel.ExaminationProjectView view, List<ExamSubjectView> subjectList)
  282. {
  283. var entity = ProjectFeeDAL.ProjectRepository.Entities
  284. .SingleOrDefault(x => x.ExaminationProjectID == view.ExaminationProjectID);
  285. if (entity == null)
  286. {
  287. entity = new EX_ExaminationProject();
  288. this.SetNewStatus(entity);
  289. ProjectFeeDAL.ProjectFeeTypeRepository.UnitOfWork.Add(entity);
  290. }
  291. else {
  292. this.SetModifyStatus(entity);
  293. }
  294. entity.ExaminationProjectID = view.ExaminationProjectID;
  295. entity.Name = view.Name;
  296. entity.ExaminationLevelID = view.ExaminationLevelID;
  297. entity.ExaminationTypeID = view.ExaminationTypeID;
  298. entity.IssuedByID = view.IssuedByID;
  299. entity.PreposeProjectID = view.PreposeProjectID;
  300. entity.Remark = view.Remark;
  301. //修改科目
  302. UnitOfWork.Delete<EX_ExaminationProjectSubject>(x => x.ExaminationProjectID == entity.ExaminationProjectID);
  303. List<EX_ExaminationProjectSubject> projectSubjectList = new List<EX_ExaminationProjectSubject>();
  304. if (subjectList != null)
  305. {
  306. subjectList.ForEach(x =>
  307. {
  308. EX_ExaminationProjectSubject projectSubject = new EX_ExaminationProjectSubject();
  309. projectSubject.ExaminationProjectSubjectID = Guid.NewGuid();
  310. projectSubject.ExaminationProjectID = entity.ExaminationProjectID;
  311. projectSubject.ExaminationSubjectID = x.ExaminationSubjectID;
  312. projectSubject.ResitCount = x.ResitCount;
  313. this.SetNewStatus(projectSubject);
  314. projectSubjectList.Add(projectSubject);
  315. });
  316. }
  317. UnitOfWork.BulkInsert(projectSubjectList);
  318. UnitOfWork.Commit();
  319. }
  320. public IGridResultSet<ExamSubjectView> GetSubjectByProjectIDGrid(ConfiguretView configuretView, Guid? projectID)
  321. {
  322. Expression<Func<EX_ExaminationProjectSubject, bool>> expeps = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE);
  323. expeps = expeps.And(x => x.ExaminationProjectID == projectID);
  324. var query = ProjectFeeDAL.GetExamSubjectByProjectID(expeps);
  325. //查询条件
  326. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  327. {
  328. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  329. }
  330. return query.OrderBy(x => x.ExaminationSubjectID)
  331. .ToGridResultSet<ExamSubjectView>();
  332. }
  333. public IGridResultSet<ExamSubjectView> GetSubjectListGrid(ConfiguretView configuretView, int pageIndex, int pageSize)
  334. {
  335. var query = ProjectFeeDAL.GetExamSubject();
  336. return query.OrderBy(x => x.ExaminationSubjectID)
  337. .ToGridResultSet<ExamSubjectView>(pageIndex, pageSize);
  338. }
  339. }
  340. }