关于 C# 十进制不足补位的应用

看下面图的应用(我们平常的一些自定义主键增加):

补位应用知识:

D十进制 不足几位前面补0

基于这个我们可以得到上面结果

           //最大編號
            string maxNo = string.Empty;
            //3到8 00001  0002
            string cmdText = "SELECT MAX(SUBSTRING(ServerQueueNo,3, 8)) AS ServerQueueNo FROM test_publish_server_queue_info";
            object o = SqlHelper.ExecuteScalar(SqlHelper.ERPDBConnection, cmdText);
            string max = (o != null ? o.ToString() : "");

            if (!string.IsNullOrEmpty(max))
            {
         //SQ00001 SQ0002  
int num = Convert.ToInt32(max) + n; //D5 ,5位十进制数,不足5位前面补0 SQ00001 maxNo = string.Format("SQ{0}", num.ToString("D5")); } else maxNo = string.Format("SQ0000{0}",1); if (this.CheckSQNo(maxNo)) return this.GetMaxPmNo(n + 1); else return maxNo;
原文地址:https://www.cnblogs.com/yzenet/p/5090857.html