【问题标题】:How to include a dialog for file upload如何包含文件上传对话框
【发布时间】:2016-11-02 01:06:31
【问题描述】:

我已经获得了一些 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;
        }
    }
}

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    您应该在您的 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" />
    

    【讨论】:

    • 非常感谢 Ruslan - 太完美了。这是丢失的部分。
    • 3 年后,这个答案仍然是合法的。
    猜你喜欢
    • 1970-01-01
    • 2011-02-23
    • 2013-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-20
    • 1970-01-01
    • 2023-03-07
    相关资源
    最近更新 更多