Esempio n. 1
0
        /// <summary>
        /// 给定表名,获得下一个ID,实现主键的自动增长
        /// </summary>
        /// <param name="tableName"></param>
        /// <returns></returns>
        public string GetNextId(string tblName)
        {
            string strResult = dal.ExecuteScalar("UP_GetMaxId",
                                                 new SqlParameter("@TableName", tblName)).ToString();

            //判断有无数据
            if (strResult.Length != 0)
            {
                int i = Convert.ToInt32(
                    strResult.Substring(strResult.Length - 4));
                i++;
                return(tblName + i.ToString());
            }
            else
            {
                return(tblName + "1001");
            }
        }