生成预订单编号

 public ActionResult CreateYuDingDanHao()

        {

            string YuDingDanHao= "YD";

            string Year = DateTime.Now.Year.ToString();

            string Month = DateTime.Now.Month.ToString().Length == 1 ? "0" + DateTime.Now.Month.ToString() : DateTime.Now.Month.ToString();

            string Day = DateTime.Now.Day.ToString().Length == 1 ? "0" + DateTime.Now.Day.ToString() : DateTime.Now.Day.ToString();

            Random rd = new Random();

            string suijihao = rd.Next(1, 99999).ToString();

            YuDingDanHao= YuDingDanHao+ suijihao + Year + Month + Day;

            return Json(YuDingDanHao, JsonRequestBehavior.AllowGet);

       }

你可能感兴趣的:(生成预订单编号)