ComplianceServer/oldcode/BLL/QH/QH_PerformanceGroupAudit_BL.cs

71 lines
2.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using WX.CRM.IBLL.QH;
using WX.CRM.Model.Entity;
namespace WX.CRM.BLL.QH
{
public class QH_PerformanceGroupAudit_BL : DbContextRepository<QH_BALANCESALEGROUPERAUDIT>, IQH_PerformanceGroupAudit
{
public void AuditPerformanceGroup(decimal PKID, int sta, string remark, decimal auditid, string auditname)
{
using (var db = new crmContext())
{
var info = db.QH_BALANCESALEGROUPERAUDIT.FirstOrDefault(p => p.PKID == PKID);
if (info == null)
{
throw new Exception("未找到结算记录!");
}
if (info.STATUS == "已确认")
{
throw new Exception("已经确认过了!");
}
if (sta == 0)
info.STATUS = "未确认";
else if (sta == 1)
info.STATUS = "已确认";
else info.STATUS = "未知";
info.REMARK = remark;
info.AUDITBYUSERID = auditid;
info.AUDITBYUSERNAME = auditname;
info.AUDITTIME = System.DateTime.Now;
db.SaveChanges();
}
}
public IList<QH_BALANCESALEGROUPERAUDIT> GetAutitList(decimal[] gId, DateTime? balanceCode, string status, decimal? userId)
{
var where = PredicateExtensionses.True<QH_BALANCESALEGROUPERAUDIT>();
if (gId != null && gId.Length > 1)
{
var g0 = gId[0];
var g1 = gId[1];
//where = where.And(p => p.GID == gId.Value);
//where = where.And(p => gId.Contains(p.GID.GetValueOrDefault()));
where = where.And(p => p.GID == g0 || p.GID == g1);
}
else if (gId != null && gId.Length > 0)
{
var g0 = gId[0];
where = where.And(p => p.GID == g0);
}
if (balanceCode.HasValue)
{
where = where.And(p => p.MONTH == balanceCode.Value);
}
if (!string.IsNullOrEmpty(status))
{
where = where.And(p => p.STATUS == status);
}
if (userId.HasValue)
{
where = where.And(p => p.INNERUSERID == userId);
}
var list = GetList(where);
return list.ToList();
}
}
}