我是靠谱客的博主 优雅发带,这篇文章主要介绍c#生成连续单号,现在分享给大家,希望可以做个参考。

bill.BillCode = GetBillCode("JH");//生成单号
if (bill.BillCode == "no")
{
bill.BillCode = GetBillCode("JH");//再次生成单号
}

/// <summary>
/// 生成单号
/// </summary>
/// <returns></returns>
public string GetBillCode(string head)
{
string res = "";
try
{
string temp = DateTime.Now.ToString("yyyyMM");//六位年月
int totalCount;//没用
string flowid;
var lastbill = CurrentDal.LoadPageEntities(a => a.BillCode.Substring(2, 6) == temp, a => a.BillCode, 1, 1, false, out totalCount).FirstOrDefault();
if (lastbill == null)
{
flowid = "00001";
}
else
{
flowid = string.Format("{0:00000}", (Convert.ToInt32(lastbill.BillCode.Substring(8, 5)) + 1));
}
res = head + temp + flowid;
}
catch
{
res = "no";
}
return res;
}

 

转载于:https://www.cnblogs.com/zhang-wenbin/p/7681325.html

最后

以上就是优雅发带最近收集整理的关于c#生成连续单号的全部内容,更多相关c#生成连续单号内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(60)

评论列表共有 0 条评论

立即
投稿
返回
顶部