123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- 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.ViewModel.PaymentManage;
- using EMIS.ViewModel;
- using EMIS.DataLogic.PaymentManage;
- using EMIS.Entities;
- namespace EMIS.CommonLogic.PaymentManage
- {
- public class StaffStandardServices : BaseServices, IStaffStandardServices
- {
- public StaffStandardDAL StaffStandardDAL { get; set; }
- public IGridResultSet<StaffStandardView> GetStaffStandardViewList(ConfiguretView staffStandardConditionView,
- Guid? collegeID, Guid? departmentID, Guid? userID, int? pageIndex, int? pageSize)
- {
- Expression<Func<TP_StaffStandard, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<CF_College, bool>> collegeExp = (x => true);
- Expression<Func<CF_Department, bool>> departmentExp = (x => true);
- if (collegeID.HasValue)
- {
- collegeExp = collegeExp.And(x => x.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- departmentExp = departmentExp.And(x => x.DepartmentID == departmentID);
- }
- if (userID.HasValue)
- {
- exp = exp.And(x => x.UserID == userID);
- }
-
- var query = StaffStandardDAL.GetStaffStandardViewQueryable(exp, departmentExp, collegeExp);
- if (!string.IsNullOrEmpty(staffStandardConditionView.ConditionValue) && !string.IsNullOrEmpty(staffStandardConditionView.Attribute))
- query = query.DynamicWhere(staffStandardConditionView.Attribute, staffStandardConditionView.Condition, staffStandardConditionView.ConditionValue);
- query = query.OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
- .ThenBy(x => x.DepartmentName)
- .ThenBy(x => x.LoginID);
- return query.ToGridResultSet<StaffStandardView>(pageIndex, pageSize);
- }
- public List<StaffStandardView> GetStaffStandardViewList(ConfiguretView staffStandardConditionView,
- Guid? collegeID, Guid? departmentID, Guid? userID)
- {
- Expression<Func<TP_StaffStandard, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<CF_College, bool>> collegeExp = (x => true);
- Expression<Func<CF_Department, bool>> departmentExp = (x => true);
- if (collegeID.HasValue)
- {
- collegeExp = collegeExp.And(x => x.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- departmentExp = departmentExp.And(x => x.DepartmentID == departmentID);
- }
- if (userID.HasValue)
- {
- exp = exp.And(x => x.UserID == userID);
- }
-
- var query = StaffStandardDAL.GetStaffStandardViewQueryable(exp, departmentExp, collegeExp);
- if (!string.IsNullOrEmpty(staffStandardConditionView.ConditionValue) && !string.IsNullOrEmpty(staffStandardConditionView.Attribute))
- query = query.DynamicWhere(staffStandardConditionView.Attribute, staffStandardConditionView.Condition, staffStandardConditionView.ConditionValue);
- query = query.OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
- .ThenBy(x => x.DepartmentName)
- .ThenBy(x => x.LoginID);
- return query.ToList();
- }
- public StaffStandardView GetStaffStandardView(Guid? staffStandardID)
- {
- var query = StaffStandardDAL.GetStaffStandardViewQueryable(x => x.StaffStandardID == staffStandardID, (x => true), (x => true));
- return query.FirstOrDefault();
- }
- public void Save(StaffStandardView staffStandardView)
- {
- TP_StaffStandard staffStandard = new TP_StaffStandard();
- staffStandard = StaffStandardDAL.StaffStandardRepository.GetSingle(x => x.UserID == staffStandardView.UserID
- && x.StaffStandardID != staffStandardView.StaffStandardID);
- if (staffStandard != null)
- {
- throw new Exception("已有相同的标准课酬设置,请勿重复设置。");
- }
- if (staffStandardView.StaffStandardID == null || staffStandardView.StaffStandardID == Guid.Empty)
- {
-
- staffStandard = new TP_StaffStandard();
- staffStandard.StaffStandardID = Guid.NewGuid();
- SetNewStatus(staffStandard);
- UnitOfWork.Add(staffStandard);
- }
- else
- {
- staffStandard = StaffStandardDAL.StaffStandardRepository.GetSingle(x => x.StaffStandardID == staffStandardView.StaffStandardID);
- if (staffStandard == null)
- {
- throw new Exception("未能找到需要修改的数据,数据可能已被其他用户更改。");
- }
- SetModifyStatus(staffStandard);
- }
- staffStandard.UserID = staffStandardView.UserID;
- staffStandard.Amount = staffStandardView.Amount;
- UnitOfWork.Commit();
- }
- public void Delete(IList<Guid?> staffStandardIDList)
- {
- if (staffStandardIDList.Count > 0)
- {
- UnitOfWork.Delete<TP_StaffStandard>(x => staffStandardIDList.Contains(x.StaffStandardID));
- }
- }
- }
- }
|