zoukankan      html  css  js  c++  java
  • 按日期添加生成单号

     public string GetNext挂号代码(string 登记日期)
            {
                string strReturn = "";
                StringBuilder strSql = new StringBuilder();
                strSql.Append(" select MAX(Regid) as maxgh");
                strSql.Append(" from Us_ghxx ");
                strSql.Append("   where  (select CONVERT(varchar(12) ,Ghrq, 112 ) )='" + 登记日期 + "' ");
                DataSet ds = DbHelperSQL.Query(strSql.ToString());


                int int挂号代码 = 0;
                if (ds.Tables[0].Rows[0]["maxgh"].ToString().Trim() == "")
                {
                    strReturn = 登记日期 + "00001";
                }
                else
                {

                    string strTmp = ds.Tables[0].Rows[0]["maxgh"].ToString();
                    int挂号代码 = int.Parse(strTmp.Substring(8, 5));

                    int挂号代码 = int挂号代码 + 1;

                    string str挂号代码 = int挂号代码.ToString().Trim();
                    if (str挂号代码.Length == 1)
                    {
                        str挂号代码 = "0000" + str挂号代码;
                    }
                    else if (str挂号代码.Length == 2)
                    {
                        str挂号代码 = "000" + str挂号代码;
                    }
                    else if (str挂号代码.Length == 3)
                    {
                        str挂号代码 = "00" + str挂号代码;
                    }
                    else if (str挂号代码.Length == 4)
                    {
                        str挂号代码 = "0" + str挂号代码;
                    }
                    strReturn = 登记日期 + str挂号代码;
                }

                return strReturn;
            }

  • 相关阅读:
    codeforces 1C(几何题)
    poj 1015 Jury Compromise
    poj 1466 计算直线的交点数
    poj 1228 凸包第一题
    2012 MUTC 3 总结
    用优先队列优化Dij的一个代码
    有关排序时,上移,下移的处理思路
    有关缓存的思考
    python备份文件2 分类: python 20130315 15:16 233人阅读 评论(0) 收藏
    lambda表达式使用方法详解 分类: python 20130315 10:58 396人阅读 评论(0) 收藏
  • 原文地址:https://www.cnblogs.com/leischen/p/2475769.html
Copyright © 2011-2022 走看看