我可以通过编程方式关闭智能面板吗?

时间:2019-03-07 19:00:42

标签: acumatica

我想在单击按钮时运行验证,如果通过验证,该按钮也将关闭智能面板。有没有办法以编程方式关闭智能面板?

1 个答案:

答案 0 :(得分:0)

首先-在SmartPanel上,您需要添加一个按钮并将“对话框结果”属性设置为“确定”值。

  

px:PXButton runat =“服务器” ID =“ OkButton”文本=“ Ok” DialogResult =“确定”

第二个-您可以使用下面的代码(它是用stackOverflow编辑器编写的,但是您可能了解其思想)

public partial class ARInvoiceEntrySnrExt : PXGraphExtension<ARInvoiceEntry>
{
    public PXAction<ARInvoice> paySmartPanelAction
    [PXUIField(DisplayName = "Payment details", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
    public virtual IEnumerable PaySmartPanelAction(PXAdapter adapter)
    {
        WebDialogResult result = this.SmartPanelDataView.AskExt();
        if (result == WebDialogResult.OK)
            {
                var isValid = this.ValidateSmartPanelFields() //validation method everithing you may need
                if (isValid == false)
                {
                    throw new PXArgumentException(CstAPMessages.InvalidDetails, (Exception)null);
                }
        }
    }

    public virtual bool ValidateSmartPanelFields()
    {
        bool isValid = true;
        foreach (DataViewDetail detail in this.SmartPanelDataView.Select())
        {
            if (detail.FieldName <= 0)
            {
                cache.RaiseExceptionHandling<DataViewDetail.fieldName>(detail, detail.FieldName, new PXSetPropertyException(CstAPMessages.AmountPaidMustBeGreater));
                isValid = false;
            }
        }
        return isValid;
    }
}