12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.DataLogic.TerminatePrinter;
- using EMIS.ViewModel.TerminatePrinter;
- using EMIS.ViewModel;
- using EMIS.Entities;
- namespace EMIS.CommonLogic.TerminatePrinter
- {
- public class PrintControlServices : BaseServices, IPrintControlServices
- {
- public PrintControlDAL PrintControlDAL { get; set; }
- public IGridResultSet<PrintControlView> GetPrintControlViewGrid(ConfiguretView conditionView, int? yearID, int? pageIndex, int? pageSize)
- {
- Expression<Func<Tem_PrintControl, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (yearID.HasValue)
- {
- exp = exp.And(x => x.YearID == yearID);
- }
- var query = PrintControlDAL.GetPrintControlViewQueryable(exp);
- if (!string.IsNullOrEmpty(conditionView.ConditionValue))
- query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue.Trim());
- query = query.OrderByDescending(x => x.YearID);
- return query.ToGridResultSet(pageIndex, pageSize);
- }
- public PrintControlView GetPrintControlView(Guid? printControlID)
- {
- return PrintControlDAL.GetPrintControlViewQueryable(x => x.PrintControlID == printControlID).FirstOrDefault();
- }
- public void Save(PrintControlView printControlView)
- {
- try
- {
- Tem_PrintControl dupPrintControl = PrintControlDAL.PrintControlRepository.Entities.Where(x =>
- x.YearID == printControlView.YearID &&
- x.PrintControlID != printControlView.PrintControlID).FirstOrDefault();
- if (dupPrintControl != null)
- {
- throw new Exception("已经存在" + printControlView.YearID.ToString() + "年级的设置,不能保存。");
- }
- Tem_PrintControl printControl = null;
- if (printControlView.PrintControlID == null || printControlView.PrintControlID == Guid.Empty)
- {
- printControl = new Tem_PrintControl();
- printControl.PrintControlID = Guid.NewGuid();
- SetNewStatus(printControl);
- UnitOfWork.Add(printControl);
- }
- else
- {
- printControl = this.PrintControlDAL.PrintControlRepository.GetSingle(x => x.PrintControlID == printControlView.PrintControlID);
- if (printControl == null)
- {
- throw new Exception("未找到相对应的等级成绩。");
- }
- SetModifyStatus(printControl);
- }
- printControl.YearID = printControlView.YearID;
- printControl.Times = printControlView.Times;
- UnitOfWork.Commit();
- }
- catch (Exception)
- {
- throw;
- }
- }
- public void Delete(IList<Guid?> printControlIDList)
- {
- if (printControlIDList.Count > 0)
- {
- UnitOfWork.Delete<Tem_PrintControl>(x => printControlIDList.Contains(x.PrintControlID));
- }
- }
- }
- }
|