如何为现成的销售订单实体添加属性支持?

时间:2018-08-15 22:16:43

标签: acumatica acumatica-kb

现成的import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.usermodel.*; public class LC_negotiation { public static void LC_negotiation(){ try { FileInputStream file = new FileInputStream(new File("D:\\home.xls")); HSSFWorkbook workbook = new HSSFWorkbook(file); HSSFSheet sheet = workbook.getSheetAt(0); Cell cell = null; cell = sheet.getRow(1).getCell(2); cell.setCellValue("Name"); cell = sheet.getRow(2).getCell(2); cell.setCellValue("Address"); file.close(); FileOutputStream outFile = new FileOutputStream(new File("D:\\home.xls")); workbook.write(outFile); outFile.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public static void main(String[] args) { LC_negotiation lc_one = new LC_negotiation(); } } 不具有属性支持。如何在Acumatica中将属性支持扩展到销售订单实体?

1 个答案:

答案 0 :(得分:0)

从根本上讲,您的实体主DAC必须具有GUID列(NoteID)来引用CSAnswers表,并且必须具有标识实体类的字段。

我们将使用Order Type来定义属性列表,以收集特定于订单类型的特定信息。

SOOrderTypeMaint图形创建图形扩展,并声明数据视图以定义特定订单类型的属性列表。我们将使用开箱即用的CSAttributeGroupList<TEntityClass, TEntity>

public class SOOrderTypeMaintPXExt : PXGraphExtension<SOOrderTypeMaint>
{
    [PXViewName(PX.Objects.CR.Messages.Attributes)]
    public CSAttributeGroupList<SOOrderType, SOOrder> Mapping;
}

SOOrderEntry图形创建图形扩展,并声明特定于当前订单类型的属性的数据视图。

public class SOOrderEntryPXExt : PXGraphExtension<SOOrderEntry>
{
    public CRAttributeList<SOOrder> Answers;
}

SOOrder DAC创建DAC扩展,并声明用CRAttributesField属性修饰的用户定义字段,并指定ClassID字段-在我们的示例中为OrderType

public class SOOrderPXExt : PXCacheExtension<SOOrder>
{
    #region UsrAttributes

    public abstract class usrAttributes : IBqlField { }

    [CRAttributesField(typeof(SOOrder.orderType))]
    public virtual string[] UsrAttributes { get; set; }

    #endregion
}

如下所示使用定制引擎修改订单类型页面(SO201000

<px:PXTabItem Text = "Attributes" >
  <Template>
    <px:PXGrid runat = "server" BorderWidth="0px" Height="150px" SkinID="Details" Width="100%" ID="AttributesGrid" 
                MatrixMode="True" DataSourceID="ds">
        <AutoSize Enabled = "True" Container="Window" MinHeight="150" />
        <Levels>
            <px:PXGridLevel DataMember = "Mapping" >
                <RowTemplate>
                    <px:PXSelector runat = "server" DataField="AttributeID" FilterByAllFields="True" AllowEdit="True" 
                                    CommitChanges="True" ID="edAttributeID" /></RowTemplate>
                <Columns>
                    <px:PXGridColumn DataField = "AttributeID" Width="81px" AutoCallBack="True" LinkCommand="ShowDetails" />
                    <px:PXGridColumn DataField = "Description" Width="351px" AllowNull="False" />
                    <px:PXGridColumn DataField = "SortOrder" TextAlign="Right" Width="81px" />
                    <px:PXGridColumn DataField = "Required" Type="CheckBox" TextAlign="Center" AllowNull="False" />
                    <px:PXGridColumn DataField = "CSAttribute__IsInternal" Type="CheckBox" TextAlign="Center" AllowNull="True" />
                    <px:PXGridColumn DataField = "ControlType" Type="DropDownList" Width="81px" AllowNull="False" />
                    <px:PXGridColumn DataField = "DefaultValue" RenderEditorText="False" Width="100px" AllowNull="True" />
                </Columns>
            </px:PXGridLevel>
        </Levels>
    </px:PXGrid>
  </Template>
</px:PXTabItem>

如下所示使用定制引擎修改销售订单页面(SO301000

<px:PXTabItem Text="Attributes">
  <Template>
    <px:PXGrid runat="server" ID="PXGridAnswers" Height="200px" SkinID="Inquire" 
                Width="100%" MatrixMode="True" DataSourceID="ds">
        <AutoSize Enabled="True" MinHeight="200" />
        <ActionBar>
            <Actions>
                <Search Enabled="False" />
            </Actions>
        </ActionBar>
        <Mode AllowAddNew="False" AllowDelete="False" AllowColMoving="False" />
        <Levels>
            <px:PXGridLevel DataMember="Answers">                        
                <Columns>
                    <px:PXGridColumn TextAlign="Left" DataField="AttributeID" TextField="AttributeID_description" 
                                        Width="250px" AllowShowHide="False" />
                    <px:PXGridColumn Type="CheckBox" TextAlign="Center" DataField="isRequired" Width="80px" />
                    <px:PXGridColumn DataField="Value" Width="300px" AllowSort="False" AllowShowHide="False" />
                </Columns>
            </px:PXGridLevel>
        </Levels>
    </px:PXGrid>
  </Template>
</px:PXTabItem>

Download deployment package