123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.ViewModel;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.MinorManage.MinorSetting;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using EMIS.DataLogic.MinorManage.MinorSetting;
- namespace EMIS.CommonLogic.MinorManage.MinorSetting
- {
- public class MinorStandardSettingServices : BaseServices, IMinorStandardSettingServices
- {
- public MinorStandardSettingDAL minorStandardSettingDAL { get; set; }
- /// <summary>
- /// 查询辅修专业设置列表
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="minorStandardID"></param>
- /// <param name="standardID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<MinorStandardSettingView> GetMinorControlViewGrid(ConfiguretView configuretView, int? minorStandardID, int? standardID, int pageIndex, int pageSize)
- {
- Expression<Func<CF_MinorStandardSetting, bool>> exp = x => true;
- if (minorStandardID.HasValue)
- {
- exp = exp.And(x => x.MinorStandardID == minorStandardID);
- }
- if (standardID.HasValue)
- {
- exp = exp.And(x => x.StandardID == standardID);
- }
- var query = minorStandardSettingDAL.GetMinorStandardSettingViewQueryable(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- }
- query = query.OrderByDescending(x => x.StandardID).ThenByDescending(x => x.MinorStandardID);
- return query.ToGridResultSet<MinorStandardSettingView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询辅修专业设置列表(Excel)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="minorStandardID"></param>
- /// <param name="standardID"></param>
- /// <param name="idList"></param>
- /// <returns></returns>
- public List<MinorStandardSettingView> GetMinorControlViewList(ConfiguretView configuretView, int? minorStandardID, int? standardID, List<Guid?> idList)
- {
- Expression<Func<CF_MinorStandardSetting, bool>> exp = x => true;
- if (minorStandardID.HasValue)
- {
- exp = exp.And(x => x.MinorStandardID == minorStandardID);
- }
- if (standardID.HasValue)
- {
- exp = exp.And(x => x.StandardID == standardID);
- }
- if (idList.Count > 0 && idList != null)
- {
- exp = exp.And(x => idList.Contains(x.MinorStandardSettingID));
- }
- var query = minorStandardSettingDAL.GetMinorStandardSettingViewQueryable(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- }
- query = query.OrderByDescending(x => x.StandardID).ThenByDescending(x => x.MinorStandardID);
- return query.ToList();
- }
- /// <summary>
- /// 查询对应的辅修专业设置
- /// </summary>
- /// <param name="retakeOpenControlID"></param>
- /// <returns></returns>
- public MinorStandardSettingView GetMinorStandardSettingView(Guid? minorStandardSettingID)
- {
- var query = minorStandardSettingDAL.GetMinorStandardSettingViewQueryable(x => x.MinorStandardSettingID == minorStandardSettingID);
- return query.FirstOrDefault();
- }
- /// <summary>
- /// 辅修专业设置编辑(新增、修改)
- /// </summary>
- /// <param name="retakeOpenControlView"></param>
- public void MinorStandardSettingEdit(MinorStandardSettingView minorStandardSettingView)
- {
- try
- {
- CF_MinorStandardSetting minorStandardSetting = new CF_MinorStandardSetting();
- if (minorStandardSettingView.MinorStandardSettingID == null || minorStandardSettingView.MinorStandardSettingID == Guid.Empty)
- {
- //新增、复制新增
- minorStandardSetting = minorStandardSettingDAL.minorStandardSettingRepository
- .GetSingle(x => x.StandardID == minorStandardSettingView.StandardID && x.MinorStandardID == minorStandardSettingView.MinorStandardID);
- if (minorStandardSetting != null)
- {
- throw new Exception("已存在相同的辅修专业设置信息。");
- }
- minorStandardSetting = new CF_MinorStandardSetting();
- minorStandardSetting.MinorStandardSettingID = Guid.NewGuid();
- minorStandardSetting.StandardID = minorStandardSettingView.StandardID;
- minorStandardSetting.MinorStandardID = minorStandardSettingView.MinorStandardID;
- SetNewStatus(minorStandardSetting);
- UnitOfWork.Add(minorStandardSetting);
- }
- else
- {
- //修改
- minorStandardSetting = minorStandardSettingDAL.minorStandardSettingRepository
- .GetSingle(x => x.MinorStandardSettingID != minorStandardSettingView.MinorStandardSettingID
- && x.StandardID == minorStandardSettingView.StandardID && x.MinorStandardID == minorStandardSettingView.MinorStandardID);
- if (minorStandardSetting != null)
- {
- throw new Exception("已存在相同的辅修专业设置信息。");
- }
- minorStandardSetting = minorStandardSettingDAL.minorStandardSettingRepository
- .GetSingle(x => x.MinorStandardSettingID == minorStandardSettingView.MinorStandardSettingID);
- if (minorStandardSetting == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- //minorStandardSetting.MinorStandardSettingID = minorStandardSettingView.MinorStandardSettingID
- minorStandardSetting.StandardID = minorStandardSettingView.StandardID;
- minorStandardSetting.MinorStandardID = minorStandardSettingView.MinorStandardID;
- SetModifyStatus(minorStandardSetting);
- }
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 辅修专业设置删除
- /// </summary>
- /// <param name="openControlIDList"></param>
- public void MinorStandardSettingDelete(IList<Guid?> minorStandardSettingIDList)
- {
- try
- {
- if (minorStandardSettingIDList.Count > 0)
- {
- UnitOfWork.Delete<CF_MinorStandardSetting>(x => minorStandardSettingIDList.Contains(x.MinorStandardSettingID));
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查找标准专业(排除已选专业)
- /// </summary>
- /// <param name="standardID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<MinorStandardSettingView> GetStandardNotSelectID(int? standardID, int pageIndex, int pageSize)
- {
- Expression<Func<Sys_DictionaryItem, bool>> exp = x => true;
- exp = exp.And(x => x.DictionaryCode == "CF_Standard");
- if(standardID.HasValue)
- {
- exp = exp.And(x => x.Value != standardID);
- }
- var query = minorStandardSettingDAL.GetStandardNotHaveSelect(exp);
-
-
- return query.ToGridResultSet<MinorStandardSettingView>(pageIndex, pageSize);
- }
- }
- }
|