public Order_Code GetOrderCount() { int orderCount = 0; var dataReader = this.SqlServer.ExecuteDataReader(CommandType.StoredProcedure, "[sp_GetOrderCount]", null, null); if (dataReader.Read()) { var code = new Order_Code { OrderCode = Convert.ToInt32(dataReader["OrderCount"]), CreateTime = Convert.ToDateTime(dataReader["CreateTime"]) }; return code; } return null; }
/// <summary> /// 加密订单编码 /// </summary> /// <param name="code"></param> /// <returns></returns> private static string EncryptionCode(Order_Code code) { string nowtimeStr = DateTime.Today.ToString("yyyyMMdd");//获取当前时间 //当前时间去掉第一位,加上最大订单编号,保证10位 string strNo = nowtimeStr.Substring(1) + code.OrderCode.ToString().PadLeft(4, '0'); string strlastTime = code.CreateTime.ToString("yyyyMMdd HHmmss"); //当前时间的最后一位 int lastTime = int.Parse(strlastTime.Substring(strlastTime.Length - 1)); //根据秒自增 lastTime = lastTime == 0 ? 3 : lastTime; //当前时间最后一位乘111111111 int intfeed = lastTime * 11111111; long longFeed = Convert.ToInt64(strNo) + intfeed; return longFeed.ToString(); }