//先找到数据库里当天日期的最大流水号
string strSQL = string.Format("SELECT right(max(ECRNo),4) as ECR FROM pimECMECRSheet where CONVERT(varchar(100), Create_On, 112)=CONVERT(varchar(100), GETDATE(), 112)");
string s = dbUtil.GetSelectedItemData(strSQL);
//按既定规则,自增数字,生成流水号
int i;if (s == "" || s == null)
{
s = "0001";
}
else
{
i = Int32.Parse(s);
i++;
s = i.ToString().PadLeft(4, '0');
}
string strECNno = "ECR" + DateTime.Now.ToString("yyMMdd")+"."+s;
MessageBox.Show(strECNno);