Acumatica 如何包含用于文件上载的对话框
我得到了一些C#图扩展代码,可以上传excel文件导入到采购收据屏幕上的分配弹出屏幕。没有包括的是似乎用作对话框的PXSmartPanel。对于如何设置/配置此智能面板以实现给定代码中的目的,我们将不胜感激。问题是: if(this.NewRevisionPanel.AskExt()==WebDialogResult.OK) 代码如下:Acumatica 如何包含用于文件上载的对话框,acumatica,Acumatica,我得到了一些C#图扩展代码,可以上传excel文件导入到采购收据屏幕上的分配弹出屏幕。没有包括的是似乎用作对话框的PXSmartPanel。对于如何设置/配置此智能面板以实现给定代码中的目的,我们将不胜感激。问题是: if(this.NewRevisionPanel.AskExt()==WebDialogResult.OK) 代码如下: public class POReceiptEntryGraphExtension : PXGraphExtension<PO.POReceiptEnt
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;
}
}
}
公共类porecipentrygraphextension:PXGraphExtension
{
公共PX选择新建修订面板;
公共行动进口;
[PXUIField(DisplayName=“导入分配”,MapEnableRights=PXCacheRights.Update,
MapViewRights=PXCacheRights.Update,Enabled=true)]
[PXButton()]
公共虚拟无效导入配置()
{
尝试
{
if(Base.transactions.Current!=null)
{
if(Base.splits.Select().Count==0)
{
if(this.NewRevisionPanel.AskExt()==WebDialogResult.OK)
{
const string PanelSessionKey=“ImportStatementProtoFile”;
PX.SM.FileInfo=PX.Common.PXContext.SessionTyped().FileInfo[PanelSessionKey]作为PX.SM.FileInfo;
System.Web.HttpContext.Current.Session.Remove(PanelSessionKey);
如果(信息!=null)
{
字节[]filedata=info.BinData;
使用(NVExcelReader=new NVExcelReader())
{
字典数据=reader.loadWorksheet(filedata);
foreach(data.Values中的字符串[]textArray)
{
Base.splits.Insert(新采购订单POReceiptLineSplit()
{
InventoryID=Base.transactions.Current.InventoryID,
LocationID=Base.transactions.Current.LocationID,
LotSerialNbr=textArray[2],
Qty=Decimal.Parse(textArray[3])
});
}
}
}
}
}
}
Base.Actions[“LSPOReceiptLine_binLotSerial”]。按();
}
捕获(文件格式异常文件格式)
{
抛出新的PXException(String.Format(“不正确的文件格式。文件类型必须为.xlsx”,fileFormat.Message));
}
捕获(例外情况除外)
{
掷骰子;
}
}
}
您应该在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年后,这个答案仍然是正确的。