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;
}

 

相关文章:

  • 2021-08-01
  • 2022-01-17
  • 2022-03-03
  • 2022-01-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
相关资源
相似解决方案