日期:2014-05-17 浏览次数:20536 次
int max = 100; System.Linq.Enumerable.Range(1, max).ToList().ForEach(i => { string value = "0000000" + i.ToString(); Console.WriteLine("{0}{1}", DateTime.Now.ToString("yyyyMMddhhmm"), value.Substring(value.Length - 5)); });
------解决方案--------------------
class Program { static void Main(string[] args) { Console.WriteLine(CreateOrderNumber("20120117091100001")); } /// <summary> /// 生成新订单号 /// </summary> /// <param name="thisOrderNumber">当前订单号</param> /// <returns>返回新订单号</returns> public static string CreateOrderNumber(string thisOrderNumber) { string num = thisOrderNumber.Substring(12, 5); int newNum = int.Parse(num) + 1; return DateTime.Now.ToString("yyyyMMddHHmm")+newNum.ToString().PadLeft(5,'0'); } }
------解决方案--------------------
肯定要涉及数据库操作的吧,否则很容易出现重复的