internal void AddTableField(Hubble.Framework.Data.DataColumn col) { System.Data.DataColumn sCol = new DataColumn(col.ColumnName, col.DataType); TableField tableField = new TableField(sCol, AnalyzerList); tableField.Enabled = true; _TableFields.Add(tableField); }
private void buttonAddField_Click(object sender, EventArgs e) { TableField tableField = new TableField(radioButtonCreateTableFromExistTable.Checked, AnalyzerList); tableField.Enabled = true; _TableFields.Add(tableField); ShowTableField(); }
private void ClearTableFields() { List <TableField> tableFields = new List <TableField>(); foreach (Control control in panelFields.Controls) { TableField tableField = control as TableField; if (tableField != null) { tableFields.Add(tableField); } } foreach (TableField tableField in tableFields) { panelFields.Controls.Remove(tableField); } }
private void ShowFields(DataTable table) { int currentTop = panelHead.Top + panelHead.Height; foreach (DataRow row in table.Rows) { TableField tableField = new TableField(); tableField.FieldName = row["FieldName"].ToString(); tableField.DataType = row["DataType"].ToString(); tableField.IndexType = row["IndexType"].ToString(); tableField.DataLength = int.Parse(row["DataLength"].ToString()); tableField.AnalyzerName = row["Analyzer"].ToString(); tableField.IsNull = bool.Parse(row["IsNull"].ToString()); tableField.IsPK = bool.Parse(row["IsPrimaryKey"].ToString()); tableField.DefaultValue = row["Default"].ToString(); tableField.Top = currentTop; tableField.Left = panelHead.Left; tableField.Visible = true; tableField.Enabled = false; currentTop += tableField.Height; tabPageFields.Controls.Add(tableField); } }
private string GetOneRowSql(DataSet schema, DataRow row, string tableName) { StringBuilder insertString = new StringBuilder(); insertString.AppendFormat("Insert {0} (", tableName); int i = 0; foreach (DataColumn col in schema.Tables[0].Columns) { if (i == 0) { insertString.AppendFormat("[{0}]", TableField.GetFieldName(col.ColumnName)); } else { insertString.AppendFormat(", [{0}]", TableField.GetFieldName(col.ColumnName)); } i++; } insertString.Append(") Values("); i = 0; foreach (DataColumn col in schema.Tables[0].Columns) { string value; if (row[col.ColumnName] == DBNull.Value) { value = "NULL"; } else { if (col.DataType == typeof(string)) { value = "'" + row[col.ColumnName].ToString().Replace("'", "''") + "'"; } else if (col.DataType == typeof(DateTime)) { value = "'" + ((DateTime)(row[col.ColumnName])).ToString("yyyy-MM-dd HH:mm:ss") + "'"; } else if (col.DataType == typeof(double) || col.DataType == typeof(Single) || col.DataType == typeof(decimal)) { value = string.Format("{0:0.################}", row[col.ColumnName]); } else { value = row[col.ColumnName].ToString(); } } if (i == 0) { insertString.AppendFormat("{0}", value); } else { insertString.AppendFormat(", {0}", value); } i++; } insertString.Append(");"); return(insertString.ToString()); }