首页 > 代码库 > .net编程:自动生成会员卡号

.net编程:自动生成会员卡号

   /// <summary>
        /// 自动生成会员卡号
        /// </summary>
        void CardNumber()
        {
            string sql = string.Format("select top 1 cardId from cardInfo order by cardId desc");
            DBHelper.cmd = new SqlCommand(sql, DBHelper.conn);
            DBHelper.conn.Open();
            int id = Convert.ToInt32(DBHelper.cmd.ExecuteScalar());
            DBHelper.conn.Close();
            string number = string.Format("023-{0:D3}", id + 1);
            txtCardNumber.Text = number;
        }