我在 Acumatica 2020R2 中有一个维护表单,它在表单和两个包含网格的选项卡项之间具有主从关系。我有表单自动编号的 ID,详细记录将此 ID 与 PXParentAttribute 一起使用。表单自动编号并使用正确的 ID 保存到数据库中,但详细记录使用初始占位符< NEW >而不是自动编号保存到数据库中。
以下是表单使用的 DAC 字段:
#region VendorRebateID
[PXDBString(15, IsKey = true, IsUnicode = true, InputMask = ">CCCCCCCCCCCCCCC")]
[PXDefault(PersistingCheck = PXPersistingCheck.NullOrBlank)]
[PXUIField(DisplayName = "Vendor Rebate Code", Visibility = PXUIVisibility.SelectorVisible)]
[AutoNumber(typeof(APVendorRebateSetup.numberingID), typeof(AccessInfo.businessDate))]
[PXSelector(typeof(Search<APVendorRebate.vendorRebateID>))]
public virtual string VendorRebateID { get; set; }
public abstract class vendorRebateID : PX.Data.BQL.BqlString.Field<vendorRebateID> { }
#endregion
#region Description
[PXDBString(256, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Description")]
public virtual string Description { get; set; }
public abstract class description : PX.Data.BQL.BqlString.Field<description> { }
#endregion
#region VendorID
[Vendor]
[PXDefault]
[PXParent(typeof(Select<Vendor, Where<Vendor.bAccountID, Equal<Current<APVendorPrice.vendorID>>>>))]
public virtual int? VendorID { get; set; }
public abstract class vendorID : PX.Data.BQL.BqlInt.Field<vendorID> { }
#endregion
#region CuryID
[PXDBString(5)]
[PXDefault(typeof(Search<PX.Objects.GL.Company.baseCuryID>))]
[PXSelector(typeof(Currency.curyID), CacheGlobal = true)]
[PXUIField(DisplayName = "Currency", Required = false, Visible = false, Visibility = PXUIVisibility.Visible)]
public virtual string CuryID { get; set; }
public abstract class curyID : PX.Data.BQL.BqlString.Field<curyID> { }
#endregion
#region EffectiveDate
[PXDefault(typeof(AccessInfo.businessDate), PersistingCheck = PXPersistingCheck.Nothing)]
[PXDBDate()]
[PXUIField(DisplayName = "Effective Date", Visibility = PXUIVisibility.Visible)]
public virtual DateTime? EffectiveDate { get; set; }
public abstract class effectiveDate : PX.Data.BQL.BqlDateTime.Field<effectiveDate> { }
#endregion
#region ExpirationDate
[PXDBDate()]
[PXUIField(DisplayName = "Expiration Date", Visibility = PXUIVisibility.Visible)]
public virtual DateTime? ExpirationDate { get; set; }
public abstract class expirationDate : PX.Data.BQL.BqlDateTime.Field<expirationDate> { }
#endregion
以下是其中一个网格使用的 DAC 字段:
#region VendorRebateID
[PXDBString(15, IsKey = true, IsUnicode = true, InputMask = "")]
[PXDefault(typeof(APVendorRebate.vendorRebateID))]
[PXParent(typeof(SelectFrom<APVendorRebate>.
Where<APVendorRebate.vendorRebateID.IsEqual<APVendorRebateCustomer.vendorRebateID.FromCurrent>>))]
public virtual string VendorRebateID { get; set; }
public abstract class vendorRebateID : PX.Data.BQL.BqlString.Field<vendorRebateID> { }
#endregion
#region CustomerID
[PX.Objects.AR.Customer(DescriptionField = typeof(PX.Objects.AR.Customer.acctName), IsKey = true)]
[PXUIField(DisplayName = "Customer")]
public virtual int? CustomerID { get; set; }
public abstract class customerID : PX.Data.BQL.BqlInt.Field<customerID> { }
#endregion
以下是其他网格使用的 DAC 字段:
#region VendorRebateID
[PXDBString(15, IsKey = true, IsUnicode = true, InputMask = "")]
[PXDefault(typeof(APVendorRebate.vendorRebateID))]
[PXParent(typeof(SelectFrom<APVendorRebate>.
Where<APVendorRebate.vendorRebateID.IsEqual<APVendorRebateInventoryItem.vendorRebateID.FromCurrent>>))]
public virtual string VendorRebateID { get; set; }
public abstract class vendorRebateID : PX.Data.BQL.BqlString.Field<vendorRebateID> { }
#endregion
#region InventoryID
[APCrossItem(BAccountField = typeof(APVendorRebate.vendorID), IsKey = true, WarningOnNonUniqueSubstitution = true)]
[PXParent(typeof(Select<InventoryItem, Where<InventoryItem.inventoryID, Equal<Current<APVendorPrice.inventoryID>>>>))]
public virtual int? InventoryID { get; set; }
public abstract class inventoryID : PX.Data.BQL.BqlInt.Field<inventoryID> { }
#endregion
#region AlternateID
[PXUIField(DisplayName = "Alternate ID")]
[PXDBString(50, IsUnicode = true, InputMask = "")]
public virtual string AlternateID { get; set; }
public abstract class alternateID : PX.Data.BQL.BqlString.Field<alternateID> { }
#endregion
#region UOM
[PXDefault(typeof(Search<InventoryItem.purchaseUnit, Where<InventoryItem.inventoryID, Equal<Current<APVendorPrice.inventoryID>>>>))]
[INUnit(typeof(APVendorPrice.inventoryID))]
[PXFormula(typeof(Selector<APVendorPrice.inventoryID, InventoryItem.purchaseUnit>))]
public virtual string UOM { get; set; }
public abstract class uOM : PX.Data.BQL.BqlString.Field<uOM> { }
#endregion
#region "Rebate Selling Price"
[PXDBPriceCost]
[PXUIField(DisplayName = "Selling Price", Visibility = PXUIVisibility.Visible)]
public virtual decimal? SellingPrice { get; set; }
public abstract class sellingPrice : PX.Data.BQL.BqlDecimal.Field<sellingPrice> { }
#endregion
#region RebatePrice
[PXDBPriceCost]
[PXDefault(TypeCode.Decimal, "0.0")]
[PXUIField(DisplayName = "Rebate Price", Visibility = PXUIVisibility.Visible)]
public virtual decimal? RebatePrice { get; set; }
public abstract class rebatePrice : PX.Data.BQL.BqlDecimal.Field<rebatePrice> { }
#endregion
#region VendorPrice
[PXPriceCost]
[PXUIField(DisplayName = "Vendor Price", Enabled = false)]
[PXDependsOnFields(typeof(APVendorRebate.vendorID), typeof(APVendorRebateInventoryItem.inventoryID), typeof(APVendorRebate.effectiveDate), typeof(APVendorRebate.expirationDate))]
[LatestVendorPrice]
public virtual decimal? VendorPrice { get; set; }
public abstract class vendorPrice : PX.Data.BQL.BqlDecimal.Field<vendorPrice> { }
#endregion
#region BreakQty
[PXDefault(TypeCode.Decimal, "0.0")]
[PXDBQuantity(MinValue = 0)]
[PXUIField(DisplayName = "Break Qty", Visibility = PXUIVisibility.Visible)]
public virtual decimal? BreakQty { get; set; }
public abstract class breakQty : PX.Data.BQL.BqlDecimal.Field<breakQty> { }
#endregion
#region SiteID
[NullableSite]
public virtual int? SiteID { get; set; }
public abstract class siteID : PX.Data.BQL.BqlDecimal.Field<siteID> { }
#endregion
这是 ASPX 代码:
<%@ Page Language="C#" MasterPageFile="~/MasterPages/FormView.master" AutoEventWireup="true" ValidateRequest="false" CodeFile="AP209900.aspx.cs" Inherits="Page_AP209900" Title="Untitled Page" %>
<%@ MasterType VirtualPath="~/MasterPages/FormView.master" %>
<asp:Content ID="cont1" ContentPlaceHolderID="phDS" Runat="Server">
<px:PXDataSource Height="" ID="ds" runat="server" Visible="True" Width="100%"
TypeName="APVendorRebates.APVendorRebateMaint"
PrimaryView="Rebates"
>
<CallbackCommands>
</CallbackCommands>
</px:PXDataSource>
</asp:Content>
<asp:Content ID="cont2" ContentPlaceHolderID="phF" Runat="Server">
<px:PXFormView AllowCollapse="false" Height="" ID="form" runat="server" DataSourceID="ds" DataMember="Rebates" Width="100%" AllowAutoHide="false">
<Template>
<px:PXLayoutRule runat="server" ID="PXLayoutRule1" StartRow="True" ></px:PXLayoutRule>
<px:PXLayoutRule ControlSize="XM" StartGroup="False" SuppressLabel="False" LabelsWidth="SM" runat="server" ID="CstPXLayoutRule1" StartColumn="True" ></px:PXLayoutRule>
<px:PXSelector CommitChanges="True" runat="server" ID="CstPXSelector6" DataField="VendorRebateID" >
<GridProperties>
<Layout BorderMode="NotSet" CellPadding="0" CellSpacing="0" ></Layout></GridProperties></px:PXSelector>
<px:PXSegmentMask CommitChanges="True" runat="server" ID="CstPXSegmentMask4" DataField="VendorID" ></px:PXSegmentMask>
<px:PXLayoutRule runat="server" ID="CstLayoutRule21" ColumnSpan="2" ></px:PXLayoutRule>
<px:PXTextEdit runat="server" ID="CstPXTextEdit10" DataField="Description" ></px:PXTextEdit>
<px:PXLayoutRule StartRow="False" ControlSize="SM" StartGroup="False" SuppressLabel="False" LabelsWidth="SM" runat="server" ID="CstPXLayoutRule2" StartColumn="True" ></px:PXLayoutRule>
<px:PXDateTimeEdit CommitChanges="True" runat="server" ID="CstPXDateTimeEdit7" DataField="EffectiveDate" ></px:PXDateTimeEdit>
<px:PXDateTimeEdit CommitChanges="True" runat="server" ID="CstPXDateTimeEdit8" DataField="ExpirationDate" ></px:PXDateTimeEdit></Template>
<AutoSize Container="Parent" Enabled="False" MinHeight="140" ></AutoSize>
</px:PXFormView>
<px:PXTab Height="" runat="server" ID="CstPXTab14">
<Items>
<px:PXTabItem RepaintOnDemand="False" BindingContext="form" Text="Inventory Items" >
<Template>
<px:PXGrid SyncPosition="False" Width="100%" runat="server" ID="CstPXGrid15" SkinID="Details">
<Levels>
<px:PXGridLevel DataMember="InventoryItems" >
<Columns>
<px:PXGridColumn CommitChanges="True" DataField="InventoryID" Width="70" ></px:PXGridColumn>
<px:PXGridColumn DataField="InventoryID_description" Width="280" ></px:PXGridColumn>
<px:PXGridColumn DataField="AlternateID" Width="180" ></px:PXGridColumn>
<px:PXGridColumn DataField="UOM" Width="72" ></px:PXGridColumn>
<px:PXGridColumn DataField="SellingPrice" Width="100" ></px:PXGridColumn>
<px:PXGridColumn DataField="RebatePrice" Width="100" ></px:PXGridColumn>
<px:PXGridColumn DataField="VendorPrice" Width="100" ></px:PXGridColumn>
<px:PXGridColumn DataField="BreakQty" Width="100" ></px:PXGridColumn>
<px:PXGridColumn DataField="SiteID" Width="140" ></px:PXGridColumn></Columns>
<RowTemplate></RowTemplate></px:PXGridLevel></Levels>
<AutoSize Enabled="True" ></AutoSize>
<Mode InitNewRow="True" ></Mode></px:PXGrid></Template></px:PXTabItem>
<px:PXTabItem RepaintOnDemand="False" BindingContext="form" Text="Customers" >
<Template>
<px:PXGrid SyncPosition="False" runat="server" ID="CstPXGrid16" Width="100%" SkinID="Details">
<Levels>
<px:PXGridLevel DataMember="Customers" >
<Columns>
<px:PXGridColumn DataField="CustomerID" Width="140" CommitChanges="True" ></px:PXGridColumn>
<px:PXGridColumn DataField="CustomerID_description" Width="280" ></px:PXGridColumn></Columns>
<RowTemplate></RowTemplate></px:PXGridLevel></Levels>
<AutoSize Enabled="True" ></AutoSize>
<Mode InitNewRow="True" ></Mode></px:PXGrid></Template></px:PXTabItem></Items>
<AutoSize Enabled="True" />
<AutoSize MinHeight="180" />
<AutoSize Container="Window" /></px:PXTab></asp:Content>
以下是记录插入数据库的方式:
我对 Acumatica 还很陌生,我根据 T210 培训课程中的说明编写了这段代码。我非常仔细地遵循了这些步骤,但我不确定为什么会发生这种情况。任何帮助,将不胜感激。谢谢。
