要写一个编号,编号格式如:OA_110_12_0001号,在服务层里写好,在后台直接调用。OA是固定的,110是公司编号(在数据库读取,公司不同编号不同),12是年份的后两位,00001是流水号。
下民是以前的编号:
string TempCode = "OA_" + item.GroupCodeValue + "_" + DateTime.Now.ToString("yy") + "_" + BingoExtension.GetSerialNumberForpkurgContract();
item.ContractCode = TempCode;
以前的编号是每天流水号一换,现在的编号是想每年流水号一换,
我新手,不会写,求大神指教,小弟感激不尽。下面的是在服务层里。
namespace Bingo.Modules.FounderOA.PKUResourceGroupWorkflow.Ext
{
    public class ContractCodeService : BizObjectServiceBase<ContractCode>, IContractCodeService
    {
        /// <summary>
        /// 获取当前类型的编号的序号
        /// </summary>
        /// <param name="code">所属公司编号</param>
        public  int GetSerialCode(string code)
        {
            int ReportValue = 0;
            string OA = "OA_";
            //code格式如:OA_110_12_0001号
            ContractCode Item = this.GetEntities().Where(A => A.Code.StartsWith(OA + code)).OrderByDescending(A => Convert.ToInt32(A.Code.Replace(OA + code, "").Replace("号", ""))).FirstOrDefault();
            
            if (Item == null)
            {
                ReportValue = 1;
            }
            else
            {
                var temp = Item.Code.Replace(OA + code , "").TrimStart('0', '-')+ 1;
                int? V = temp.TrimEnd('号').ToInt();
                ReportValue = V == null ? 0 : (V.Value + 1);
            }
            return ReportValue;
        }
    }
}该怎么写...