2017-06-20 13 views
0

私はこれに苦しんでいます。それはとても簡単で、おそらく何か愚かなことがありませんが、私は助けが必要です。ARの印刷文にParentAccountIdと名前を追加してください。

AR503500のPrint Statement画面の下に、詳細グリッドに別のフィールドを追加しようとしています。このフィールドは、顧客のparentAccountIdです。 DetailsResultには既にCustomerIDが含まれています。

私はAR.ARStatementPrint.DetailsResult DACを拡張し、次の

 public abstract class parentAccountTest2 : IBqlField 
    { 
    } 

    #region Parent Account test 2 
    [PXString] 
    [PXUIField(DisplayName = "Parent Account test 2")] 
    [PXDBScalar(typeof(Search<Customer.parentBAccountID, 
           Where<Customer.bAccountID, Equal<DetailsResult.customerID>>>))] 
    public string ParentAccountTest2 { get; set; } 
    #endregion 

を追加しました。しかし、私は、任意の値がグリッド上に表示するために取得カントています。

グラフには、DetailsResultのコピーメソッドを呼び出すメソッドdetails()があります。これを何とかオーバーライドして、そのようにparentAccountIdを設定する必要がありますか?ここで

は、「詳細」メソッドが呼び出されたグラフの詳細方法

protected virtual IEnumerable details() 
{ 
    ARSetup setup = ARSetup.Current; 

    PrintParameters header = Filter.Current; 
    List<DetailsResult> result = new List<DetailsResult>(); 
    if (header == null) 
     yield break; 

    GL.Company company = PXSelect<GL.Company>.Select(this); 
    foreach (PXResult<ARStatement, Customer> it in PXSelectJoin<ARStatement, 
      InnerJoin<Customer, On<Customer.bAccountID, Equal<ARStatement.statementCustomerID>>>, 
      Where<ARStatement.statementDate, Equal<Required<ARStatement.statementDate>>, 
       And<ARStatement.statementCycleId, Equal<Required<ARStatement.statementCycleId>>>>, 
      OrderBy<Asc<ARStatement.statementCustomerID, Asc<ARStatement.curyID>>>> 
      .Select(this, header.StatementDate, header.StatementCycleId)) 
    { 
     DetailsResult res = new DetailsResult(); 
     ARStatement st = it; 
     Customer cust = it; 
     res.Copy(st, cust); 

     if (setup.ConsolidatedStatement != true && st.BranchID != header.BranchID) 
       continue; 

     if (Filter.Current.Action == 0 && 
      header.ShowAll != true && 
      (st.DontPrint == true || st.Printed == true)) 
       continue; 

     if ((Filter.Current.Action == 1 || Filter.Current.Action == 2) && 
      header.ShowAll != true && 
      (st.DontEmail == true || st.Emailed == true)) 
       continue; 

     if (cust.PrintCuryStatements == true) 
     { 
      if (Filter.Current.CuryStatements != true) 
       continue; 

      DetailsResult last = result.Count > 0 ? result[result.Count - 1] : null; 
      if (last?.CustomerID == res.CustomerID && last?.CuryID == res.CuryID) 
      { 
       last.Append(res); 
      } 
      else 
      { 
       result.Add(res); 
      } 
     } 
     else 
     { 
      if (Filter.Current.CuryStatements == true) 
       continue; 

      res.ResetToBaseCury(company.BaseCuryID); 

      DetailsResult last = result.Count > 0 ? result[result.Count - 1] : null; 
      if (last?.CustomerID == res.CustomerID) 
      { 
       last.Append(res); 
      } 
      else 
      { 
       result.Add(res); 
      } 
     } 
    } 

    foreach (var item in result) 
    { 
     var located = Details.Cache.Locate(item); 
     if (located != null) 
     { 
      yield return located; 
     } 
     else 
     { 
      Details.Cache.SetStatus(item, PXEntryStatus.Held); 
      yield return item; 
     } 
    } 

    Details.Cache.IsDirty = false; 
} 

