public static List <ColumnEditSchema> GetTableColumnsSchema(string SchemaName, string tableName, CodeConfigHelper objCodeConfigHelper, string connectionString = "") { DataTable dataTable = new DataTable("TableColumns"); string tableForeignFileName = SqlSchemaHelper.GetTableForeignFileName(SchemaName, tableName, connectionString); List <ColumnEditSchema> list = new List <ColumnEditSchema>(); foreach (DataRow dataRow in SqlSchemaHelper.GetTableColumns(SchemaName, tableName, connectionString).Rows) { XmlNode xmlNode = objCodeConfigHelper.CodeConfig.SelectSingleNode(string.Concat(new string[] { "//BusinessConfig/Business[@TableName='", tableName, "']/Field[@FieldName='", dataRow["FieldName"].ToString(), "']" })); bool flag = xmlNode == null; list.Add(new ColumnEditSchema { TableName = tableName, DataType = dataRow["DataType"].ToString(), Length = ((dataRow["DataType"].ToString() == "longtext") ? 0 : int.Parse(dataRow["Length"].ToString())), FieldName = dataRow["FieldName"].ToString(), FieldTitle = (flag ? dataRow["Description"].ToString() : xmlNode.Attributes["FieldTitle"].Value), ControlType = SqlSchemaHelper.GetControlType(dataRow["DataType"].ToString()), IsShow = false, IsEmpty = (dataRow["IsNullable"].ToString() == "1"), ErrorMessage = (flag ? (((dataRow["DataType"].ToString() == "int" || dataRow["DataType"].ToString() == "bit") ? "请选择" : "请输入") + dataRow["Description"]) : xmlNode.Attributes["ErrorMessage"].Value), IsAutoValue = false, ColumnType = ((dataRow["IsKey"].ToString() == "1") ? "PrimaryKey" : ((dataRow["FieldName"].ToString() == tableForeignFileName) ? "ForeignKey" : "Common")), ValidationReg = "" }); } return(list); }
public static TableListSchema GetTableListSchema(string SchemaName, string tableName, string moduleID, string url, string ConnectionString, CodeConfigHelper objCodeConfigHelper, string WTFConfigPath) { TableListSchema tableListSchema = new TableListSchema(); tableListSchema.TableName = tableName; DataTable dataTable = new DataTable("TableColumns"); string tableForeignFileName = SqlSchemaHelper.GetTableForeignFileName(SchemaName, tableName, ConnectionString); foreach (DataRow dataRow in SqlSchemaHelper.GetTableColumns(SchemaName, tableName, ConnectionString).Rows) { XmlNode xmlNode = objCodeConfigHelper.CodeConfig.SelectSingleNode(string.Concat(new string[] { "//BusinessConfig/Business[@TableName='", tableName, "']/Field[@FieldName='", dataRow["FieldName"].ToString(), "']" })); bool flag = xmlNode == null; tableListSchema.Columns.Add(new ColumnListSchema { TableName = tableName, IsIdentity = (dataRow["Identity"].ToString() == "1"), DataType = dataRow["DataType"].ToString(), FieldName = dataRow["FieldName"].ToString(), FieldTitle = (flag ? dataRow["Description"].ToString() : xmlNode.Attributes["FieldTitle"].Value), ControlType = ((dataRow["DataType"].ToString() == "int" || dataRow["DataType"].ToString() == "bit") ? "TemplateField" : "BoundField"), Width = ((dataRow["DataType"].ToString().IndexOf("datetime") >= 0) ? 120 : 0), IsShow = false, IsSearch = false, IsSort = false, FormatString = ((dataRow["DataType"].ToString().IndexOf("datetime") >= 0) ? "yyyy-MM-dd HH:mm:ss" : ""), ColumnType = ((dataRow["IsKey"].ToString() == "1") ? "PrimaryKey" : ((dataRow["FieldName"].ToString() == tableForeignFileName) ? "ForeignKey" : "Common")) }); } string configConnectionString = Common.GetConfigConnectionString(WTFConfigPath); foreach (DataRow dataRow in SqlSchemaHelper.MySqlHelper.ExecuteDataTable(string.Format(Resources.GetCommand, moduleID), CommandType.Text, null, configConnectionString).Rows) { tableListSchema.Commands.Add(new CommandSchema { CommandName = dataRow["CommandName"].ToString(), ProcessType = ((dataRow["CommandName"].ToString().IndexOf("Modify") >= 0 || dataRow["CommandName"].ToString().IndexOf("View") >= 0) ? "RedirectState" : ((dataRow["CommandName"].ToString().IndexOf("Create") >= 0 || dataRow["CommandName"].ToString().IndexOf("Back") >= 0) ? "Redirect" : "RenderPage")), RedirectUrl = ((dataRow["CommandName"].ToString().IndexOf("Modify") >= 0 || dataRow["CommandName"].ToString().IndexOf("Create") >= 0 || dataRow["CommandName"].ToString().IndexOf("View") >= 0 || dataRow["CommandName"].ToString().IndexOf("Back") >= 0) ? url : ""), ModuleName = dataRow["ModuleName"].ToString(), IsTop = (dataRow["PlaceType"].ToString().IndexOf("101") >= 0), IsBotom = (dataRow["PlaceType"].ToString().IndexOf("103") >= 0), IsList = (dataRow["PlaceType"].ToString().IndexOf("102") >= 0), SortIndex = int.Parse(dataRow["SortIndex"].ToString()) }); } return(tableListSchema); }
public static List <ColumnRuleSchema> GetTableRuleColumnsSchema(string Connectionstring, string SchemaName, string tableName, CodeConfigHelper objCodeConfigHelper) { DataTable dataTable = new DataTable("TableColumns"); string tableForeignFileName = SqlSchemaHelper.GetTableForeignFileName(SchemaName, tableName, Connectionstring); List <ColumnRuleSchema> list = new List <ColumnRuleSchema>(); foreach (DataRow dataRow in SqlSchemaHelper.GetTableColumns(SchemaName, tableName, Connectionstring).Rows) { bool isXmlField = false; string text = "请输入" + dataRow["Description"]; XmlNode xmlNode = objCodeConfigHelper.CodeConfig.SelectSingleNode(string.Concat(new string[] { "//BusinessConfig/Business[@TableName='", tableName, "']/Field[@FieldName='", dataRow["FieldName"].ToString(), "']" })); bool isCheck; if (xmlNode == null) { isCheck = false; } else { isCheck = bool.Parse(xmlNode.Attributes["IsCheck"].Value); text = xmlNode.Attributes["ErrorMessage"].Value; isXmlField = true; } string text2 = (xmlNode == null) ? dataRow["Description"].ToString() : xmlNode.Attributes["FieldTitle"].Value; list.Add(new ColumnRuleSchema { TableName = tableName, IsXmlField = isXmlField, DataType = dataRow["DataType"].ToString(), IsIdentity = (dataRow["Identity"].ToString() == "1"), IsUnsigned = (dataRow["IsUnsigned"].ToString() == "1"), Length = ((dataRow["DataType"].ToString() == "longtext") ? 0 : int.Parse(dataRow["Length"].ToString())), IsEmpty = (dataRow["IsNullable"].ToString() == "1"), FieldName = dataRow["FieldName"].ToString(), Description = dataRow["Description"].ToString(), FieldTitle = text2, IsCheck = isCheck, ErrorMessage = text, OldErrorMessage = text, OldFieldTitle = text2, ColumnType = ((dataRow["IsKey"].ToString() == "1") ? "PrimaryKey" : ((dataRow["FieldName"].ToString() == tableForeignFileName) ? "ForeignKey" : "Common")) }); } return(list); }