using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using Bowin.Common.Linq.Entity; using EMIS.Entities; using EMIS.ViewModel; using EMIS.ViewModel.UniversityManage.AdministrativeOrgan; using EMIS.DataLogic.UniversityManage.AdministrativeOrgan; namespace EMIS.CommonLogic.UniversityManage.AdministrativeOrgan { public class UniversityServices : BaseServices, IUniversityServices { public UniversityDAL UniversityDAL { get; set; } /// /// 查询学校信息View /// /// /// /// /// public IGridResultSet GetUniversityViewGrid(ConfiguretView configuretView, int pageIndex, int pageSize) { Expression> expUniversity = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); var query = UniversityDAL.GetUniversityViewQueryable(expUniversity); //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return query.OrderBy(x => x.Code.Length).ThenBy(x => x.Code).ToGridResultSet(pageIndex, pageSize); } /// /// 查询学校信息List /// /// /// public IList GetUniversityViewList(ConfiguretView configuretView) { Expression> expUniversity = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); var query = UniversityDAL.GetUniversityViewQueryable(expUniversity); //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return query.OrderBy(x => x.Code.Length).ThenBy(x => x.Code).ToList(); } /// /// 查询全部学校信息CF_University /// /// public List GetUniversityList() { Expression> expUniversity = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); var query = UniversityDAL.UniversityRepository.GetList(expUniversity); return query.OrderBy(x => x.Code.Length).ThenBy(x => x.Code).ToList(); } /// /// 查询对应的学校信息UniversityView /// /// /// public UniversityView GetUniversityView(Guid? universityID) { try { var query = UniversityDAL.GetUniversityViewQueryable(x => x.UniversityID == universityID).SingleOrDefault(); return query; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 编辑(新增、修改,业务主键:学校代码或学校名称) /// /// public void UniversityEdit(UniversityView universityView) { try { //查询数据库进行验证 var universityVerify = UniversityDAL.UniversityRepository.GetList(x => x.UniversityID != universityView.UniversityID && (x.Code == universityView.Code || x.Name == universityView.Name)).FirstOrDefault(); if (universityVerify == null) { //数据有误验证 if (universityView.UniversityID != Guid.Empty) { var university = UniversityDAL.UniversityRepository.GetList(x => x.UniversityID == universityView.UniversityID, (x => x.CF_UniversityProfile)).SingleOrDefault(); if (university == null) { throw new Exception("数据有误,请核查。"); } else { //表示修改 university.Code = universityView.Code; university.Name = universityView.Name; university.SimpleName = universityView.SimpleName; university.EnglishName = universityView.EnglishName; university.Remark = universityView.Remark; SetModifyStatus(university); //学校信息扩展表 if (university.CF_UniversityProfile == null) { //新增 var newUniversityProfile = new CF_UniversityProfile(); newUniversityProfile.UniversityID = universityView.UniversityID; newUniversityProfile.ProvinceID = universityView.ProvinceID; newUniversityProfile.CityID = universityView.CityID; newUniversityProfile.DistrictID = universityView.DistrictID; newUniversityProfile.PropertyID = universityView.PropertyID; newUniversityProfile.SchoolTypeID = universityView.SchoolTypeID; newUniversityProfile.ManagerID = universityView.ManagerID; newUniversityProfile.FounderTypeID = universityView.FounderTypeID; newUniversityProfile.SchoolLevelID = universityView.SchoolLevelID; newUniversityProfile.HeadMasterName = universityView.HeadMasterName; newUniversityProfile.PartyManageID = universityView.PartyManageID; newUniversityProfile.LegalPersonName = universityView.LegalPersonName; newUniversityProfile.BuildDate = universityView.BuildDate; newUniversityProfile.AnniversaryDate = universityView.AnniversaryDate; newUniversityProfile.SchoolBasis = universityView.SchoolBasis; newUniversityProfile.SchoolMotto = universityView.SchoolMotto; newUniversityProfile.SubjectCount = universityView.SubjectCount; newUniversityProfile.Is211University = universityView.Is211University; newUniversityProfile.IsKeyUniversity = universityView.IsKeyUniversity; newUniversityProfile.IsAdultCollege = universityView.IsAdultCollege; newUniversityProfile.IsPostCollege = universityView.IsPostCollege; newUniversityProfile.IsNetCollege = universityView.IsNetCollege; newUniversityProfile.Telephone = universityView.Telephone; newUniversityProfile.ZIPCode = universityView.ZIPCode; newUniversityProfile.Email = universityView.Email; newUniversityProfile.FAX = universityView.FAX; newUniversityProfile.PublicNum = universityView.PublicNum; newUniversityProfile.HomePage = universityView.HomePage; newUniversityProfile.Address = universityView.Address; newUniversityProfile.EnglishAddress = universityView.EnglishAddress; newUniversityProfile.HistoryEvolution = universityView.HistoryEvolution; SetNewStatus(newUniversityProfile); UnitOfWork.Add(newUniversityProfile); } else { //修改 university.CF_UniversityProfile.ProvinceID = universityView.ProvinceID; university.CF_UniversityProfile.CityID = universityView.CityID; university.CF_UniversityProfile.DistrictID = universityView.DistrictID; university.CF_UniversityProfile.PropertyID = universityView.PropertyID; university.CF_UniversityProfile.SchoolTypeID = universityView.SchoolTypeID; university.CF_UniversityProfile.ManagerID = universityView.ManagerID; university.CF_UniversityProfile.FounderTypeID = universityView.FounderTypeID; university.CF_UniversityProfile.SchoolLevelID = universityView.SchoolLevelID; university.CF_UniversityProfile.HeadMasterName = universityView.HeadMasterName; university.CF_UniversityProfile.PartyManageID = universityView.PartyManageID; university.CF_UniversityProfile.LegalPersonName = universityView.LegalPersonName; university.CF_UniversityProfile.BuildDate = universityView.BuildDate; university.CF_UniversityProfile.AnniversaryDate = universityView.AnniversaryDate; university.CF_UniversityProfile.SchoolBasis = universityView.SchoolBasis; university.CF_UniversityProfile.SchoolMotto = universityView.SchoolMotto; university.CF_UniversityProfile.SubjectCount = universityView.SubjectCount; university.CF_UniversityProfile.Is211University = universityView.Is211University; university.CF_UniversityProfile.IsKeyUniversity = universityView.IsKeyUniversity; university.CF_UniversityProfile.IsAdultCollege = universityView.IsAdultCollege; university.CF_UniversityProfile.IsPostCollege = universityView.IsPostCollege; university.CF_UniversityProfile.IsNetCollege = universityView.IsNetCollege; university.CF_UniversityProfile.Telephone = universityView.Telephone; university.CF_UniversityProfile.ZIPCode = universityView.ZIPCode; university.CF_UniversityProfile.Email = universityView.Email; university.CF_UniversityProfile.FAX = universityView.FAX; university.CF_UniversityProfile.PublicNum = universityView.PublicNum; university.CF_UniversityProfile.HomePage = universityView.HomePage; university.CF_UniversityProfile.Address = universityView.Address; university.CF_UniversityProfile.EnglishAddress = universityView.EnglishAddress; university.CF_UniversityProfile.HistoryEvolution = universityView.HistoryEvolution; SetModifyStatus(university.CF_UniversityProfile); } } } else { //表示新增(CF_University主表) CF_University university = new CF_University(); university.UniversityID = Guid.NewGuid(); university.Code = universityView.Code; university.Name = universityView.Name; university.SimpleName = universityView.SimpleName; university.EnglishName = universityView.EnglishName; university.Remark = universityView.Remark; SetNewStatus(university); UnitOfWork.Add(university); //表示新增(CF_UniversityProfile扩展表) CF_UniversityProfile universityProfile = new CF_UniversityProfile(); universityProfile.UniversityID = university.UniversityID; universityProfile.ProvinceID = universityView.ProvinceID; universityProfile.CityID = universityView.CityID; universityProfile.DistrictID = universityView.DistrictID; universityProfile.PropertyID = universityView.PropertyID; universityProfile.SchoolTypeID = universityView.SchoolTypeID; universityProfile.ManagerID = universityView.ManagerID; universityProfile.FounderTypeID = universityView.FounderTypeID; universityProfile.SchoolLevelID = universityView.SchoolLevelID; universityProfile.HeadMasterName = universityView.HeadMasterName; universityProfile.PartyManageID = universityView.PartyManageID; universityProfile.LegalPersonName = universityView.LegalPersonName; universityProfile.BuildDate = universityView.BuildDate; universityProfile.AnniversaryDate = universityView.AnniversaryDate; universityProfile.SchoolBasis = universityView.SchoolBasis; universityProfile.SchoolMotto = universityView.SchoolMotto; universityProfile.SubjectCount = universityView.SubjectCount; universityProfile.Is211University = universityView.Is211University; universityProfile.IsKeyUniversity = universityView.IsKeyUniversity; universityProfile.IsAdultCollege = universityView.IsAdultCollege; universityProfile.IsPostCollege = universityView.IsPostCollege; universityProfile.IsNetCollege = universityView.IsNetCollege; universityProfile.Telephone = universityView.Telephone; universityProfile.ZIPCode = universityView.ZIPCode; universityProfile.Email = universityView.Email; universityProfile.FAX = universityView.FAX; universityProfile.PublicNum = universityView.PublicNum; universityProfile.HomePage = universityView.HomePage; universityProfile.Address = universityView.Address; universityProfile.EnglishAddress = universityView.EnglishAddress; universityProfile.HistoryEvolution = universityView.HistoryEvolution; SetNewStatus(universityProfile); UnitOfWork.Add(universityProfile); } } else { throw new Exception("已存在相同的学校代码或学校名称,请核查。"); } //事务提交 UnitOfWork.Commit(); } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 删除 /// /// /// public bool UniversityDelete(List universityIDList) { try { UnitOfWork.Remove(x => universityIDList.Contains(x.UniversityID)); UnitOfWork.Remove(x => universityIDList.Contains(x.UniversityID)); UnitOfWork.Commit(); return true; } catch (Exception) { throw; } } } }