Esempio n. 1
0
        /// <summary>
        /// 克隆当前对象
        /// </summary>
        /// <returns>新映射对象</returns>
        public OPCClientDBFieldMapping Clone()
        {
            OPCClientDBFieldMapping newObj = new OPCClientDBFieldMapping();

            newObj.FieldName        = this.FieldName;
            newObj.SourceOPCItem    = this.SourceOPCItem;
            newObj.SourceCustom     = this.SourceCustom;
            newObj.DataType         = this.DataType;
            newObj.SeqName          = this.SeqName;
            newObj.AutoInc          = this.AutoInc;
            newObj.IsEntityIdentity = this.IsEntityIdentity;

            return(newObj);
        }
Esempio n. 2
0
        private void AddDBField()
        {
            OPCClientDBFieldMapping newMapping = new OPCClientDBFieldMapping();

            newMapping.FieldName        = string.Empty;
            newMapping.SourceOPCItem    = (int)OPCClientDBFieldMapping.EnumOPCItem.未设置;
            newMapping.SourceCustom     = string.Empty;
            newMapping.DataType         = (int)OPCClientDBFieldMapping.EnumDataType.CHAR;
            newMapping.SeqName          = string.Empty;
            newMapping.AutoInc          = (int)OPCClientDBFieldMapping.EnumAutoInc.NO;
            newMapping.IsEntityIdentity = (int)OPCClientDBFieldMapping.EnumIsEntityIdentity.NO;

            //克隆数据,直接插入数据赋值回去会报“索引-1没有值”错误
            List <OPCClientDBFieldMapping> dbFieldMappings =
                CloneFieldMappings((List <OPCClientDBFieldMapping>)dvgDBFieldMapping.DataSource);

            dbFieldMappings.Add(newMapping);
            //DataGridView必须这样更新数据
            dvgDBFieldMapping.DataSource = new List <OPCClientDBFieldMapping>();
            dvgDBFieldMapping.DataSource = dbFieldMappings;

            dvgDBFieldMapping.CurrentCell = dvgDBFieldMapping.Rows[dvgDBFieldMapping.Rows.Count - 1].Cells[0];
        }