123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using System.Transactions;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.StudentManage.StudentChange;
- using EMIS.DataLogic.StudentManage.StudentChange;
- namespace EMIS.CommonLogic.StudentManage.StudentChange
- {
- public class ChangeReportServices : BaseServices, IChangeReportServices
- {
- public ChangeReportDAL ChangeReportDAL { get; set; }
- /// <summary>
- /// 查询对应的异动报表信息ChangeReportView
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<ChangeReportView> GetChangeReportViewGrid(ConfiguretView configuretView, int pageIndex, int pageSize)
- {
- Expression<Func<CF_DifferentDynamicReport, bool>> exp = (x => true);
- var query = ChangeReportDAL.GetChangeReportViewQueryable(exp);
-
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.Code).ToGridResultSet<ChangeReportView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的异动报表信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <returns></returns>
- public IList<ChangeReportView> GetChangeReportViewList(ConfiguretView configuretView)
- {
- Expression<Func<CF_DifferentDynamicReport, bool>> exp = (x => true);
- var query = ChangeReportDAL.GetChangeReportViewQueryable(exp);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.Code).ToList();
- }
- /// <summary>
- /// 查询对应的异动报表信息ChangeReportView(根据异动报表ID)
- /// </summary>
- /// <param name="changeReportID"></param>
- /// <returns></returns>
- public ChangeReportView GetChangeReportView(Guid? changeReportID)
- {
- try
- {
- var changeReportView = ChangeReportDAL.GetChangeReportViewQueryable(x => x.ChangeReportID == changeReportID).SingleOrDefault();
- return changeReportView;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="changeReportView"></param>
- public void ChangeReportEdit(ChangeReportView changeReportView)
- {
- try
- {
- var changeReportVerify = ChangeReportDAL.ChangeReportRepository.GetList(x => x.ChangeReportID != changeReportView.ChangeReportID
- && (x.Code == changeReportView.Code || x.Name == changeReportView.Name)).FirstOrDefault();
- if (changeReportVerify == null)
- {
- if (changeReportView.ChangeReportID != Guid.Empty)
- {
- var changeReport = ChangeReportDAL.ChangeReportRepository.GetList(x => x.ChangeReportID == changeReportView.ChangeReportID).SingleOrDefault();
- if (changeReport == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- else
- {
- changeReport.Code = changeReportView.Code;
- changeReport.Name = changeReportView.Name;
- changeReport.Url = changeReportView.Url;
- }
- }
- else
- {
- var newChangeReport = new CF_DifferentDynamicReport();
- newChangeReport.ChangeReportID = Guid.NewGuid();
- newChangeReport.Code = changeReportView.Code;
- newChangeReport.Name = changeReportView.Name;
- newChangeReport.Url = changeReportView.Url;
- UnitOfWork.Add(newChangeReport);
- }
- }
- else
- {
- throw new Exception("已存在相同的异动报表(报表代码或报表名称唯一),请核查。");
- }
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="changeReportIDs"></param>
- /// <returns></returns>
- public bool ChangeReportDelete(List<Guid?> changeReportIDs)
- {
- try
- {
- UnitOfWork.Delete<CF_DifferentDynamicReport>(x => changeReportIDs.Contains(x.ChangeReportID));
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|