C#生成编号
//自动生成账单编号 public string GetNewPoID(string Prefix) { string NewPoID = Prefix + DateTime.Now.Year.ToString().Substring(2); CommandText = "SELECT count(*) FROM OverSystems_PoInfo where PoNo like '" + NewPoID + "%'"; if (Convert.ToInt32(sqlAccess.ExecuteScalar(CommandText)) > 0) { string LastPoID; CommandText = "SELECT PoNo FROM OverSystems_PoInfo where PoNo like '" + NewPoID + "%' order by PoNo desc"; LastPoID = Convert.ToString(sqlAccess.ExecuteScalar(CommandText)).Substring(4); if (LastPoID.IndexOf("-") >= 0) LastPoID = LastPoID.Substring(0, LastPoID.IndexOf("-")); NewPoID += (Convert.ToInt32(LastPoID) + 1).ToString("000"); } else { NewPoID += "001"; } return NewPoID; }