され、PX.Objects.AR.ARStatementPrint.DetailsResultクラス上のコピー方法

public virtual void Copy(ARStatement aSrc, Customer cust) 
{ 
    this.CustomerID = cust.BAccountID; 
    this.UseCurrency = cust.PrintCuryStatements; 
    this.StatementBalance = aSrc.EndBalance ?? decimal.Zero; 
    this.AgeBalance00 = aSrc.AgeBalance00 ?? decimal.Zero; 
    this.CuryID = aSrc.CuryID; 
    this.CuryStatementBalance = aSrc.CuryEndBalance ?? decimal.Zero; 
    this.CuryAgeBalance00 = aSrc.CuryAgeBalance00 ?? decimal.Zero; 
    this.DontEmail = aSrc.DontEmail; 
    this.DontPrint = aSrc.DontPrint; 
    this.Emailed = aSrc.Emailed; 
    this.Printed = aSrc.Printed; 
      this.BranchID = aSrc.BranchID; 
} 
+0

どのように相互に関連している2つの抽象クラスがあります。プロパティ 'ParentAccountTest2'はどのクラスに属していますか? 'Details'と' Copy'メソッドのコードを共有できますか? 'DetailsResult'クラスはどこですか? –

+0

ParentAccountTest2は私のDetailsResult Extensionに追加したフィールドです。それらのメソッドでポストを更新しました.DetailsResultはPX.Objects.AR.AR.StatementPrintにあります – GrayFoxNZ

答えて

1

ですDataViewデリゲート。その定義では、DataViewのレコードリストを返します。単一のBQLクエリには適していない、アンバウンドDACやカスタムロジックによく使用されます。 'details' DataViewデリゲートでは、新しいレコードが空白として作成され、値がコピーされます。

DACレコードが空白で作成されたため、PXDBScalarが実行された時点でCustomerIDがNULLであると思われます。

DACの代わりにDataViewデリゲートで値を計算する場合、FieldSelectingイベントハンドラを使用して、デリゲートが実行された後でカスタムフィールドの値を計算できます。

お知らせDAC拡張がBQLクエリが含まれていません:

public class ARStatementPrint_Extension : PXGraphExtension<ARStatementPrint> 
{ 
    #region Event Handlers 
    protected virtual void DetailsResult_ParentAccount_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) 
    { 
     ARStatementPrint.DetailsResult detailsResult = e.Row as ARStatementPrint.DetailsResult; 

     if (detailsResult != null) 
     { 
      BAccount2 bAccount = PXSelectJoin<BAccount2, 
           InnerJoin<Customer, On<Customer.bAccountID, Equal<Required<ARStatementPrint.DetailsResult.customerID>>>>, 
           Where<BAccount2.bAccountID, Equal<Customer.parentBAccountID>>>.Select(Base, detailsResult.CustomerID); 

      if (bAccount != null) 
      { 
       e.ReturnValue = bAccount.AcctName; 
      } 
     } 
    } 
    #endregion 
} 
:得意先は、DataViewのデリゲートにコピーされた後

public class DetailsResultExt: PXCacheExtension<ARStatementPrint.DetailsResult> 
{ 
    #region Parent Account   
   public abstract class parentAccount : IBqlField { } 

    [PXString(60, IsUnicode = true)] 
    [PXUIField(DisplayName = "Parent Account")] 
    public virtual string ParentAccount { get; set; } 
    #endregion 
} 

クエリは、print文グラフ延長のFieldSelectingイベントハンドラ内で実行されます

プロジェクトエディタの画面にバインドされていないカスタムフィールドを追加します。 enter image description here

カスタムフィールドに親ビジネスアカウント名が表示されます: enter image description here

+0

詳細な回答ありがとうございます。治療をしました。 – GrayFoxNZ

関連する問題