【问题标题】:Specified Cast is not Valid in new Master Screen of Acumatica ERP System指定的演员在 Acumatica ERP 系统的新主屏幕中无效
【发布时间】:2019-08-16 20:19:23
【问题描述】:

我已经在 Acumatica 中创建了新的附加主屏幕 (ListView)。 以下代码为页面源代码:

<%@ Page Language="C#" MasterPageFile="~/MasterPages/ListView.master" AutoEventWireup="true" ValidateRequest="false" CodeFile="CS213000.aspx.cs" Inherits="Page__213000" Title="Untitled Page" %>
<%@ MasterType VirtualPath="~/MasterPages/ListView.master" %>
<asp:Content ID="cont1" ContentPlaceHolderID="phDS" runat="Server">
<px:PXDataSource ID="ds" runat="server" Visible="True" PrimaryView="RoomMaster" SuspendUnloading="False" TypeName="SGLCustomizeProject.RoomMaint" >
</px:PXDataSource>
</asp:Content>

<asp:Content ID="cont2" ContentPlaceHolderID="phL" runat="Server">
<px:PXGrid ID="grid" runat="server" Height="400px" Width="100%" Style="z-index: 100"
    AllowPaging="True" AllowSearch="True" AdjustPageSize="Auto" DataSourceID="ds" SkinID="Inquire" TabIndex="900" 
    AllowAdd="True" TemporaryFilterCaption="Filter Applied">
<Levels>
<px:PXGridLevel DataMember="RoomMaster">
<Columns>
<px:PXGridColumn DataField="BranchID" Width="120px">
                </px:PXGridColumn>
                <px:PXGridColumn DataField="BuildingID">
                </px:PXGridColumn>
                <px:PXGridColumn DataField="RoomCD" Width="200px">
                </px:PXGridColumn>
                <px:PXGridColumn DataField="RoomDescription" Width="200px">
                </px:PXGridColumn>
                <px:PXGridColumn DataField="Status">
                </px:PXGridColumn>
</Columns>
        </px:PXGridLevel>
    </Levels>
<AutoSize Container="Window" Enabled="True" MinHeight="200" />
</px:PXGrid>

以下代码是PXGraph的源代码:

using System;
using System.Collections;
using System.Collections.Generic;
using PX.SM;
using PX.Data;
namespace SGLCustomizeProject
{
    public class RoomMaint : PXGraph<RoomMaint>
    {
        public PXCancel<RoomMaster> Cancel;
        public PXSave<RoomMaster> Save;
        public PXInsert<RoomMaster> Insert;
        public PXSelect<RoomMaster> RoomMaster;
    }
}

以下代码是DAC的源代码:

namespace SGLCustomizeProject
{
using System;
using PX.Data;
using PX.Objects.GL;
using PX.Objects.AR;
using PX.Objects.CR;
using PX.Objects.FA;

[System.SerializableAttribute()]
public class RoomMaster : PX.Data.IBqlTable
{
    #region BranchID
    public abstract class branchID : PX.Data.IBqlField
    {
    }
    protected Int32? _BranchID;
    [PXDBInt(IsKey = true)]
    [PXDefault()]
    //[PXUIField(DisplayName = "BranchID")]
    [Branch()]
    public virtual Int32? BranchID
    {
        get
        {
            return this._BranchID;
        }
        set
        {
            this._BranchID = value;
        }
    }
    #endregion

    #region BuildingID
    public abstract class buildingID : PX.Data.IBqlField
    {
    }
    protected Int32? _BuildingID;
    [PXDBInt()]
    [PXDefault()]
    [PXSelector(typeof(Search<Building.buildingID, 
                        Where<Building.branchID, 
                         Equal<Current<FALocationHistory.locationID>>>>),
        SubstituteKey = typeof(Building.buildingCD), DescriptionField = typeof(Building.description))]
    [PXUIField(DisplayName = "Building")]
    public virtual Int32? BuildingID
    {
        get
        {
            return this._BuildingID;
        }
        set
        {
            this._BuildingID = value;
        }
    }
    #endregion

    #region RoomCD
    public abstract class roomCD : PX.Data.IBqlField
    {
    }
    protected string _RoomCD;
    [PXDBString(50, IsUnicode = true, IsKey = true)]
    [PXDefault()]
    [PXUIField(DisplayName = "Kode Area")]
    public virtual string RoomCD
    {
        get
        {
            return this._RoomCD;
        }
        set
        {
            this._RoomCD = value;
        }
    }
    #endregion

    #region RoomID
    public abstract class roomID : PX.Data.IBqlField
    {
    }
    protected int? _RoomID;
    [PXDBIdentity()]
    [PXUIField(Enabled = false)]
    public virtual int? RoomID
    {
        get
        {
            return this._RoomID;
        }
        set
        {
            this._RoomID = value;
        }
    }
    #endregion

    #region RoomDescription
    public abstract class roomDescription : PX.Data.IBqlField
    {
    }
    protected string _RoomDescription;
    [PXDBString(75, IsUnicode = true)]
    [PXUIField(DisplayName = "Deskripsi Area")]
    public virtual string RoomDescription
    {
        get
        {
            return this._RoomDescription;
        }
        set
        {
            this._RoomDescription = value;
        }
    }
    #endregion

