Ejemplo n.º 1
0
        protected virtual void OnValidateAddColumn(InternalDataColumn dataColumn)
        {
            if (this.ChildItems.Where(item => item.LocalName == dataColumn.ColumnName).Any() == true)
            {
                throw new CremaDataException("{0} 은(는) 자식 테이블의 이름으로 사용되고 있으므로 사용할 수 없습니다.", dataColumn.ColumnName);
            }
            if (dataColumn.IsKey == true && this.Rows.Count > 0)
            {
                throw new CremaDataException("데이터가 있을때는 키로 설정된 열을 추가할 수 없습니다.");
            }
            if (dataColumn.AllowDBNull == false && this.Rows.Count > 0)
            {
                throw new CremaDataException("데이터가 있을때는 null값을 허용하지 않는 열을 추가할 수 없습니다.");
            }
            if (dataColumn.Unique == true && this.Rows.Count > 0)
            {
                throw new CremaDataException("데이터가 있을때는 고유 속성인 열을 추가할 수 없습니다.");
            }

            var dataType = dataColumn.CremaType;

            if (dataType != null && this.DataSet != null && dataType.DataSet != this.DataSet)
            {
                throw new CremaDataException("테이블이 DataSet에 속해있지 않기 때문에 타입 '{0}'을(를) 사용할 수 없습니다.", dataType);
            }
        }
Ejemplo n.º 2
0
        public void UpdateIndexInternal(InternalDataColumn dataColumn)
        {
            var query = from item in this.columnList
                        orderby item.Index
                        select item;

            var columns = query.ToList();

            if (dataColumn != null)
            {
                var index = dataColumn.Index;
                columns.Remove(dataColumn);
                columns.Insert(index, dataColumn);
            }
            var columnList = new List <InternalDataColumn>(columns.Count);

            for (var i = 0; i < columns.Count; i++)
            {
                var item = columns[i];
                if (item.Index != i)
                {
                    item.InternalIndex = i;
                    columnList.Add(item);
                }
                else if (item == dataColumn)
                {
                    columnList.Add(item);
                }
            }
            this.columnList.Clear();
            this.columnList.AddRange(columns);
        }
Ejemplo n.º 3
0
 public bool CanRemoveColumn(InternalDataColumn dataColumn)
 {
     if (this.TemplateNamespace != string.Empty)
     {
         return(false);
     }
     return(this.Columns.CanRemove(dataColumn));
 }
Ejemplo n.º 4
0
        private InternalDataColumn AddColumnInternal(string columnName)
        {
            var dataColumn = new InternalDataColumn()
            {
                InternalColumnName = columnName,
            };

            this.Columns.Add(dataColumn);
            return(dataColumn);
        }
Ejemplo n.º 5
0
        protected override void OnRowChanging(DataRowChangeEventArgs e)
        {
            if (this.RowEventStack.Any() == true)
            {
                if (this.RowEventStack.Peek() == e.Row)
                {
                    base.OnRowChanging(new InternalDataRowChangeEventArgs(e));
                }
                else
                {
                    base.OnRowChanging(e);
                }
            }
            else
            {
                var row = e.Row as InternalTemplateColumn;
                switch (e.Action)
                {
                case DataRowAction.Add:
                {
                    if (this.IsLoading == false)
                    {
                        CremaDataSet.ValidateName(row.ColumnName);
                    }

                    if (this.targetTable != null && this.IsDiffMode == false)
                    {
                        InternalDataSet.ValidateSetDataTypeName(this.targetTable.DataSet, row.DataTypeName);
                    }

                    if (e.Row is InternalTemplateColumn c && c.TargetColumn == null && this.targetTable != null)
                    {
                        var dataColumn = new InternalDataColumn()
                        {
                            ColumnName = c.ColumnName,

                            IsKey         = c.IsKey,
                            Unique        = c.Unique,
                            Comment       = c.Comment,
                            DefaultValue  = c.DefaultValue ?? (object)DBNull.Value,
                            AutoIncrement = c.AutoIncrement,
                            AllowDBNull   = c.AllowNull,
                            Tags          = c.Tags,
                            ReadOnly      = c.ReadOnly,
                        };
                        this.TargetTable.ValidateAddColumn(dataColumn);
                    }
                }
                break;
                }
                base.OnRowChanging(e);
            }
        }
Ejemplo n.º 6
0
        public static void SetForceField <T>(this DataRow row, InternalDataColumn column, T value, object editor)
        {
            if (column.Editor != null)
            {
                throw new ArgumentException();
            }

            try
            {
                column.Editor = editor;
                row.SetField(column, value);
            }
            finally
            {
                column.Editor = null;
            }
        }
