混合手动\自动编号序列 [英] Mix Manual\Auto Numbering Sequences

查看:16
本文介绍了混合手动\自动编号序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编号序列设置 (CS201010) 中,有一个手动编号选项.

In Numbering Sequences settings (CS201010), there is an option for manual numbering.

但是,取决于文档类型.在某些情况下,参考编号可以留空.如果它是空白的,我希望自动编号启动.或者在保存文档之前调用 NextNumber() 函数.是否可以 ?我该怎么做?

However, depending on the document type. There are instances where the reference number can be left blank. If it's blank, I'd want the auto numbering to kick in. Or something like call the NextNumber() function before saving the document. Is it possible ? How do I do that ?

目前,如果我强制执行自动编号.例如,它不允许我在参考编号上输入任​​何内容.

At the moment, if I enforce the auto numbering. It doesn't allow me to type anything on the Reference number for example.

TIA

推荐答案

有两种方法:简单和稍微复杂一点.简单的将附加到 FieldDefaulting,并在该事件内部检查该字段是否为空,然后为其分配一些值.另一种更好地适应 Acumatica 风格的方法是实现您自己的 AutoNumbering 属性,然后将该 Autonumbering 属性应用于您的 DAC 类.注意您可以使用 PXCacheExtension 替换 Acumatica 自动编号属性

There are two ways: easy and little bit more complicated. Easy one will be attach to FieldDefaulting, and inside of that event check if that field is empty then assign some value into it. Another way which better feet to Acumatica style is to implement your own AutoNumbering attribute and then apply that Autonumbering attribute to your DAC class. N.B. you can substitute Acumatica autonumbering attribute with yours with PXCacheExtension

下面是通过 FieldDefaulting 实现自动编号来删除默认自动编号的代码示例:

below goes example of code with removing default autonumbering with implementing autonumbering via FieldDefaulting:

public class ARInvoiceEntryExt : PXGraphExtension<ARInvoiceEntry>
{
    [PXDBString(15, InputMask = ">CCCCCCCCCCCCCCC", IsKey = true, IsUnicode = true)]
    [PXDefault]
    [PXUIField(DisplayName = "Reference Nbr.", TabOrder = 1, Visibility = PXUIVisibility.SelectorVisible)]
    //[ARInvoiceType.RefNbr(typeof(Search2<ARRegisterAlias.refNbr, InnerJoinSingleTable<ARInvoice, On<ARInvoice.docType, Equal<ARRegisterAlias.docType>, And<ARInvoice.refNbr, Equal<ARRegisterAlias.refNbr>>>, InnerJoinSingleTable<Customer, On<ARRegisterAlias.customerID, Equal<Customer.bAccountID>>>>, Where<ARRegisterAlias.docType, Equal<Optional<ARInvoice.docType>>, And2<Where<ARRegisterAlias.origModule, Equal<BatchModule.moduleAR>, Or<ARRegisterAlias.released, Equal<True>>>, And<Match<Customer, Current<AccessInfo.userName>>>>>, OrderBy<Desc<ARRegisterAlias.refNbr>>>), Filterable = true, IsPrimaryViewCompatible = true)]
    //[ARInvoiceType.Numbering] 
    //This is example of throwing away Acumatica autonumbering
    //[ARInvoiceNbr]
    [PXFieldDescription]
    protected void ARInvoice_RefNbr_Cacheattached()
    {

    }

    protected void ARInvoice_RefNbr_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
    {
        //here you can implement your way of initialization of this field

    }
}

或者使用属性,您可以尝试这样的操作:

Or with attribute you can try something like this:

//somewhere in your code
public class RickAutonumberingAttribute : ARInvoiceNbrAttribute
{
    //Here you'll need to play with implementation of your autonumbering
}

public class ARInvoiceEntryExt : PXGraphExtension<ARInvoiceEntry>
{
    [PXDBString(15, InputMask = ">CCCCCCCCCCCCCCC", IsKey = true, IsUnicode = true)]
    [PXDefault]
    [PXUIField(DisplayName = "Reference Nbr.", TabOrder = 1, Visibility = PXUIVisibility.SelectorVisible)]
    [ARInvoiceType.RefNbr(typeof(Search2<ARRegisterAlias.refNbr, InnerJoinSingleTable<ARInvoice, On<ARInvoice.docType, Equal<ARRegisterAlias.docType>, And<ARInvoice.refNbr, Equal<ARRegisterAlias.refNbr>>>, InnerJoinSingleTable<Customer, On<ARRegisterAlias.customerID, Equal<Customer.bAccountID>>>>, Where<ARRegisterAlias.docType, Equal<Optional<ARInvoice.docType>>, And2<Where<ARRegisterAlias.origModule, Equal<BatchModule.moduleAR>, Or<ARRegisterAlias.released, Equal<True>>>, And<Match<Customer, Current<AccessInfo.userName>>>>>, OrderBy<Desc<ARRegisterAlias.refNbr>>>), Filterable = true, IsPrimaryViewCompatible = true)]
    //[ARInvoiceType.Numbering] 
    //This is example of throwing away Acumatica autonumbering
    [RickAutonumberingAttribute]
    [PXFieldDescription]
    protected void ARInvoice_RefNbr_Cacheattached()
    {
    }

}

这篇关于混合手动\自动编号序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