c# 财务数据编号的生辰

实现逻辑:

    根据票号前戳+生成的6位数据编号=收据号(010+000001=010000001)

作废票号

       将票号作废,插入到编号表中,以此下次在使用

作废票号使用

      编号表中 现在只有2,当我作废1的时候,表中就有1 2 值了

        假如我现在的作废号为010000001,我表中插入1的值,因此 我下次在使用的时候 直接取 最小的值,当我在生成的时候,我就把此条的作废号删除,编号表中只保留一条.

  string sql = "select count(num) from f_za_code";
            string codes = "";
            object i = SqlHelper.ExecuteScalarText(sql, null);
            if (int.Parse(i.ToString()) > 1)
            {
                string drs = "select lpad(min(num),6,0) from f_za_code";

                MySqlDataReader dr = SqlHelper.ExecuteReaderText(drs, null);
                while (dr.Read())
                {

                    codes = dr[0].ToString();
                }

            }
            else 
            {
                string drs = "select lpad(num,6,0) from f_za_code";

                MySqlDataReader dr = SqlHelper.ExecuteReaderText(drs, null);
                while (dr.Read())
                {

                    codes = dr[0].ToString();
                }
            }
            return codes;

  

原文地址:https://www.cnblogs.com/mengluo/p/5776237.html