//生成订单号 public string GetOrderNO() { StringBuilder result = new StringBuilder(); DateTime now = DateTime.Now; result.Append(now.Year.ToString().Substring(2, 2)); string month = now.Month.ToString(); result.Append(month.Length < 2 ? "0" + month : month); string day = now.Day.ToString(); result.Append(day.Length < 2 ? "0" + day : day); String hour = now.Hour.ToString(); result.Append(hour.Length < 2 ? "0" + hour : hour); string minute = now.Minute.ToString(); result.Append(minute.Length < 2 ? "0" + minute : minute); string second = now.Second.ToString(); result.Append(second.Length < 2 ? "0" + second : second); int last = new Random().Next(10000); result = result.Append(last.ToString()); if (last > 99 && last <= 999) { result = result.Append("0"); } else if (last > 9 && last <= 99) { result = result.Append("00"); } else if (last <= 9) { result = result.Append("000"); } else { } return result.ToString(); }