    #region Status
    public abstract class status : PX.Data.IBqlField
    {
    }
    protected string _Status;
    [PXDBString(2, IsFixed = true)]
    [PXDefault()]
    [PXUIField(DisplayName = "Status")]
    [PXStringList(new string[]
        {
            "01",
            "02"
        },

        new string[]
        {
            "Active",
            "Inactive"
        })]
    public virtual string Status
    {
        get
        {
            return this._Status;
        }
        set
        {
            this._Status = value;
        }
    }
    #endregion

    #region tstamp
    public abstract class Tstamp : PX.Data.IBqlField
    {
    }
    protected byte[] _tstamp;
    [PXDBTimestamp()]
    public virtual byte[] tstamp
    {
        get
        {
            return this._tstamp;
        }
        set
        {
            this._tstamp = value;
        }
    }
    #endregion

    #region CreatedByID
    public abstract class createdByID : PX.Data.IBqlField
    {
    }
    protected Guid? _CreatedByID;
    //[PXDBField()]
    //[PXDefault()]
    //[PXUIField(DisplayName = "CreatedByID")]
    [PXDBCreatedByID]
    public virtual Guid? CreatedByID
    {
        get
        {
            return this._CreatedByID;
        }
        set
        {
            this._CreatedByID = value;
        }
    }
    #endregion

    #region CreatedByScreenID
    public abstract class createdByScreenID : PX.Data.IBqlField
    {
    }
    protected string _CreatedByScreenID;
    //[PXDBString(8, IsFixed = true)]
    //[PXDefault("")]
    //[PXUIField(DisplayName = "CreatedByScreenID")]
    [PXDBCreatedByScreenID]
    public virtual string CreatedByScreenID
    {
        get
        {
            return this._CreatedByScreenID;
        }
        set
        {
            this._CreatedByScreenID = value;
        }
    }
    #endregion

    #region CreatedDateTime
    public abstract class createdDateTime : PX.Data.IBqlField
    {
    }
    protected DateTime? _CreatedDateTime;
    //[PXDBDate()]
    //[PXDefault(TypeCode.DateTime, "01/01/1900")]
    //[PXUIField(DisplayName = "CreatedDateTime")]
    [PXDBCreatedDateTime]
    public virtual DateTime? CreatedDateTime
    {
        get
        {
            return this._CreatedDateTime;
        }
        set
        {
            this._CreatedDateTime = value;
        }
    }
    #endregion

    #region LastModifiedByID
    public abstract class lastModifiedByID : PX.Data.IBqlField
    {
    }
    protected Guid? _LastModifiedByID;
    //[PXDBField()]
    //[PXDefault()]
    //[PXUIField(DisplayName = "LastModifiedByID")]
    [PXDBLastModifiedByID]
    public virtual Guid? LastModifiedByID
    {
        get
        {
            return this._LastModifiedByID;
        }
        set
        {
            this._LastModifiedByID = value;
        }
    }
    #endregion

    #region LastModifiedDateTime
    public abstract class lastModifiedDateTime : PX.Data.IBqlField
    {
    }
    protected DateTime? _LastModifiedDateTime;
    //[PXDBDate()]
    //[PXDefault(TypeCode.DateTime, "01/01/1900")]
    //[PXUIField(DisplayName = "LastModifiedDateTime")]
    [PXDBLastModifiedDateTime]
    public virtual DateTime? LastModifiedDateTime
    {
        get
        {
            return this._LastModifiedDateTime;
        }
        set
        {
            this._LastModifiedDateTime = value;
        }
    }
    #endregion
}
}

当我第一次尝试添加新记录时没有关系,但是当我尝试添加另一条记录或打开屏幕时,我收到以下错误消息:

有谁知道如何解决这个案子? 谢谢

【问题讨论】:

  • 您应该包括跟踪窗口中的跟踪详细信息。可能有助于指出正在运行的事件可以帮助回答问题。可能是此字段上的 ID/CD 设置。我认为您可能需要在建筑字段的 PXGrid 标记内的 aspx 中添加 RowTemplate。例如:

标签: c# acumatica


【解决方案1】:

BuildingID 字段上的 PXSelector 显示了一个 WHERE 子句,将结果限制为 Current FALocationHistory.locationID,但我在 RoomMaint 图的上下文中看不到 FALocationHistory。您是否打算根据这个新 RoomMaster 行中的 BranchID 选择来限制列表?如果为 true,那么您还需要 BranchID 列上的 CommitChanges=true 以及网格级别的 RowTemplate 部分的 BuildingID px:PXSelector 控件上的 AutoRefresh=true,例如:

<RowTemplate>

<px:PXSelector ID="edBuildingID" runat="server" DataField="BuildingID" 
                    DataSourceID="ds" AutoRefresh="True">

</RowTemplate>

在这种情况下,您可能需要在标记的 Grid 标记上添加 SyncPosition=true。还可以尝试将 IsKey=true 仅放置在 RoomID 身份字段上,而不是 BranchID/RoomCD。

【讨论】:

    猜你喜欢
    • 2021-07-21
    • 1970-01-01
    • 2018-02-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多