如何在两个事件处理程序之间传递值?

How to pass values between two event handlers?

在我的第一个事件处理程序中,我将从 SalesTable 表单中收集我需要的所有字段。在此表单中,我需要从 SalesLine 获取这些字段。下面是我的代码:

[FormEventHandler(formStr(SalesTable), FormEventType::PostRun)]
public static void SalesTable_OnPostRun(xFormRun sender, FormEventArgs e)
{
      SalesLine   salesLine;
      SalesTable  salesTable = sender.dataSource(formDataSourceStr(SalesTable,salesTable)).cursor();

      select ItemId, SalesId, ShippingDateConfirmed from salesLine
         where salesLine.SalesId == SalesTable.SalesId;
}

之后,下一个事件处理程序是在另一个表单中找到的按钮的 OnClick 事件..

[FormControlEventHandler(formControlStr(SalesAvailableDlvDates, TransferToConfirmedButton), FormControlEventType::Clicked)]
public static void TransferToConfirmedButton_OnClicked(FormControl sender, FormControlEventArgs e)
{
    //some code here
}

在这个不同形式的事件处理程序中,即 SalesAvailableDlvDates,这里我需要来自我的 SalesLine table 的字段 这是我从 SalesTable 表格中获得的。因为在这里,这是需要触发的按钮,它将值放入新创建的 table.

我是否可以将值从 SalesTable 事件处理程序 传递到 SalesAvailableDlvDates 事件处理程序

因为在 SalesAvailableDlvDates 中,我无法获取 SalesLine 数据。是否可以将值从一个事件处理程序传递到另一个?

SalesAvailableDlvDates表单事件处理程序中您可以获得表单调用者。然后如果 salesCalcAvailableDlvDatesSalesCalcAvailableDlvDates_SalesTableSalesCalcAvailableDlvDates_SalesLine 你可以从相应的 parm 方法中获取你需要的数据。

[FormControlEventHandler(formControlStr(SalesAvailableDlvDates, TransferToConfirmedButton), FormControlEventType::Clicked)]
public static void TransferToConfirmedButton_OnClicked(FormControl sender, FormControlEventArgs e)
{
    SalesTable                              salesTable;
    SalesLine                               salesLine;
    SalesCalcAvailableDlvDates              salesCalcAvailableDlvDates;
    SalesCalcAvailableDlvDates_SalesLine    salesCalcAvailableDlvDates_SalesLine;
    SalesCalcAvailableDlvDates_SalesTable   salesCalcAvailableDlvDates_SalesTable;
    FormRun                                 formRun;
    ;

    formRun = sender.formRun() as FormRun;
    salesCalcAvailableDlvDates = formRun.args().caller();

    switch (classIdGet(salesCalcAvailableDlvDates))
    {
        case classNum(SalesCalcAvailableDlvDates_SalesLine):
            salesCalcAvailableDlvDates_SalesLine = salesCalcAvailableDlvDates as SalesCalcAvailableDlvDates_SalesLine;
            salesLine = salesCalcAvailableDlvDates_SalesLine.parmSalesLine();
            salesTable = salesLine.salesTable();
            break;

        case classNum(SalesCalcAvailableDlvDates_SalesTable):
            salesCalcAvailableDlvDates_SalesTable = salesCalcAvailableDlvDates as salesCalcAvailableDlvDates_SalesTable;
            salesTable = salesCalcAvailableDlvDates_SalesTable.parmSalesTable();
            break;

        default:
            break;
    }
}