问题
I've been given some C# graph extension code to upload an excel file for import into the Allocation popup screen on the Purchase Receipts screen. What wasn't included is the PXSmartPanel that seems to be used as a dialog. Any help would be appreciated as to how to set up / configure this Smart Panel for what was intended in the code given. the line in question is this:
if (this.NewRevisionPanel.AskExt() == WebDialogResult.OK)
The code is below:
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;
}
}
}
回答1:
You should declare PXUploadDialog element in your aspx file:
<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" />
来源:https://stackoverflow.com/questions/40364461/how-to-include-a-dialog-for-file-upload