Acumatica-在销售订单行中添加图像 [英] Acumatica - Adding Image in Sales Order Line

查看:70
本文介绍了Acumatica-在销售订单行中添加图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当选择InventoryID时,我正在为文档明细的销售订单行制作缩略图。但是,每当我在行中选择InventoryID时,图像就不会填充到网格中。这是我到目前为止的内容:



DAC扩展:

 名称空间PX.Objects.IN 
{
公共类InventoryItemExt:PXCacheExtension< InventoryItem>
{
#region ThumbnailURL
公共抽象类thumbnailURL:IBqlField
{}
[PXString]
公共字符串ThumbnailURL {get;组; }
#endregion
}
}

代码扩展:

 使用PX.Data; 
使用PX.Objects.SO;
使用系统;
使用PX.Objects.IN;
使用PX.Web.UI;

命名空间组合
{
公共类SOLineExt:PXCacheExtension< SOLine>
{
#region ThumbnailURL
公共抽象类thumbnailURL:IBqlField
{}
[PXString]
公共字符串ThumbnailURL {get;组; }
#endregion
}
公共类SOOrderEntryExt:PXGraphExtension< SOOrderEntry>
{
public void SOLine_RowSelecting(PXCache sender,PXRowSelectingEventArgs e,PXRowSelecting baseMethod)
{
baseMethod.Invoke(sender,e);
if(e.Row!= null)
{
var row = e.Row as SOLine;
if(row.InventoryID!= null)
{

InventoryItem currentLineItem = PXSelect< InventoryItem,where< InventoryItem.inventoryID,Equal< Required< InventoryItem.inventoryID>>>> ;> .Select(this.Base,row.InventoryID);
if(行!= null&!amp;!string.IsNullOrEmpty(currentLineItem.ImageUrl))
{
if(currentLineItem.StkItem == true)
{
InventoryItemMaintventoryItemMaint = PXGraph.CreateInstance< InventoryItemMaint>();
Guid []文件= PXNoteAttribute.GetFileNotes(inventoryItemMaint.Item.Cache,currentLineItem);
var fm = PXGraph.CreateInstance< PX.SM.UploadFileMaintenance>();
foreach(文件中的指导文件ID)
{
PX.SM.FileInfo fi = fm.GetFileWithNoData(fileID);
if(fi.FullName == currentLineItem.ImageUrl || fi.Name == currentLineItem.ImageUrl)
{
row.GetExtension< SOLineExt>()。ThumbnailURL = ControlHelper.GetAttachedFileUrl(null ,fileID.ToString());
休息时间;
}
}
}
其他
{
NonStockItemMaintventoryItemMaint = PXGraph.CreateInstance< NonStockItemMaint>();
Guid []文件= PXNoteAttribute.GetFileNotes(inventoryItemMaint.Item.Cache,currentLineItem);
var fm = PXGraph.CreateInstance< PX.SM.UploadFileMaintenance>();
foreach(文件中的指导文件ID)
{
PX.SM.FileInfo fi = fm.GetFileWithNoData(fileID);
if(fi.FullName == currentLineItem.ImageUrl || fi.Name == currentLineItem.ImageUrl)
{
row.GetExtension< SOLineExt>()。ThumbnailURL = ControlHelper.GetAttachedFileUrl(null ,fileID.ToString());
休息时间;
}
}
}
}
}
}
}
}
}

ASPX代码:



网格中的代码:

 < px:PXGridColumn DataField = ThumbnailURL Width = 300px Type = Icon /> 

InventoryID段上的代码掩码:

 < px:PXSegmentMask CommitChanges = True ID = edInventoryID runat = server DataField = InventoryID AllowEdit = True> 
< GridProperties>
< Columns>
< px:PXGridColumn Type = Icon DataField = ThumbnailURL Width = 300px AutoGenerateOption = Add />
< / Columns>
< / GridProperties>
< / px:PXSegmentMask>