Ejemplo n.º 7
0
 public void AttachTarget(InternalDataColumn targetColumn)
 {
     this.ColumnID         = targetColumn.ColumnID;
     this.IsKey            = targetColumn.IsKey;
     this.Unique           = targetColumn.Unique;
     this.ColumnName       = targetColumn.ColumnName;
     this.DataTypeName     = targetColumn.DataTypeName;
     this.DefaultValue     = targetColumn.DefaultValue;
     this.AutoIncrement    = targetColumn.AutoIncrement;
     this.AllowNull        = targetColumn.AllowDBNull;
     this.ReadOnly         = targetColumn.ReadOnly;
     this.Comment          = targetColumn.Comment;
     this.Tags             = targetColumn.Tags;
     this.CreationInfo     = targetColumn.CreationInfo;
     this.ModificationInfo = targetColumn.ModificationInfo;
     this.targetColumn     = targetColumn;
 }
Ejemplo n.º 8
0
 public void CopyTo(InternalDataColumn dest)
 {
     dest.InternalAllowDBNull      = this.InternalAllowDBNull;
     dest.InternalAutoIncrement    = this.InternalAutoIncrement;
     dest.InternalColumnName       = this.InternalColumnName;
     dest.InternalDataType         = this.InternalDataType;
     dest.InternalCremaType        = this.InternalCremaType;
     dest.InternalDefaultValue     = this.InternalDefaultValue;
     dest.InternalExpression       = this.InternalExpression;
     dest.InternalValidation       = this.InternalValidation;
     dest.InternalUnique           = this.InternalUnique;
     dest.InternalReadOnly         = this.InternalReadOnly;
     dest.InternalComment          = this.InternalComment;
     dest.InternalIsKey            = this.InternalIsKey;
     dest.InternalCreationInfo     = this.InternalCreationInfo;
     dest.InternalModificationInfo = this.InternalModificationInfo;
     dest.InternalTags             = this.InternalTags;
     dest.InternalColumnID         = this.InternalColumnID;
 }
Ejemplo n.º 9
0
 protected virtual void OnValidateRemoveColumn(InternalDataColumn dataColumn)
 {
     if (dataColumn == null)
     {
         throw new ArgumentNullException(nameof(dataColumn));
     }
     if (this.Columns.IndexOf(dataColumn) < 0)
     {
         throw new InvalidOperationException("이 테이블에 속하지 않는 열은 제거할 수 없습니다.");
     }
     if (dataColumn.IsKey == true)
     {
         throw new InvalidOperationException("이 열은 기본 키의 일부이므로 제거할 수 없습니다.'");
     }
     if (dataColumn.Unique == true)
     {
         throw new InvalidOperationException("이 열은  테이블에서 Constraint1 제약 조건의 일부이므로 제거할 수 없습니다.'");
     }
 }
Ejemplo n.º 10
0
        public void RemoveColumn(InternalDataColumn dataColumn)
        {
            this.ValidateRemoveColumn(dataColumn);
            var signatureDate = this.Sign();

            if (this.OmitSignatureDate == false)
            {
                this.InternalModificationInfo = signatureDate;
            }
            this.RemoveColumnInternal(dataColumn);
            foreach (var item in this.DerivedItems.ToArray())
            {
                item.RemoveColumnInternal(dataColumn.ColumnName);
                if (item.OmitSignatureDate == false)
                {
                    item.InternalModificationInfo = signatureDate;
                }
            }
        }
Ejemplo n.º 11
0
        public void AddColumn(InternalDataColumn dataColumn)
        {
            this.ValidateAddColumn(dataColumn);
            var signatureDate = this.Sign();

            this.AddColumnInternal(dataColumn);
            if (this.OmitSignatureDate == false)
            {
                this.InternalModificationInfo = signatureDate;
            }
            foreach (var item in this.DerivedItems.ToArray())
            {
                var derivedColumn = new InternalDataColumn();
                dataColumn.CopyTo(derivedColumn);
                item.AddColumnInternal(derivedColumn);
                if (item.OmitSignatureDate == false)
                {
                    item.InternalModificationInfo = signatureDate;
                }
            }
        }
