<%@ Page CodeFileBaseClass="AliCMS.Lib.SystemPageBase" %>
<ali:Get ID="Config" Object="InstanceConfig" Operation="GetBasicSettings()" />
<script language="c#" runat="server">
protected string MaxNo
{
	get
	{
		string maxNo = "";
		
		int id = 0;
		int typeNoDigit = Convert.ToInt32(<%=Config[TypeNoDigit]%>);
		int goodsNoDigit = Convert.ToInt32(<%=Config[GoodsNoDigit]%>);
		
		using (IGoods goodsBll = (IGoods)Manager.CreateObject("Goods", InstanceID, ContentLang, false))
		{
			DataTable table = goodsBll.List(1, 1, null, Alias.Goods.InnerID + " DESC");
			if (table.Rows.Count == 0)
				id = 1;
			else
				id = (int)table.Rows[0][Alias.Goods.InnerID];

			int count = goodsNoDigit - id.ToString().Length;
			if (count < 0)
				return "";
	
			while (true)
			{
				maxNo = "";
				for (int i = 0; i < count; i++)
				{
					maxNo += '0';
				}
				maxNo += id;
				
				table = goodsBll.List(1, 1, Alias.Goods.No + "='" + maxNo + "'", Alias.Goods.No + " DESC");
				if (table.Rows.Count == 0)
					break;
				else
					id++;
			}
		}		
		
		return maxNo;
	}
}
</script>
<%=MaxNo%>