Quintiq file version 2.0
#parent: Panel418/btn_Add_FM
Response OnClick (
  H_MaterialInfo selection
) id:Response_Panel418_btn_Add_FM_OnClick_975
{
  #keys: '[414724.0.145238844]'
  CanBindMultiple: false
  DefinitionID => /Panel418/Responsedef_Panel418_btn_Add_FM_OnClick
  Precondition:
  [*
    return not isnull( MacroPlan);
  *]
  QuillAction
  {
    Body:
    [*
      SelectItem :=  select( MacroPlan,H_MessagePassing,Obj,Obj.FKey()="FrmMaterial" and Obj.ItemKey()="ListSelect");
      CustomCode:="";
      CustomName:="";
      SValue:="";
      SValueJsonString:="";
      // 获取客户名称和客户ID
      if(txtSaveForecastData_FM.Text().Length()>0)
      {
         jForecast := JSON::Parse( txtSaveForecastData_FM.Text());
         CustomCode := jForecast.Get( "CustomCode").GetString();
         CustomName := jForecast.Get( "CustomName").GetString();
      }
      if(not isnull(selection))
      {
        SValueJsonString:= JSON::Object().Add( "SKU",selection.SKU())
                    .Add( "MaterialName",selection.MaterialName())
                    .Add( "MaterialType",selection.MaterialType())
                    .Add( "OrgCode",selection.OrgCode())
                    .Add( "Unit",selection.Unit())
                    .Add( "CustomCode",CustomCode)
                    .Add( "ParentSKU",lb_SUK_FM.Text())
                    .Add( "CustomName",CustomName).Build().AsString();
      }
      if( isnull( SelectItem))
      {
        MacroPlan.H_MessagePassing(relnew,FKey := "FrmMaterial",ItemKey := "ListSelect", Value:=SValue,ValueJsonString:=SValueJsonString);
      }
      else
      {
        SelectItem.Value(SValue);
        SelectItem.ValueJsonString( SValueJsonString);
      }
      Application.OpenForm( "FrmAuthorizeAndCountersign_Material","modal");
    *]
    GroupServerCalls: false
  }
}
