using System; using System.Collections.Generic; using System.Linq; using System.Text; using FireBirdUtil.SqlHelpers; namespace WeighBusiness.BO.CreateTables { public abstract class CreateTable { string _SqlAfterCreateTable; public string SqlAfterCreateTable { private get { return _SqlAfterCreateTable; } set { _SqlAfterCreateTable = value; } } CreateTableHelper _CTH; public CreateTable(string database, string tableName) { #if DEBUG if (string.IsNullOrEmpty(database) || string.IsNullOrEmpty(tableName)) throw new ArgumentException("构造函数的参数不能为空"); #endif _CTH = new CreateTableHelper(database, tableName); AddFields(_CTH); } public abstract void AddFields(CreateTableHelper cth); public bool Create() { string errorMessage; return Create(out errorMessage); } public bool Create(out string errorMessage) { errorMessage = string.Empty; try { _CTH.CreateTableIfNotExist(_SqlAfterCreateTable); return true; } catch (Exception ex) { errorMessage = ex.ToString(); return false; } } } }