|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using BWP.B3Frameworks.BO.NamedValueTemplate;
|
|
|
using BWP.B3Sale.BL;
|
|
|
using BWP.B3Sale.BO;
|
|
|
using Forks.EnterpriseServices.BusinessInterfaces;
|
|
|
using Forks.EnterpriseServices.DomainObjects2;
|
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery;
|
|
|
using Forks.EnterpriseServices.SqlDoms;
|
|
|
using TSingSoft.WebPluginFramework.BIPlugins.BLEvents;
|
|
|
|
|
|
namespace BWP.B3_YunKen.BLActions
|
|
|
{
|
|
|
public class CusAcceptUpdateAcceptInfoBLAction : IBLMethodAction
|
|
|
{
|
|
|
public string Description
|
|
|
{
|
|
|
get { return "【客户验收单】删除或者作废时更新验收数量"; }
|
|
|
}
|
|
|
|
|
|
public void Execute(Forks.EnterpriseServices.BusinessInterfaces.IDmoContext context, object dmo, object parameter)
|
|
|
{
|
|
|
var customer = dmo as CustomerAccept;
|
|
|
if (customer == null)
|
|
|
return;
|
|
|
var details = customer.Details.Where(x => x.BillType == DmoTypeIDAttribute.GetID(typeof(SaleOutStore)) && x.SourceBillDetailID != null && x.BillID != null);
|
|
|
var dom = new DmoQuery(typeof(SaleOutStore_DetailToCustomerAcceptNumber));
|
|
|
dom.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("SaleOutStore_Detail_ID"), details.Select(x=> DQExpression.Value(x.SourceBillDetailID)).ToArray()));
|
|
|
var acceptNumberList = context.Session.ExecuteList(dom).Cast<SaleOutStore_DetailToCustomerAcceptNumber>();
|
|
|
foreach (var detail in details) {
|
|
|
var accDetail = acceptNumberList.FirstOrDefault(x => x.SaleOutStore_Detail_ID == detail.SourceBillDetailID.Value);
|
|
|
if (accDetail != null) {
|
|
|
accDetail.AlreadyAcceptNumber = (accDetail.AlreadyAcceptNumber ?? 0) - (detail.AcceptNum ?? 0);
|
|
|
accDetail.AlreadyAcceptUnitNum = (accDetail.AlreadyAcceptUnitNum ?? 0) - (detail.AcceptNum ?? 0);
|
|
|
accDetail.AlreadyAcceptSecondNumber = (accDetail.AlreadyAcceptSecondNumber ?? 0) - (detail.AcceptSecondNumber ?? 0);
|
|
|
if (accDetail.AlreadyAcceptNumber == 0 || accDetail.AlreadyAcceptUnitNum == 0 || accDetail.AlreadyAcceptSecondNumber == 0) {
|
|
|
accDetail.AlreadyAcceptNumber = 0;
|
|
|
accDetail.AlreadyAcceptUnitNum = 0;
|
|
|
accDetail.AlreadyAcceptSecondNumber = 0;
|
|
|
}
|
|
|
context.Session.Update(accDetail);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public IList<string> Features
|
|
|
{
|
|
|
get { return new List<string>(); }
|
|
|
}
|
|
|
|
|
|
public string Name
|
|
|
{
|
|
|
get { return "B3_YunKen.【客户验收单】删除或者作废时更新验收数量"; }
|
|
|
}
|
|
|
}
|
|
|
}
|