我确实找到了有关将图像添加到InventoryID选择器的帖子,并且它具有不同的添加方法到该网格的图像,这里是否也一样?这是另一篇文章:



更新1: 已修复
我已经重做了上面的所有代码以回答1,并在上面的帖子中添加了Ruslan的回答中的代码。屏幕快照仍返回相同的位置。



更新2:
我似乎一切正常。我现在仅在某些时候收到此错误,我不确定是什么原因。忽略CustomerID错误是因为他们的信用余额已过期。

解决方案

添加对 <$ c的引用$ c> PX.Web.UI.dll 从Acumatica的Bin文件夹或 使用PX.Web.UI; (如果您正在自定义代码编辑器中编写代码)。
ControlHelper 是一个静态帮助器类,用于使Acumatica的Web控件的使用更加轻松。



更新1



在答案中,您已经注意到,在库存项目选择器的查找中完成了图像的添加,并在网格中添加了SOLineExt。您的情况是将其添加到SOLine。这是执行此操作的代码:

 使用PX.Data; 
使用PX.Objects.SO;
使用系统;
使用PX.Objects.IN;
使用PX.Web.UI;

名称空间ClassLibrary1
{

公共类SOLineExt:PXCacheExtension< SOLine>
{
#region ThumbnailURL
公共抽象类thumbnailURL:IBqlField
{}
[PXString]
公共字符串ThumbnailURL {get;组; }
#endregion
}
公共类SOOrderEntryExt:PXGraphExtension< SOOrderEntry>
{
public void SOLine_RowSelecting(PXCache sender,PXRowSelectingEventArgs e,PXRowSelecting baseMethod)
{
baseMethod?.Invoke(sender,e);
if(e.Row!= null)
{
var row = e.Row as SOLine;
if(row.InventoryID!= null)
{

InventoryItem currentLineItem = PXSelect< InventoryItem,where< InventoryItem.inventoryID,Equal< Required< InventoryItem.inventoryID>>>> ;> .Select(this.Base,row.InventoryID);
if(行!= null&!amp;!string.IsNullOrEmpty(currentLineItem.ImageUrl))
{
if(currentLineItem.StkItem == true)
{
InventoryItemMaintventoryItemMaint = PXGraph.CreateInstance< InventoryItemMaint>();
Guid []文件= PXNoteAttribute.GetFileNotes(inventoryItemMaint.Item.Cache,currentLineItem);
var fm = PXGraph.CreateInstance< PX.SM.UploadFileMaintenance>();
foreach(文件中的指导文件ID)
{
PX.SM.FileInfo fi = fm.GetFileWithNoData(fileID);
if(fi.FullName == currentLineItem.ImageUrl || fi.Name == currentLineItem.ImageUrl)
{
row.GetExtension< SOLineExt>()。ThumbnailURL = ControlHelper.GetAttachedFileUrl(null ,fileID.ToString());
休息时间;
}
}
}
其他
{
NonStockItemMaintventoryItemMaint = PXGraph.CreateInstance< NonStockItemMaint>();
Guid []文件= PXNoteAttribute.GetFileNotes(inventoryItemMaint.Item.Cache,currentLineItem);
var fm = PXGraph.CreateInstance< PX.SM.UploadFileMaintenance>();
foreach(文件中的指导文件ID)
{
PX.SM.FileInfo fi = fm.GetFileWithNoData(fileID);
if(fi.FullName == currentLineItem.ImageUrl || fi.Name == currentLineItem.ImageUrl)
{
row.GetExtension< SOLineExt>()。ThumbnailURL = ControlHelper.GetAttachedFileUrl(null ,fileID.ToString());
休息时间;
}
}
}
}
}
}
}
}
}

如您所见,我已将 ThumbnailURL 直接添加到 SOLine
现在还需要根据物料类型创建 InventoryItemMaint NonStockItemMaint 的实例



因此,您应该得到以下内容:




