private void BtnSave_Click(object sender, EventArgs e) { DBColumn dbColumn = new DBColumn() { ColumnName = txtColumnName.Text, AllowNull = checkBoxAllowNull.Checked, DbType = JFieldType.String, }; int length = 0; if (!string.IsNullOrEmpty(txtLength.Text)) { int.TryParse(txtLength.Text, out length); dbColumn.Length = length; } if (!string.IsNullOrEmpty(comboBoxSQLDBType.Text)) { JFieldType dbType; if (Enum.TryParse<JFieldType>(comboBoxSQLDBType.Text, out dbType)) { dbColumn.DbType = dbType; } } JField field = new JField(dbColumn); if (AddFieldDelegate != null) { AddFieldDelegate(field); } this.Close(); }
private DBForeignKey(DBColumn column) { this.ColumnName = column.ColumnName; this.DbType = column.DbType; this.Length = column.Length; this.AllowNull = column.AllowNull; }
public DBPrimaryKey(DBColumn column, bool isIdentity, int seed, int currentValue, int step) : this(column) { this.IsIdentity = isIdentity; this.Seed = seed; this.CurrentValue = currentValue; this.Step = step; }
public JField(DBColumn column) { this.FieldName = column.ColumnName; this.ValueType = column.DbType; this.FirstOperand = new JOperateNum(this.FieldName, this.ValueType); this.AllowNull = column.AllowNull; if (column is DBPrimaryKey) { DBPrimaryKey pk = column as DBPrimaryKey; this.FirstOperand.ValueCategroy = JValueCategroy.Sequence; this.FirstOperand.MinValue = pk.CurrentValue + pk.Step; this.FirstOperand.Step = pk.Step; } if (column is DBForeignKey) { DBForeignKey fk = column as DBForeignKey; this.FirstOperand.ValueCategroy = JValueCategroy.FromTable; this.FirstOperand.ReferenceTableName = fk.ReferenceTableName; this.FirstOperand.ReferenceColumnName = fk.ReferenceColumnName; } this.Visible = false; this.Order = 0; }
private DBPrimaryKey(DBColumn column) { this.ColumnName = column.ColumnName; this.DbType = column.DbType; this.Length = column.Length; }
public DBForeignKey(DBColumn column, string reftableName, string refColumnName) : this(column) { this.ReferenceColumnName = refColumnName; this.ReferenceTableName = reftableName; }
public void AddForeignKey(DBColumn column, string refTableName, string refColumnName) { this.ForeignKeys.Add(new DBForeignKey(column, refTableName, refColumnName)); this.Columns.Remove(column); }
public void SetPrimaryKey(DBColumn column, bool isIdentity, int seed, int currentValue, int step) { this.PrimaryKey = new DBPrimaryKey(column, isIdentity, seed, currentValue, step); this.Columns.Remove(column); }
protected virtual void FillFields(DBTable table) { OleDbDataReader rd = OleDbHelper.ExecuteReader(this.OleDbConnStr, string.Format(this.Format_GET_ALL_FIELDS, table.TableName)); List<DBColumn> fields = new List<DBColumn>(); while (rd.Read()) { try { DBColumn column = new DBColumn(rd["fieldName"].ToString()); string fieldType = rd["fieldType"].ToString(); if (this.DataBaseType == DataBaseType.MSSQL) { column.DbType = ((SqlDbType)Enum.Parse(typeof(SqlDbType), fieldType, true)).ToJFielType(); } else { column.DbType = ((OracleType)Enum.Parse(typeof(OracleType), fieldType, true)).ToJFielType(); } column.Length = int.Parse(rd["fieldLength"].ToString()); column.AllowNull = rd["allowNull"].ToString() == "1" ? true : false; fields.Add(column); } catch (Exception ex) { } } rd.Close(); rd.Dispose(); table.Columns = fields; }