Ejemplo n.º 12
0
        private InternalDataColumn AddColumnInternal(ColumnInfo columnInfo)
        {
            var dataColumn = new InternalDataColumn()
            {
                InternalColumnName    = columnInfo.Name,
                InternalColumnID      = columnInfo.ID,
                InternalIsKey         = columnInfo.IsKey,
                InternalAllowDBNull   = columnInfo.AllowNull,
                InternalTags          = columnInfo.Tags,
                InternalDefaultValue  = columnInfo.DefaultValue == null ? DBNull.Value : (object)columnInfo.DefaultValue,
                InternalUnique        = columnInfo.IsUnique,
                InternalComment       = columnInfo.Comment,
                InternalReadOnly      = columnInfo.ReadOnly,
                InternalAutoIncrement = columnInfo.AutoIncrement,
            };

            this.Columns.Add(dataColumn);

            dataColumn.InternalDataTypeName     = columnInfo.DataType;
            dataColumn.InternalCreationInfo     = columnInfo.CreationInfo;
            dataColumn.InternalModificationInfo = columnInfo.ModificationInfo;

            return(dataColumn);
        }
Ejemplo n.º 13
0
 internal CremaDataColumn(InternalDataColumn dataColumn)
 {
     this.column = dataColumn;
 }
Ejemplo n.º 14
0
 private void RemoveColumnInternal(InternalDataColumn dataColumn)
 {
     this.Columns.Remove(dataColumn);
 }
Ejemplo n.º 15
0
 internal static T Field <T>(this CremaDataRow row, InternalDataColumn column)
 {
     return(row.InternalObject.Field <T>(column));
 }
Ejemplo n.º 16
0
 private void AddColumnInternal(InternalDataColumn dataColumn)
 {
     this.Columns.Add(dataColumn);
 }
 internal CremaDataColumnChangeEventArgs(DataColumnChangeEventArgs e)
 {
     this.dataRow       = e.Row as InternalDataRow;
     this.dataColumn    = e.Column as InternalDataColumn;
     this.proposedValue = e.ProposedValue;
 }
Ejemplo n.º 18
0
 public void ValidateRemoveColumn(InternalDataColumn dataColumn)
 {
     this.ValidateInvoke(nameof(this.RemoveColumn));
     this.OnValidateRemoveColumn(dataColumn);
 }
Ejemplo n.º 19
0
        protected override void OnRowChanged(DataRowChangeEventArgs e)
        {
            //if (this.updateIndex == true && this.RowChangedStack == 0)
            //{
            //    this.UpdateIndex(e.Row);
            //    this.updateIndex = false;
            //}

            if (this.RowEventStack.Any() == false)
            {
                base.OnRowChanged(e);
                if (e.Action == DataRowAction.Add)
                {
                    if (e.Row is InternalTemplateColumn c && c.TargetColumn == null && this.targetTable != null)
                    {
                        var dataColumn = new InternalDataColumn()
                        {
                            ColumnName = c.ColumnName,

                            IsKey         = c.IsKey,
                            Unique        = c.Unique,
                            Comment       = c.Comment,
                            DefaultValue  = c.DefaultValue ?? (object)DBNull.Value,
                            AutoIncrement = c.AutoIncrement,
                            AllowDBNull   = c.AllowNull,
                            Tags          = c.Tags,
                            ReadOnly      = c.ReadOnly,
                        };

                        this.TargetTable.AddColumn(dataColumn);
                        dataColumn.DataTypeName     = c.DataTypeName;
                        dataColumn.CreationInfo     = c.CreationInfo;
                        dataColumn.ModificationInfo = c.ModificationInfo;
                        c.TargetColumn = dataColumn;
                        //c.TargetColumn.CreationInfo = c.CreationInfo;
                        this.UpdateRow(e.Row);
                    }
                    //this.UpdateIsUnique();
                }
                else if (e.Action == DataRowAction.Change)
                {
                    if (e.Row is InternalTemplateColumn c && this.IsDiffMode == false)
                    {
                        c.TargetColumn.Index            = c.Index;
                        c.TargetColumn.ModificationInfo = c.ModificationInfo;
                    }
                    if (this.IsDiffMode == false)
                    {
                        this.UpdateRow(e.Row);
                    }
                }

                if (this.IsLoading == false)
                {
                    this.columnColumnName.DefaultValue = this.GenerateColumnName();
                    this.columnID.DefaultValue         = Guid.NewGuid();
                }
                //this.columnIndex.DefaultValue = this.GenerateMemberIndex();
            }
            else
            {
                base.OnRowChanged(new InternalDataRowChangeEventArgs(e));
            }
        }
Ejemplo n.º 20
0
 public CremaDataColumn(string columnName, CremaDataType dataType)
 {
     this.column = new InternalDataColumn(this, columnName, (InternalDataType)dataType);
 }
Ejemplo n.º 21
0
 public void SetNull(InternalDataColumn column)
 {
     base.SetNull(column);
 }