string .format 生成类似20090409001的序号
string sUsername = "";
string date = DateTime.Now.ToString("yyyyMMdd");
DataTable dtmax = Conn.query("select sUserName from xUser where sUserName like '" + date + "%' order by sUserName desc ");
if (dtmax.Rows.Count == 0)
sUsername = date + "001";
else
sUsername =date +String .Format ("{0:D3}", (Convert.ToInt32(dtmax.Rows[0] ["sUserName"].ToString().Substring(7)) + 1));
txtsUserName.Text = sUsername;