我一直试图覆盖“更新合同价格”页面的流程代表。
public ContractPriceUpdate()
{
Items.SetSelected<ContractDetail.selected>();
Items.SetProcessDelegate<ContractMaint>(UpdatePrices);
Items.SetProcessCaption(Messages.Update);
Items.SetProcessAllCaption(Messages.UpdateAll);
PXUIFieldAttribute.SetDisplayName<Contract.contractCD>(Caches[typeof(Contract)], Common.Messages.Identifier);
}
protected static void UpdatePrices(ContractMaint graph, ContractDetail item)
{
Contract contract = PXSelect<Contract, Where<Contract.contractID, Equal<Required<Contract.contractID>>>>.Select(graph, item.ContractID);
using (PXTransactionScope ts = new PXTransactionScope())
{
if (contract.IsTemplate != true)
{
ContractMaintExt contractMaintExt = CreateInstance<ContractMaintExt>();
contractMaintExt.Contracts.Current = contract;
if (contract.IsActive == true &&
contract.IsPendingUpdate != true &&
contract.Status != Contract.status.PendingActivation)
{
CTBillEngine engine = CreateInstance<CTBillEngine>();
engine.Upgrade(contract.ContractID);
engine.Clear();
contractMaintExt.Contracts.Current = PXSelect<Contract, Where<Contract.contractID, Equal<Required<Contract.contractID>>>>.Select(engine, item.ContractID);
item = PXSelect<ContractDetail,
Where<ContractDetail.contractID, Equal<Required<ContractDetail.contractID>>,
And<ContractDetail.lineNbr, Equal<Required<ContractDetail.lineNbr>>>>>.Select(engine, item.ContractID, item.LineNbr);
}
contractMaintExt.ContractDetails.Cache.SetDefaultExt<ContractDetail.basePriceOption>(item);
contractMaintExt.ContractDetails.Cache.SetDefaultExt<ContractDetail.basePrice>(item);
contractMaintExt.ContractDetails.Cache.SetDefaultExt<ContractDetail.renewalPriceOption>(item);
contractMaintExt.ContractDetails.Cache.SetDefaultExt<ContractDetail.renewalPrice>(item);
contractMaintExt.ContractDetails.Cache.SetDefaultExt<ContractDetail.fixedRecurringPriceOption>(item);
contractMaintExt.ContractDetails.Cache.SetDefaultExt<ContractDetail.fixedRecurringPrice>(item);
contractMaintExt.ContractDetails.Cache.SetDefaultExt<ContractDetail.usagePriceOption>(item);
contractMaintExt.ContractDetails.Cache.SetDefaultExt<ContractDetail.usagePrice>(item);
contractMaintExt.ContractDetails.Update(item);
contractMaintExt.Actions.PressSave();
}
else
{
TemplateMaint templateMaint = CreateInstance<TemplateMaint>();
templateMaint.Templates.Current = PXSelect<ContractTemplate, Where<ContractTemplate.contractID, Equal<Required<ContractTemplate.contractID>>>>.Select(graph, item.ContractID);
templateMaint.ContractDetails.Cache.SetDefaultExt<ContractDetail.basePriceOption>(item);
templateMaint.ContractDetails.Cache.SetDefaultExt<ContractDetail.basePrice>(item);
templateMaint.ContractDetails.Cache.SetDefaultExt<ContractDetail.renewalPriceOption>(item);
templateMaint.ContractDetails.Cache.SetDefaultExt<ContractDetail.renewalPrice>(item);
templateMaint.ContractDetails.Cache.SetDefaultExt<ContractDetail.fixedRecurringPriceOption>(item);
templateMaint.ContractDetails.Cache.SetDefaultExt<ContractDetail.fixedRecurringPrice>(item);
templateMaint.ContractDetails.Cache.SetDefaultExt<ContractDetail.usagePriceOption>(item);
templateMaint.ContractDetails.Cache.SetDefaultExt<ContractDetail.usagePrice>(item);
templateMaint.ContractDetails.Update(item);
templateMaint.Actions.PressSave();
}
ts.Complete();
}
}
这里我需要自定义这个条件:
if (contract.IsActive == true &&
contract.IsPendingUpdate != true &&
contract.Status != Contract.status.PendingActivation)
我试图用我自己的自定义静态方法覆盖构造函数,我会重写所有代码,但改变这样的条件,但它不起作用:
public override void Initialize()
{
var processDelegate = (PXProcessingBase<ContractDetail>.ProcessListDelegate)Base.Items.GetProcessDelegate();
Base.Items.SetProcessDelegate<ContractMaint>(UpdatePricesProc);
}
#region Event Handlers
public static void UpdatePricesProc(ContractMaint graph, ContractDetail item)
{
Contract contract = PXSelect<Contract, Where<Contract.contractID, Equal<Required<Contract.contractID>>>>.Select(graph, item.ContractID);
}
需要帮助来解决这个问题。感谢。