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;
}