Acumatica - 详细记录不使用主记录的自动编号字段
Acumatica - Detail Record Not using Auto-Numbered Field of Master Record
我在 Acumatica 2020R2 中有一个维护表单,该表单与包含网格的两个选项卡项之间存在主从关系。我有表单自动编号的 ID,详细记录将此 ID 与 PXParentAttribute 一起使用。表单自动编号并使用正确的 ID 保存到数据库中,但详细记录使用初始占位符 <NEW>[=34= 保存到数据库中] 而不是自动编号。
以下是表单使用的 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 培训课程中的说明编写此代码的。我非常仔细地按照这些步骤操作,但我不确定为什么会这样。任何帮助,将不胜感激。谢谢。
在子 DAC 中,PXDefault 应该是 PXDBDefault。当我开始时,这对我来说是一个常见问题。 PXDBDefault 的不同之处在于它“用于从自动生成的键字段中分配一个值”。
这是使用 PXDBDefault 的子 DAC 字段的一个非常基本的示例。本例中的母table为XXDocument,子table为XXLine。关键字段是 myID.
#region MyID
[PXDBInt(IsKey = true)]
[PXDBDefault(typeof(XXDocument.myID))]
[PXParent(
typeof(Select<XXDocument,
Where<XXDocument.myID,
Equal<Current<XXLine.myID>>>>)
)]
[PXUIField(DisplayName = Messages.FldMyID)]
public virtual int? MyID { get; set; }
public abstract class myID : PX.Data.BQL.BqlInt.Field<myID> { }
#endregion
值得注意的是,我使用 ID 与 CD 字段集。 parent ID是数据库中的Identity字段,Autonumber字段是CD字段。我怀疑这也会导致您的问题,因此,我上面的示例可能不适合您尝试的情况。我发现将整数标识字段用于关键字段并将我的自动编号用作 CD(代码)字段非常重要,因为它作为数据结构更清晰,并且数据库更有效地使用 store/retrieve 整数而不是字符串.此外,您可以更改 CD 值而不影响 table 关系(类似于它在 InventoryItem 中的处理方式)。
父table的ID/CD字段如下所示:
#region MyID
[PXDBIdentity]
public virtual int? MyID { get; set; }
public abstract class myID : PX.Data.BQL.BqlInt.Field<myID> { }
#endregion
#region MyCD
[PXDBString(15, IsKey = true, IsUnicode = true, InputMask = "")]
[PXDefault]
[AutoNumber(typeof(XXSetup.myNumberingID), typeof(AccessInfo.businessDate))]
[PXSelector(
typeof(MyDocument.myCD),
typeof(MyDocument.myCD),
typeof(MyDocument.descr)
)]
[PXUIField(DisplayName = Messages.FldMyCD, Visibility = PXUIVisibility.SelectorVisible)]
public virtual string MyCD { get; set; }
public abstract class myCD : PX.Data.BQL.BqlString.Field<myCD> { }
#endregion
我在 Acumatica 2020R2 中有一个维护表单,该表单与包含网格的两个选项卡项之间存在主从关系。我有表单自动编号的 ID,详细记录将此 ID 与 PXParentAttribute 一起使用。表单自动编号并使用正确的 ID 保存到数据库中,但详细记录使用初始占位符 <NEW>[=34= 保存到数据库中] 而不是自动编号。
以下是表单使用的 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 培训课程中的说明编写此代码的。我非常仔细地按照这些步骤操作,但我不确定为什么会这样。任何帮助,将不胜感激。谢谢。
在子 DAC 中,PXDefault 应该是 PXDBDefault。当我开始时,这对我来说是一个常见问题。 PXDBDefault 的不同之处在于它“用于从自动生成的键字段中分配一个值”。
这是使用 PXDBDefault 的子 DAC 字段的一个非常基本的示例。本例中的母table为XXDocument,子table为XXLine。关键字段是 myID.
#region MyID
[PXDBInt(IsKey = true)]
[PXDBDefault(typeof(XXDocument.myID))]
[PXParent(
typeof(Select<XXDocument,
Where<XXDocument.myID,
Equal<Current<XXLine.myID>>>>)
)]
[PXUIField(DisplayName = Messages.FldMyID)]
public virtual int? MyID { get; set; }
public abstract class myID : PX.Data.BQL.BqlInt.Field<myID> { }
#endregion
值得注意的是,我使用 ID 与 CD 字段集。 parent ID是数据库中的Identity字段,Autonumber字段是CD字段。我怀疑这也会导致您的问题,因此,我上面的示例可能不适合您尝试的情况。我发现将整数标识字段用于关键字段并将我的自动编号用作 CD(代码)字段非常重要,因为它作为数据结构更清晰,并且数据库更有效地使用 store/retrieve 整数而不是字符串.此外,您可以更改 CD 值而不影响 table 关系(类似于它在 InventoryItem 中的处理方式)。
父table的ID/CD字段如下所示:
#region MyID
[PXDBIdentity]
public virtual int? MyID { get; set; }
public abstract class myID : PX.Data.BQL.BqlInt.Field<myID> { }
#endregion
#region MyCD
[PXDBString(15, IsKey = true, IsUnicode = true, InputMask = "")]
[PXDefault]
[AutoNumber(typeof(XXSetup.myNumberingID), typeof(AccessInfo.businessDate))]
[PXSelector(
typeof(MyDocument.myCD),
typeof(MyDocument.myCD),
typeof(MyDocument.descr)
)]
[PXUIField(DisplayName = Messages.FldMyCD, Visibility = PXUIVisibility.SelectorVisible)]
public virtual string MyCD { get; set; }
public abstract class myCD : PX.Data.BQL.BqlString.Field<myCD> { }
#endregion