123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.DataLogic.ExaminationApply;
- using EMIS.ViewModel.ExaminationApply;
- using Bowin.Common.Utility;
- using System.Text.RegularExpressions;
- namespace EMIS.CommonLogic.ExaminationApply
- {
- public class ExaminationSubjectsServices : BaseServices, IExaminationSubjectsServices
- {
- public ExaminationSubjectDAL ExaminationSubjectDAL { get; set; }
- public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.ExaminationApply.ExaminationSubjectView> GetExaminationSubjectViewList(ViewModel.ConfiguretView examinationSubjectView,
- int? examinationFormID, int pageIndex, int pageSize)
- {
- Expression<Func<EX_ExaminationSubject, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (examinationFormID.HasValue)
- {
- exp = exp.And(x => x.ExaminationFormID == examinationFormID);
- }
- var q = ExaminationSubjectDAL.GetExaminationSubjectView(exp);
- if (!string.IsNullOrEmpty(examinationSubjectView.ConditionValue) && !string.IsNullOrEmpty(examinationSubjectView.Attribute))
- q = q.DynamicWhere(examinationSubjectView.Attribute, examinationSubjectView.Condition, examinationSubjectView.ConditionValue);
- return q.OrderBy(x => x.Name).ToGridResultSet<ExaminationSubjectView>(pageIndex, pageSize);
- }
- public IList<ViewModel.ExaminationApply.ExaminationSubjectView> GetExaminationSubjectViewList(ViewModel.ConfiguretView examinationSubjectView, int? examinationFormID, Guid? examinationSubjectID)
- {
- Expression<Func<EX_ExaminationSubject, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (examinationFormID.HasValue)
- {
- exp = exp.And(x => x.ExaminationFormID == examinationFormID);
- }
- var q = ExaminationSubjectDAL.GetExaminationSubjectView(exp);
- if (!string.IsNullOrEmpty(examinationSubjectView.ConditionValue) && !string.IsNullOrEmpty(examinationSubjectView.Attribute))
- q = q.DynamicWhere(examinationSubjectView.Attribute, examinationSubjectView.Condition, examinationSubjectView.ConditionValue);
- return q.OrderBy(x => x.Name).ToList();
- }
- public ViewModel.ExaminationApply.ExaminationSubjectView GetExaminationSubjectViewInfo(Guid? examinationSubjectID)
- {
- return ExaminationSubjectDAL.GetExaminationSubjectView(x => x.ExaminationSubjectID == examinationSubjectID).FirstOrDefault();
- }
- public void Save(ViewModel.ExaminationApply.ExaminationSubjectView examinationSubjectView)
- {
-
- var examinationSubjectEntity = ExaminationSubjectDAL.ExaminationSubjectRepository.GetSingle(x => x.ExaminationSubjectID == examinationSubjectView.ExaminationSubjectID);
- //考试科目名字唯一
- var RepeatSubject = ExaminationSubjectDAL.ExaminationSubjectRepository.GetSingle(x =>
- //x.ExaminationTypeID == examinationSubjectView.ExaminationTypeID &&
- //x.ExaminationFormID == examinationSubjectView.ExaminationFormID &&
- //x.SchoolyearID == examinationSubjectView.SchoolyearID &&
- x.Name == examinationSubjectView.Name);
- if (examinationSubjectEntity != null)
- {
- if (RepeatSubject != null && examinationSubjectEntity.ExaminationSubjectID != RepeatSubject.ExaminationSubjectID)
- { //考试科目,判断考试类型、考试类别、学年学期、考试科目名称不能重复
- throw new Exception("已存在【" + RepeatSubject.Name + "】考试科目,请核查");
- }
- examinationSubjectEntity.ExaminationTypeID = examinationSubjectView.ExaminationTypeID;
- examinationSubjectEntity.SchoolyearID = examinationSubjectView.SchoolyearID;
- examinationSubjectEntity.ExaminationFormID = examinationSubjectView.ExaminationFormsID;
- examinationSubjectEntity.Name = examinationSubjectView.Name;
- examinationSubjectEntity.PreposeSubjectID = examinationSubjectView.PreposeSubjectID;
- examinationSubjectEntity.PreposeScoreLimit = examinationSubjectView.PreposeScoreLimit;
- examinationSubjectEntity.ExaminationDate = examinationSubjectView.ExaminationDate;
- examinationSubjectEntity.PeopleNumLimit = examinationSubjectView.PeopleNumLimit;
- examinationSubjectEntity.Cost = examinationSubjectView.Cost;
- examinationSubjectEntity.Remark = examinationSubjectView.Remark;
- this.SetModifyStatus(examinationSubjectEntity);
- }
- else
- {
- if (RepeatSubject != null)
- { //考试科目,判断考试类型、考试类别、学年学期、名称不能重复
- throw new Exception("已存在【" + RepeatSubject.Name + "】考试科目,请核查");
- }
- examinationSubjectEntity = new EX_ExaminationSubject();
- examinationSubjectEntity.ExaminationSubjectID = Guid.NewGuid();
- examinationSubjectEntity.ExaminationTypeID = examinationSubjectView.ExaminationTypeID;
- examinationSubjectEntity.SchoolyearID = examinationSubjectView.SchoolyearID;
- examinationSubjectEntity.ExaminationFormID = examinationSubjectView.ExaminationFormsID;
- examinationSubjectEntity.Name = examinationSubjectView.Name;
- examinationSubjectEntity.PreposeSubjectID = examinationSubjectView.PreposeSubjectID;
- examinationSubjectEntity.PreposeScoreLimit = examinationSubjectView.PreposeScoreLimit;
- examinationSubjectEntity.ExaminationDate = examinationSubjectView.ExaminationDate;
- examinationSubjectEntity.PeopleNumLimit = examinationSubjectView.PeopleNumLimit;
- examinationSubjectEntity.Cost = examinationSubjectView.Cost;
- examinationSubjectEntity.Remark = examinationSubjectView.Remark;
- this.SetNewStatus(examinationSubjectEntity);
- UnitOfWork.Add(examinationSubjectEntity);
- }
- UnitOfWork.Commit();
- }
- public void Delete(IList<Guid?> examinationSubjectID)
- {
- if (examinationSubjectID.Count > 0)
- {
- UnitOfWork.Delete<EX_ExaminationSubject>(x => examinationSubjectID.Contains(x.ExaminationSubjectID));
- }
- }
- public string[] Validation(List<int?> ExaminationFormIDs, List<string> names)
- {
- try
- {
- for (int i = 0; i < ExaminationFormIDs.Count; i++)
- {int? ExaminationFormID = ExaminationFormIDs[0];
- string name = names[0];
- //var SubjectCountLimit = SubjectCountLimitDAL.ExaminationSubjectCountLimitRepository.Entities.Where(x =>
- // x.ExaminationTypeID == examinationType.Value && x.FacultymajorID == facultymajorIDs[0].Value &&
- // x.Years == years[0].Value).FirstOrDefault();
- var Subject = ExaminationSubjectDAL.GetExaminationSubjectView(x =>x.ExaminationFormID == ExaminationFormID && x.Name == name).FirstOrDefault();
- if (Subject != null)
- return new[] { "false", "科目【" + Subject.Name + "】"+ Subject.ExaminationFormName + "的考试性质数据已存在。" };
- }
- }
- catch (Exception ex)
- {
- return new[] { "false", ex.Message };
- }
- return new[] { "true", "成功" };
- }
- }
- }
|