自动生成编号

       /// <summary>
        /// 生成id
        /// </summary>
        /// <returns></returns>
        private int GenerateId(EnrollPaytHdr model)
        {
            string id;
            string tag = "E";
            string now = tag + DateTime.Now.ToString("yyyyMM");
            if (model != null)
            {
                string s = model.refNo.ToString();
                string prefix = s.Substring(0, 7);

                id = (prefix == now ? int.Parse(s.Remove(0, 7)) + 1 : 1).ToString().PadLeft(4, '0');
            }
            else
            {
                id = "0001";
            }

            return int.Parse(now + id);
        }

  

posted @ 2021-01-04 16:30  没有狐狸的南墙  阅读(120)  评论(0编辑  收藏  举报