如何包含文件上传对话框

How to include a dialog for file upload

我得到了一些 C# 图形扩展代码来上传 excel 文件,以便导入到采购收据屏幕上的分配弹出屏幕中。没有包括的是似乎用作对话框的 PXSmartPanel。关于如何根据给定代码中的预期设置/配置此智能面板的任何帮助,我们将不胜感激。有问题的行是这样的:

if (this.NewRevisionPanel.AskExt() == WebDialogResult.OK)

代码如下:

 public class POReceiptEntryGraphExtension : PXGraphExtension<PO.POReceiptEntry>
{

    public PXSelect<PO.POReceipt> NewRevisionPanel;

    public PXAction<PO.POReceipt> ImportAllocations;
    [PXUIField(DisplayName = "Import Allocations", MapEnableRights = PXCacheRights.Update,
                             MapViewRights = PXCacheRights.Update, Enabled = true)]
    [PXButton()]
    public virtual void importAllocations()
    {
        try
        {
            if (Base.transactions.Current != null)
            {
                if (Base.splits.Select().Count == 0)
                {
                    if (this.NewRevisionPanel.AskExt() == WebDialogResult.OK)
                    {
                        const string PanelSessionKey = "ImportStatementProtoFile";
                        PX.SM.FileInfo info = PX.Common.PXContext.SessionTyped<PXSessionStatePXData>().FileInfo[PanelSessionKey] as PX.SM.FileInfo;
                        System.Web.HttpContext.Current.Session.Remove(PanelSessionKey);

                        if (info != null)
                        {
                            byte[] filedata = info.BinData;
                            using (NVExcelReader reader = new NVExcelReader())
                            {
                                Dictionary<UInt32, string[]> data = reader.loadWorksheet(filedata);
                                foreach (string[] textArray in data.Values)
                                {
                                    Base.splits.Insert(new PO.POReceiptLineSplit()
                                    {
                                        InventoryID = Base.transactions.Current.InventoryID,
                                        LocationID = Base.transactions.Current.LocationID,
                                        LotSerialNbr = textArray[2],
                                        Qty = Decimal.Parse(textArray[3])
                                    });
                                }
                            }
                        }
                    }
                }
            }
            Base.Actions["LSPOReceiptLine_binLotSerial"].Press();
        }
        catch (FileFormatException fileFormat)
        {
            throw new PXException(String.Format("Incorrect file format. File must be of type .xlsx", fileFormat.Message));
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
}

您应该在您的 aspx 文件中声明 PXUploadDialog 元素:

<px:PXUploadDialog ID="ImportPanel" runat="server" Key="NewRevisionPanel" Height="120px" Style="position: static" Width="560px"
                Caption="Import XML File (*.xml)" AutoSaveFile="false" RenderCheckIn="false" SessionKey="ImportStatementProtoFile" />