I am working on making a thumbnail image on the Sales Order lines for the Document Details when the InventoryID is selected. The image however does not populate to the grid whenever I select the InventoryID in the line. Here is what I have so far:

DAC Extension:

namespace PX.Objects.IN
{
  public class InventoryItemExt : PXCacheExtension<InventoryItem>
  {
      #region ThumbnailURL
      public abstract class thumbnailURL : IBqlField
    { }
    [PXString]
    public string ThumbnailURL { get; set; }
      #endregion
  }
}

Code Extension:

using PX.Data;
using PX.Objects.SO;
using System;
using PX.Objects.IN;
using PX.Web.UI;

namespace Combined
{
  public class SOLineExt : PXCacheExtension<SOLine>
    {
        #region ThumbnailURL
        public abstract class thumbnailURL : IBqlField
        { }
        [PXString]
        public string ThumbnailURL { get; set; }
        #endregion
    }
    public class SOOrderEntryExt: PXGraphExtension<SOOrderEntry>
    {
        public void SOLine_RowSelecting(PXCache sender, PXRowSelectingEventArgs e,PXRowSelecting baseMethod)
        {
            baseMethod.Invoke(sender, e);
            if(e.Row!=null)
            {
                var row = e.Row as SOLine;
                if (row.InventoryID != null)
                {

                    InventoryItem currentLineItem = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.Select(this.Base, row.InventoryID);
                    if (row != null && !string.IsNullOrEmpty(currentLineItem.ImageUrl))
                    {
                        if(currentLineItem.StkItem==true)
                        {
                            InventoryItemMaint inventoryItemMaint = PXGraph.CreateInstance<InventoryItemMaint>();
                            Guid[] files = PXNoteAttribute.GetFileNotes(inventoryItemMaint.Item.Cache, currentLineItem);
                            var fm = PXGraph.CreateInstance<PX.SM.UploadFileMaintenance>();
                            foreach (Guid fileID in files)
                            {
                                PX.SM.FileInfo fi = fm.GetFileWithNoData(fileID);
                                if (fi.FullName == currentLineItem.ImageUrl || fi.Name == currentLineItem.ImageUrl)
                                {
                                    row.GetExtension<SOLineExt>().ThumbnailURL = ControlHelper.GetAttachedFileUrl(null, fileID.ToString());
                                    break;
                                }
                            }
                        }
                        else
                        {
                            NonStockItemMaint inventoryItemMaint = PXGraph.CreateInstance<NonStockItemMaint>();
                            Guid[] files = PXNoteAttribute.GetFileNotes(inventoryItemMaint.Item.Cache, currentLineItem);
                            var fm = PXGraph.CreateInstance<PX.SM.UploadFileMaintenance>();
                            foreach (Guid fileID in files)
                            {
                                PX.SM.FileInfo fi = fm.GetFileWithNoData(fileID);
                                if (fi.FullName == currentLineItem.ImageUrl || fi.Name == currentLineItem.ImageUrl)
                                {
                                    row.GetExtension<SOLineExt>().ThumbnailURL = ControlHelper.GetAttachedFileUrl(null, fileID.ToString());
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

ASPX Code:

Code in the Grid:

<px:PXGridColumn DataField="ThumbnailURL" Width="300px" Type="Icon" />

Code on the InventoryID SegmentMask:

<px:PXSegmentMask CommitChanges="True" ID="edInventoryID" runat="server" DataField="InventoryID" AllowEdit="True" >
  <GridProperties>
    <Columns>
      <px:PXGridColumn Type="Icon" DataField="ThumbnailURL" Width="300px" AutoGenerateOption="Add" />
      </Columns>
    </GridProperties>
</px:PXSegmentMask>

I did find a post about adding an image to the InventoryID Selector and it has a different method of adding images to that grid, does the same apply here? Here is the other post: How to show images inside selector lookup?

I have changed my code above to match the other post but now I am receiving this error:

\App_RuntimeCode\SOOrderEntry.cs(61): error CS0103: The name 'ControlHelper' does not exist in the current context
\App_RuntimeCode\SOOrderEntry.cs(61): error CS0103: The name 'ControlHelper' does not exist in the current context

Adding code from the first answer below but now the grid column is showing up blank:

Update 1: FIXED I have redone all the code above to answer 1 along with adding the code from the post of Ruslan's answer in the post above. The screenshot is still coming back the same.

Update 2: I have got everything working or so it seemed. I am now receiving this error only sometimes and I'm not sure what the cause is. Ignore the CustomerID error that is because their credit balance is overdue.

解决方案

Add reference to PX.Web.UI.dll from Acumatica's Bin folder or using PX.Web.UI; if you are writing code in the customization's Code Editor. ControlHelper is a static helper class for making easier work with Acumatica's Web controls .

UPDATE 1

In the answer you have noted addition of the Image is done in the lookup of the Inventory Item Selector and add to the Grid the field of the SOLineExt. In your case you are adding it to the SOLine. Here is code which is doing that:

using PX.Data;
using PX.Objects.SO;
using System;
using PX.Objects.IN;
using PX.Web.UI;

namespace ClassLibrary1
{

    public class SOLineExt : PXCacheExtension<SOLine>
    {
        #region ThumbnailURL
        public abstract class thumbnailURL : IBqlField
        { }
        [PXString]
        public string ThumbnailURL { get; set; }
        #endregion
    }
    public class SOOrderEntryExt: PXGraphExtension<SOOrderEntry>
    {
        public void SOLine_RowSelecting(PXCache sender, PXRowSelectingEventArgs e,PXRowSelecting baseMethod)
        {
            baseMethod?.Invoke(sender, e);
            if(e.Row!=null)
            {
                var row = e.Row as SOLine;
                if (row.InventoryID != null)
                {

                    InventoryItem currentLineItem = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.Select(this.Base, row.InventoryID);
                    if (row != null && !string.IsNullOrEmpty(currentLineItem.ImageUrl))
                    {
                        if(currentLineItem.StkItem==true)
                        {
                            InventoryItemMaint inventoryItemMaint = PXGraph.CreateInstance<InventoryItemMaint>();
                            Guid[] files = PXNoteAttribute.GetFileNotes(inventoryItemMaint.Item.Cache, currentLineItem);
                            var fm = PXGraph.CreateInstance<PX.SM.UploadFileMaintenance>();
                            foreach (Guid fileID in files)
                            {
                                PX.SM.FileInfo fi = fm.GetFileWithNoData(fileID);
                                if (fi.FullName == currentLineItem.ImageUrl || fi.Name == currentLineItem.ImageUrl)
                                {
                                    row.GetExtension<SOLineExt>().ThumbnailURL = ControlHelper.GetAttachedFileUrl(null, fileID.ToString());
                                    break;
                                }
                            }
                        }
                        else
                        {
                            NonStockItemMaint inventoryItemMaint = PXGraph.CreateInstance<NonStockItemMaint>();
                            Guid[] files = PXNoteAttribute.GetFileNotes(inventoryItemMaint.Item.Cache, currentLineItem);
                            var fm = PXGraph.CreateInstance<PX.SM.UploadFileMaintenance>();
                            foreach (Guid fileID in files)
                            {
                                PX.SM.FileInfo fi = fm.GetFileWithNoData(fileID);
                                if (fi.FullName == currentLineItem.ImageUrl || fi.Name == currentLineItem.ImageUrl)
                                {
                                    row.GetExtension<SOLineExt>().ThumbnailURL = ControlHelper.GetAttachedFileUrl(null, fileID.ToString());
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

As you can see I have added the ThumbnailURL directly to SOLine. Also now it's needed to create instance of the InventoryItemMaint or NonStockItemMaint depending on the Item Type(Stock/NonStock).

As a result you should get this:

这篇关于Acumatica-在销售订单行中添加图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