Epicor流水编号规则功能

本文介绍在Epicor二次开发中实现自定义流水编号功能的方法,包括设定前缀、流水号长度及下一编号,通过代码示例展示如何在系统中获取并更新流水编号。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

流水编号规则功能

因为在Epicor二次开发中使用流水编号时,总感觉非常繁琐,所以就想到开发一个功能用于获取流水编号。

功能要求

  1. 可设定前缀字符串
  2. 可设定流水号长度
  3. 可设定下一编号

字段使用

字段(UD05表)字段描述初始默认值
Key1编号规则代码
Key2数据类型NumberingRule
ShortChar01规则名称
Character01规则描述
ShortChar02格式化代码
ShortChar03规则分类
Number01下一编号1

界面设计

取号代码

public static string GetNewCode(EpiTransaction otrans, string ruleCode) {
    if (string.IsNullOrEmpty(ruleCode)) throw new Exception("获取'"+ ruleCode + "'编号失败!");
    string code = "";
    AdpUDBase ud05 = new AdpUDBase(otrans, "UD05");
    try
    {
        bool bl = ud05.GetByID(ruleCode, "NumberingRule", "", "", "");
        if (bl)
        {
            string formatCode = Convert.ToString(ud05.GetValue("UD05", "ShortChar02"));
            int nextNum = Convert.ToInt32(ud05.GetValue("UD05", "Number01"));

            if (string.IsNullOrEmpty(formatCode)) code = nextNum.ToString();
            else
            {
                string qz = formatCode.TrimEnd('0');
                int length = formatCode.Length - qz.Length;
                code = qz + nextNum.ToString().PadLeft(length, '0');
            }
            ud05.UpdateValue("UD05", "Number01", nextNum + 1);
        }else throw new Exception("获取'"+ ruleCode + "'编号失败!");
    }
    catch(Exception e1)
    {
        throw new Exception("获取'" + ruleCode + "'编号失败!"+e1.Message);
    }
    finally
    {
        ud05.Dispose();
    }
    return code;
}

上面代码中用的AdpUDBase类请查看Epicor10中Adapter使用封装

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值