using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Repositories; using EMIS.Entities; using EMIS.ViewModel; using Bowin.Common.Linq.Entity; using EMIS.DataLogic.Common.AdministrativeOrgan; using EMIS.Utility; using System.Linq.Expressions; namespace EMIS.CommonLogic.AdministrativeOrgan { public class CampusServices : BaseServices, ICampusServices { public CampusDAL CampusDAL { get; set; } /// /// 查询校区信息View /// /// /// /// /// public IGridResultSet GetCampusViewGrid(ConfiguretView configuretView, int pageIndex, int pageSize) { //校区信息 Expression> expCampus = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); var query = CampusDAL.GetCampusViewQueryable(expCampus); //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCampus(query) .OrderBy(x => x.No.Length).ThenBy(x => x.No) .ToGridResultSet(pageIndex, pageSize); } /// /// 查询校区信息List /// /// /// public IList GetCampusViewList(ConfiguretView configuretView) { //校区信息 Expression> expCampus = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); var query = CampusDAL.GetCampusViewQueryable(expCampus); //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCampus(query) .OrderBy(x => x.No.Length).ThenBy(x => x.No) .ToList(); } /// /// 查询全部校区信息CF_Campus /// /// public List GetCampusList() { //校区信息 Expression> expCampus = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); var query = CampusDAL.CampusRepository.GetList(expCampus); return this.GetQueryByDataRangeByCampus(query) .OrderBy(x => x.No.Length).ThenBy(x => x.No) .ToList(); } /// /// 查询全部校区信息CF_Campus(不考虑状态列) /// /// public List GetCampusListWithoutDataRange() { //校区信息 Expression> expCampus = (x => true); var query = CampusDAL.CampusRepository.GetList(expCampus); return query.OrderBy(x => x.No.Length).ThenBy(x => x.No) .ToList(); } /// /// 查询对应的校区信息CampusView /// /// /// public CampusView GetCampusView(Guid? campusID) { try { var query = CampusDAL.GetCampusViewQueryable(x => x.CampusID == campusID) .SingleOrDefault(); return query; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 编辑(新增、修改,业务主键:校区代码或校区名称) /// /// public void CampusEdit(CampusView campusView) { try { //查询数据库进行验证 var campusVerification = CampusDAL.CampusRepository .GetList(x => x.CampusID != campusView.CampusID && (x.No == campusView.No || x.Name == campusView.Name)) .FirstOrDefault(); if (campusVerification == null) { //数据有误验证 if (campusView.CampusID != Guid.Empty) { var campus = CampusDAL.CampusRepository .GetList(x => x.CampusID == campusView.CampusID) .SingleOrDefault(); var campusProfile = CampusDAL.CampusProfileRepository .GetList(x => x.CampusID == campusView.CampusID) .SingleOrDefault(); if (campus == null) { throw new Exception("数据有误,请核查"); } else { //表示修改 campus.UniversityID = campusView.UniversityID; campus.No = campusView.No; campus.Name = campusView.Name; campus.SimpleName = campusView.SimpleName; campus.EnglishName = campusView.EnglishName; campus.Remark = campusView.Remark; SetModifyStatus(campusView); //校区信息扩展表 if (campusProfile == null) { //新增 var newCampusProfile = new CF_CampusProfile(); newCampusProfile.CampusID = campusView.CampusID; newCampusProfile.Generalsuper = campusView.Generalsuper; newCampusProfile.Recruitstudents = campusView.Recruitstudents; newCampusProfile.Placesuper = campusView.Placesuper; newCampusProfile.Teachingsuper = campusView.Teachingsuper; newCampusProfile.Studentcharge = campusView.Studentcharge; newCampusProfile.ZIPCode = campusView.ZIPCode; newCampusProfile.Officephone = campusView.Officephone; newCampusProfile.FAX = campusView.FAX; newCampusProfile.Email = campusView.Email; newCampusProfile.Evolution = campusView.Evolution; SetNewStatus(newCampusProfile); UnitOfWork.Add(newCampusProfile); } else { //修改 campusProfile.Generalsuper = campusView.Generalsuper; campusProfile.Recruitstudents = campusView.Recruitstudents; campusProfile.Placesuper = campusView.Placesuper; campusProfile.Teachingsuper = campusView.Teachingsuper; campusProfile.Studentcharge = campusView.Studentcharge; campusProfile.ZIPCode = campusView.ZIPCode; campusProfile.Officephone = campusView.Officephone; campusProfile.FAX = campusView.FAX; campusProfile.Email = campusView.Email; campusProfile.Evolution = campusView.Evolution; SetModifyStatus(campusProfile); } } } else { //表示新增(CF_Campus主表) CF_Campus campus = new CF_Campus(); campus.CampusID = Guid.NewGuid(); campus.UniversityID = campusView.UniversityID; campus.No = campusView.No; campus.Name = campusView.Name; campus.SimpleName = campusView.SimpleName; campus.EnglishName = campusView.EnglishName; campus.Remark = campusView.Remark; SetNewStatus(campus); UnitOfWork.Add(campus); //表示新增(CF_CampusProfile扩展表) CF_CampusProfile campusProfile = new CF_CampusProfile(); campusProfile.CampusID = campus.CampusID; campusProfile.Generalsuper = campusView.Generalsuper; campusProfile.Recruitstudents = campusView.Recruitstudents; campusProfile.Placesuper = campusView.Placesuper; campusProfile.Teachingsuper = campusView.Teachingsuper; campusProfile.Studentcharge = campusView.Studentcharge; campusProfile.ZIPCode = campusView.ZIPCode; campusProfile.Officephone = campusView.Officephone; campusProfile.FAX = campusView.FAX; campusProfile.Email = campusView.Email; campusProfile.Evolution = campusView.Evolution; SetNewStatus(campusProfile); UnitOfWork.Add(campusProfile); } } else { throw new Exception("已存在相同的" + RSL.Get("CampusCode") + "或" + RSL.Get("CampusName") + ",请核查"); } //事务提交 UnitOfWork.Commit(); } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 删除 /// /// /// public bool CampusDelete(List campusIDList) { try { UnitOfWork.Delete(x => campusIDList.Contains(x.CampusID)); UnitOfWork.Commit(); return true; } catch (Exception) { throw; } } } }