输入客户后,我试图在“交易”网格中添加一行,但只有在用户接受时才显示-确认对话框。
我已将逻辑简化为非常简单的SOLine插入。
使用此代码,结果成功:
protected virtual void SOOrder_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
{
if (e.Row == null)
{
return;
}
SOOrder record = (SOOrder)e.Row;
if (!sender.ObjectsEqual<SOOrder.customerID>(e.Row, e.OldRow)
&& record.CustomerID != null)
{
SOLine sOLineNewRow = new SOLine();
sOLineNewRow = this.Base.Transactions.Insert(sOLineNewRow);
SOLineExt sOLineExtRow = PXCache<SOLine>.GetExtension<SOLineExt>(sOLineNewRow);
sOLineNewRow.InventoryID = 311;
this.Base.Transactions.Update(sOLineNewRow);
sOLineNewRow.OrderQty = (decimal)7;
this.Base.Transactions.Update(sOLineNewRow);
sOLineNewRow.CuryUnitPrice = (decimal)8;
this.Base.Transactions.Update(sOLineNewRow);
}
}
但是,当我在对话框中包含Ask()方法时,则不会执行逻辑。调试之后,我注意到if运算符中的逻辑甚至没有被访问。
protected virtual void SOOrder_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
{
if (e.Row == null)
{
return;
}
SOOrder record = (SOOrder)e.Row;
if (!sender.ObjectsEqual<SOOrder.customerID>(e.Row, e.OldRow)
&& record.CustomerID != null)
{
if (this.Base.Document.Ask("Confirmation",
"The selected customer will have the default line. Do you want to insert it?",
MessageButtons.YesNo,
MessageIcon.Question) == WebDialogResult.Yes)
{
SOLine sOLineNewRow = new SOLine();
sOLineNewRow = this.Base.Transactions.Insert(sOLineNewRow);
SOLineExt sOLineExtRow = PXCache<SOLine>.GetExtension<SOLineExt>(sOLineNewRow);
sOLineNewRow.InventoryID = 311;
this.Base.Transactions.Update(sOLineNewRow);
sOLineNewRow.OrderQty = (decimal)7;
this.Base.Transactions.Update(sOLineNewRow);
sOLineNewRow.CuryUnitPrice = (decimal)8;
this.Base.Transactions.Update(sOLineNewRow);
}
}
}
有人知道为什么会这样吗?
更新的问题
我在一个动作中复制了逻辑,结果在那成功了:
public PXAction<SOOrder> ChangeAmount;
[PXUIField(DisplayName = "Action Test", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXButton(CommitChanges = true)]
public virtual void changeAmount()
{
PXTrace.WriteInformation("BeforeAskAction");
if (this.Base.Document.Ask("Confirmation",
"The selected customer will have the default line. Do you want to insert it?",
MessageButtons.YesNo,
MessageIcon.Question) == WebDialogResult.Yes)
{
PXTrace.WriteInformation("AfterAskAction");
SOLine sOLineNewRow = new SOLine();
sOLineNewRow = this.Base.Transactions.Insert(sOLineNewRow);
sOLineNewRow.InventoryID = 311;
this.Base.Transactions.Update(sOLineNewRow);
sOLineNewRow.OrderQty = (decimal)7;
this.Base.Transactions.Update(sOLineNewRow);
sOLineNewRow.CuryUnitPrice = (decimal)8;
this.Base.Transactions.Update(sOLineNewRow);
}
}
记录了“ BeforeAskAction”和“ AfterAskAction”跟踪。
在我使用事件处理程序的原始方案中,仅输入了“之前”跟踪。
我测试了以下数据成员: -文件 -CurrentDocument -交易 -我用SOLine DAC创建的虚拟DM。 在所有这些情况下,结果在操作中都是成功的,但在事件处理程序中是失败的。
更新2
最初,我在SOOrder_CustomerID_FieldUpdated中具有逻辑。 在这种情况下,将插入记录,但是由于CuryUnitPrice没有分配代码中指示的金额,所以我无法继续使用它。它分配了商品的默认价格。
我将本文用作参考(Sales Price Updating Every Other Time),但结果仍显示默认金额。 当使用RowUpdated事件时-并且未实现Ask()方法-我的CuryUnitPrice数量已分配