记录图表中的视图计数

时间:2015-10-21 22:18:06

标签: acumatica

我有一个简单的主/细节维护屏幕图表。主数据以顶部形式显示,详细信息显示在底部的网格中。可以删除详细信息行。

我想写一些代码来删除最后一个详细记录时删除主记录。我还需要在删除每一行时进行其他处理,但我可以处理。我打算在RowDeleted处理程序中执行此操作。

我的问题是:我是否可以访问视图中活动行的计数而无需通过循环来计算它们?我无法从数据库中进行选择,因为它们尚未保存。我有一个下图的摘录。检测最后一个细节行已被删除的最简单方法是什么?

    public PXSelect<EDASN> ASN;

    public PXSelectJoin<EDASNShipment,
        LeftJoin<SOShipment, On<SOShipment.shipmentNbr, Equal<EDASNShipment.shipmentNbr>>,
        LeftJoin<SOOrderShipment, On<SOOrderShipment.shipmentNbr, Equal<EDASNShipment.shipmentNbr>>,
        LeftJoin<SOOrder, On<SOOrder.orderNbr, Equal<SOOrderShipment.orderNbr>>>>>,
        Where<EDASNShipment.aSNNbr, Equal<Current<EDASN.aSNNbr>>>> ASNShipment;

        protected virtual void EDASNShipment_RowDeleted(PXCache sender, PXRowDeletedEventArgs e)
    {
        EDASNShipment row = ASNShipment.Current;
        EDASN asn = this.ASN.Current;
        // need to determine if any shipments left on ASN
        // can I access a "count" of active rows from the ASNShipment view cache
    }

1 个答案:

答案 0 :(得分:0)

我已经解决了这个问题。我刚刚搜索了缓存,如果它返回null,则最后一批货已被删除。

    protected virtual void EDASNShipment_RowDeleted(PXCache sender, PXRowDeletedEventArgs e)
    {
        EDASNShipment row = ASNShipment.Current;
        EDASNShipment asnShipments = this.ASNShipment.Search<EDASNShipment.aSNNbr>(row.ASNNbr);
        // Remove ASN record if no more shipments
        if (asnShipments == null)
        {
            EDASN asn = this.ASN.Current;
            this.ASN.Delete(asn);
            this.Persist();
        }