123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Repositories;
- using EMIS.ViewModel;
- using Bowin.Common.Linq.Entity;
- using EMIS.Entities;
- using EMIS.ViewModel.ScoreManage;
- namespace EMIS.CommonLogic.ScoreManage
- {
- public class CreditFormulaServices : BaseServices, ICreditFormulaServices
- {
- public CreditFormulaRepository creditFormulaRepository { get; set; }
- /// <summary>
- /// 成绩学分公式设置
- /// </summary>
- /// <param name="name"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public Bowin.Common.Linq.Entity.IGridResultSet<Entities.ER_CreditFormula> GetCreditFormulaGrid(string name, int pageIndex, int pageSize)
- {
- var query = creditFormulaRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (!string.IsNullOrEmpty(name))
- query = query.Where(x => x.Name.Contains(name));
- return query.OrderByDescending(x => x.CreateTime).ToGridResultSet<ER_CreditFormula>(pageIndex, pageSize);
- }
- /// <summary>
- /// 成绩学分公式设置
- /// </summary>
- /// <param name="name"></param>
- /// <returns></returns>
- public List<Entities.ER_CreditFormula> GetCreditFormulaList(string name)
- {
- var query = creditFormulaRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (!string.IsNullOrEmpty(name))
- query = query.Where(x => x.Name.Contains(name));
- return query.OrderByDescending(x => x.CreateTime).ToList();
- }
- /// <summary>
- /// 查询成绩学分公式设置对象
- /// </summary>
- /// <param name="creditFormulaID"></param>
- /// <returns></returns>
- public Entities.ER_CreditFormula GetCreditFormula(Guid? creditFormulaID)
- {
- return creditFormulaRepository.GetSingle(x => x.CreditFormulaID == creditFormulaID);
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="scoreFormulaView"></param>
- public void CreditFormulaAdd(CreditFormulaView creditFormulaView)
- {
- try
- {
- ER_CreditFormula creditFormula = null;
- if (creditFormulaView.CreditFormulaID == null || creditFormulaView.CreditFormulaID == Guid.Empty)
- {
- creditFormula = new ER_CreditFormula();
- creditFormula.CreditFormulaID = Guid.NewGuid();
- creditFormula.Name = creditFormulaView.Name;
- creditFormula.Scores = creditFormulaView.Scores;
- SetNewStatus(creditFormula);
- UnitOfWork.Add(creditFormula);
- }
- else
- {
- creditFormula = GetCreditFormula(creditFormulaView.CreditFormulaID);
- if(creditFormula == null)
- throw new Exception("未找到相对应的成绩学分公式设置!");
- creditFormula.Name = creditFormulaView.Name;
- creditFormula.Scores = creditFormulaView.Scores;
- SetModifyStatus(creditFormula);
- }
- UnitOfWork.Commit();
- }
- catch (Exception)
- {
-
- throw;
- }
- }
- /// <summary>
- /// 根据成绩公式设置ID查询明细
- /// </summary>
- /// <param name="scoreFormulaID"></param>
- /// <returns></returns>
- public void CreditFormulaDelete(List<Guid> creditFormulaIDs)
- {
- try
- {
- if (creditFormulaIDs.Count > 0)
- {
- UnitOfWork.Delete<ER_CreditFormula>(x => creditFormulaIDs.Contains(x.CreditFormulaID));
- }
- }
- catch (Exception)
- {
-
- throw;
- }
- }
- }
- }
|