生成流水号的方法

public JiaSoft.InformationPlatform.Model.ScientificInstitution GetSerialNumberModel()
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select right(10000+max(Id)+1,4) as SerialNumber" );
strSql.Append(" FROM ScientificInstitution ");
DataSet ds = DbHelperSQL.Query(strSql.ToString());
JiaSoft.InformationPlatform.Model.ScientificInstitution model = new
JiaSoft.InformationPlatform.Model.ScientificInstitution();
string SerialNumber = ds.Tables[0].Rows[0]["SerialNumber"].ToString();
if (SerialNumber !="")
{ model.SerialNumber=SerialNumber;
return model;
} else
{ model.SerialNumber = "0001";
return model;
}
}
//此方法为生成N位流水号的方法
注意生成位数要与零的位数和截取位数一致。
posted on 2011-08-08 11:48  cheers  阅读(596)  评论(0编辑  收藏  举报