2016-05-13 86 views
0

我試圖在銷售訂單中的機會中添加添加項目功能。我已經通過了SOOrderEntry中的代碼,並試圖複製相同的功能。在機會中添加項目功能

「添加項目」菜單爲智能面板提供了過濾器選項,但不會填充數據。我已將該設置與銷售訂單添加項目智能面板設置進行了比較,我沒有錯過任何內容。

我已經按照銷售訂單複製了表格結構和事件,並需要更改商機。

#region SiteStatus Lookup 
public PXFilter<OpportunitySiteStatusFilter> oppsitestatusfilter; 
[PXFilterable] 
[PXCopyPasteHiddenView] 
public OpportunityStatusLookup<OpportunitySiteStatusSelected, OpportunitySiteStatusFilter> opportunitysitestatus; 

public PXAction<CROpportunity> addOppBySite; 
[PXUIField(DisplayName = "Add Stock Item", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)] 
[PXLookupButton] 
public virtual IEnumerable AddOppBySite(PXAdapter adapter) 
{ 
    oppsitestatusfilter.Cache.Clear(); 
    if (opportunitysitestatus.AskExt() == WebDialogResult.OK) 
    { 
     return AddOppSelBySite(adapter); 
    } 
    oppsitestatusfilter.Cache.Clear(); 
    opportunitysitestatus.Cache.Clear(); 
    return adapter.Get(); 
} 

public PXAction<CROpportunity> addOppSelBySite; 
[PXUIField(DisplayName = "Add", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Visible = false)] 
[PXLookupButton] 
public virtual IEnumerable AddOppSelBySite(PXAdapter adapter) 
{ 
    foreach (OpportunitySiteStatusSelected line in opportunitysitestatus.Cache.Cached) 
    { 
     if (line.Selected == true && line.QtySelected > 0) 
     { 
      CROpportunityProducts newline = PXCache<CROpportunityProducts>.CreateCopy(Base.Products.Insert(new CROpportunityProducts())); 
      newline.SiteID = line.SiteID; 
      newline.InventoryID = line.InventoryID; 
      newline.SubItemID = line.SubItemID; 
      newline.UOM = line.SalesUnit; 
      //newline.AlternateID = line.AlternateID; 
      //newline = PXCache<SOLine>.CreateCopy(Transactions.Update(newline)); 
      //if (newline.RequireLocation != true || PXAccess.FeatureInstalled<FeaturesSet.warehouseLocation>()) 
      // newline.LocationID = null; 
      newline = PXCache<CROpportunityProducts>.CreateCopy(Base.Products.Update(newline)); 
      //newline.Qty = line.QtySelected; 
      cnt = 0; 
      Base.Products.Update(newline); 
     } 
    } 
    opportunitysitestatus.Cache.Clear(); 
    return adapter.Get(); 
} 
protected virtual void OpportunitySiteStatusFilter_RowInserted(PXCache cache, PXRowInsertedEventArgs e) 
{ 
    OpportunitySiteStatusFilter row = (OpportunitySiteStatusFilter)e.Row; 
    if (row != null && Base.Products.Current != null) 
     row.SiteID = Base.Products.Current.SiteID; 
} 
int cnt; 
public IEnumerable<PXDataRecord> ProviderSelect(BqlCommand command, int topCount, params PXDataValue[] pars) 
{ 
    cnt++; 
    return Base.ProviderSelect(command, topCount, pars); 
} 
#endregion 

enter image description here

問候, R. Muralidharan

+1

您確定在調試代碼時數據正在填充到您爲網格定義的數據庫的相應緩存中嗎? 如果是,這裏的問題將是網格的自動大小。使網格的autosize爲true,以便您可以看到裏面的數據。 – Hybridzz

+1

您可能希望將自定義SmartPanel aspx與SalesOrderEntry屏幕的開箱即用添加庫存項SmartPanel進行比較。正如@Hybridzz提到的,很可能你沒有設置AutoSize屬性。當網格分頁啓用時,您需要將AutoSize設置爲True。 如果這沒有幫助,那麼我們需要檢查DAC,Graph和ASPX的聲明。 – DChhapgar

+0

設置網格的自動調整屬性解決了問題。我已修復其他過濾問題,並且工作正常。謝謝您的幫助 –

回答

1

您可能需要比較您的自定義SmartPanel ASPX與外的框添加SalesOrderEntry屏幕的股票項目SmartPanel。正如@Hybridzz提到的,很可能你沒有設置AutoSize屬性。當網格分頁啓用時,您需要將AutoSize設置爲True。