1

在为网格中的对象添加有关创建价格的逻辑之后,它总是创建“多行”,它是空的。因此,如果需要创建两行,则将创建 3 行,其中一个添加将为空。

我在代码中缺少什么吗?

   [Control("CommandButton")]
    class AreaActionPaneNew
    {
        void clicked()
        {
            PMCParameters   contractParameters = PMCParameters::find();
            PMETmpRentalObjectArea  groupedAreaList; // Group by area_type and cost_type
            PMERentalObjectPrice    priceList;
            date workingDate = currWorkingDate.dateValue();
            ;
            super();

            // Get grouped area values. Values are summed up by area_type and ancost_type
            groupedAreaList = PMERentalObjectAreaCl::getRentalAreaPrCostType(pmeRentalobject.RentalObjectId, userSetting.validFrom(), userSetting.validTo() , workingDate);

            ttsbegin;
            while select groupedAreaList
            {
                select forupdate firstonly priceList
                    where priceList.RentalObjectId == pmeRentalObject.RentalObjectId &&
                          priceList.RentalCostType == groupedAreaList.RentalCostTypeId &&
                          priceList.AreaType == groupedAreaList.Areatype && priceList.ValidFrom == pmeRentalObject.ValidFrom;

                if (!priceList)
                    priceList.initValue();

                priceList.RentalObjectId = pmeRentalObject.RentalObjectId;
                priceList.RentalCostType = groupedAreaList.RentalCostTypeId;
                priceList.ValidFrom      = pmeRentalobject.ValidFrom;

                priceList.AreaType       = groupedAreaList.Areatype;


   priceList.Amount         = groupedAreaList.Price;
            priceList.Area           = groupedAreaList.AreaValue;
            priceList.Quantity       = groupedAreaList.RentalQty;

            if (!priceList)
                priceList.Period  = contractParameters.ReportPeriod;

            if (priceList)
                priceList.update();
            else
                priceList.insert();
        }
        ttscommit;

        pmeRentalObjectPrice_ds.research();
    }

}
4

1 回答 1

1

该代码看起来只是更新/插入而不创建空行。

从您的属性中,您正在使用一个Command Button请参阅此处),它可能有一个关联的命令,例如New,它有效地推动Ctrl+N了 ,并会解释为什么您有一个空行。

最简单的检查方法是创建一个常规Button并覆盖单击的方法,然后复制/粘贴您的代码并按下两个按钮,看看它们是否有不同的行为。

检查Command按钮上的属性,看看那里是否有东西。尝试注释掉super();通话。

您或许应该只考虑 aButtonMenu Item Button带有关联对象的 a。

于 2019-05-07T16:59:41.417 回答