⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lookups.cs

📁 客户关系管理系统ASP.NET+VB.NET编程完整程序!
💻 CS
字号:
//This file is part of ORM.NET.
//
//ORM.NET is free software; you can redistribute it and/or
//modify it under the terms of the GNU Lesser General Public
//License as published by the Free Software Foundation; either
//version 2.1 of the License, or (at your option) any later version.
//
//ORM.NET is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public
//License along with ORM.NET; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


using System;
using System.Text;
using OrmLib;
using ORMBiz;

namespace ORM.NET
{
	/// <summary>
	/// Summary description for Lookups.
	/// </summary>
	public class LookupsGenerator
	{
		private TemplateParser tp = new TemplateParser();

		public LookupsGenerator(){}

		public string Generate(Database db)
		{
			return tp.RestoreAfterFormatting( RenderPage(db) );
		}

		private string RenderPage(Database db)
		{
			string classString = tp.LoadTemplate(@"Biz\Lookups\class");

			//string declares = "string sql = \"\";\r\nDataTable t;";
			
			return string.Format( classString,Shared.NameSpace, GetPropertyStatements(db), GetSqlStatements(db), GetOrderedTableStatements(db), GetDataStatements(db) );
		}

		private string GetPropertyStatements(Database db)
		{
			string property = tp.LoadTemplate(@"Biz\Lookups\property");
			string code = "";

			foreach ( Table t in db.Tables )
			{
				if ( t.GenerateCodeFor.ToLower() == "true" )
				{
					if ( t.IsLookupTable.ToLower() == "true" )
					{
						code += string.Format(property,t.AccessorName);
					}
				}
			}
			return code;
		}

		private string GetSqlStatements(Database db)
		{
			string sql = tp.LoadTemplate(@"Biz\Lookups\sql");
			string code = "";

			foreach ( Table t in db.Tables )
			{
				if ( t.GenerateCodeFor.ToLower() == "true" )
				{
					if ( t.IsLookupTable.ToLower() == "true" )
					{
						code += string.Format(sql,t.Name,t.AccessorName);
					}
				}
			}
			return code;
		}

		private	string GetOrderedTableStatements(Database db)
		{
			string sql = tp.LoadTemplate(@"Biz\Lookups\OrderedTables");
			string code = "";

			foreach ( Table t in db.Tables )
			{
				if ( t.GenerateCodeFor.ToLower() == "true" )
				{
					if ( t.IsLookupTable.ToLower() == "true" )
					{
						code += string.Format(sql,t.Name);
					}
				}
			}
			return code;
		}

		private string GetDataStatements(Database db)
		{
			string data = tp.LoadTemplate(@"Biz\Lookups\data");
			string code = "";

			foreach ( Table t in db.Tables )
			{
				if ( t.GenerateCodeFor.ToLower() == "true" )
				{
					if ( t.IsLookupTable.ToLower() == "true" )
					{
						code += string.Format(data,t.AccessorName, t.Name);
					}
				}
			}
			return code;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -