日期:2014-05-18 浏览次数:20546 次
public string GetReceiveNumber() { string todayDateString = DateTime.Now.ToString("yyyyMMdd"); string sql = "select max(reveive_number) from material_receive where subString( reveive_number,2,8)='" + todayDateString + "' "; DataSet ds = dal.GetDSBySQL(sql); if (ds.Tables[0].Rows[0][0].ToString() == "") { return "A" + todayDateString + "001"; } else { string sn = ds.Tables[0].Rows[0][0].ToString(); return sn.Substring(0, 9) + (int.Parse(sn.Substring(9)) + 1).ToString().PadLeft(3, '0'); } }
---修正 select 'A'+convert(varchar(12) , getdate(), 112 )+right('0000'+ltrim(row_number()over(order by getdate())),3) /*------------------- A20110928001 (1 行受影响)*/
------解决方案--------------------
+1