Пример #1
0
 public IncidentBoxRow()
 {
     _state = DataRowState.Added;
     _IsDefault = false;
     _ControllerId = -1;
     _ManagerId = -1;
 }
Пример #2
0
        /// <summary> 批量更新板块数据
        /// </summary>
        /// <param name="dicData">[(代码,板块类型,板块名称), RecId]</param>
        /// <param name="operState"></param>
        private int BulkUpdateBlockData(List <KeyValuePair <string, int> > dicData, DataRowState operState)
        {
            string       tableName  = typeof(StockBlock).Name;
            const string idxStkCode = "StkCode",
                         idxBKType  = "BKType",
                         idxBKName  = "BKName";

            if (operState == DataRowState.Deleted)
            {
                int[] aRecId = dicData.Select(kv => kv.Value).ToArray();
                _dbo.DeleteTableByRecId(tableName, aRecId);
            }
            else
            {
                DataTable dt = _dbo.GetEmptyTable(tableName);
                foreach (KeyValuePair <string, int> keyValue in dicData)
                {
                    string[] aBlock = keyValue.Key.Split(',');

                    DataRow newRow = dt.NewRow();
                    newRow[idxStkCode] = aBlock[0];
                    newRow[idxBKType]  = aBlock[1];
                    newRow[idxBKName]  = aBlock[2];

                    dt.Rows.Add(newRow);
                }

                if (dt.Rows.Count > 0)
                {
                    _dbo.BulkWriteTable(dt, operState);
                }
            }

            return(dicData.Count);
        }
Пример #3
0
        public void Insert(DbConnection conn, string tableName, DataTable sourceData, Dictionary<string, string> columnMappings = null, DataRowState state = DataRowState.Added)
        {
            SqlConnection sqlConn = conn as SqlConnection;
            Check(conn);

            using (SqlBulkCopyWrapper sqlBC = new SqlBulkCopyWrapper(sqlConn))
            {
                sqlBC.BatchSize = 10000;
                sqlBC.BulkCopyTimeout = 600;
                sqlBC.DestinationTableName = tableName;
                if (columnMappings != null && columnMappings.Count > 0)
                {
                    foreach (var item in columnMappings)
                    {
                        sqlBC.ColumnMappings.Add(item.Value, item.Key);
                    }
                }
                else
                {
                    foreach (var item in sourceData.Columns.Cast<DataColumn>())
                    {
                        sqlBC.ColumnMappings.Add(item.ColumnName, item.ColumnName);
                    }

                }
                sqlBC.WriteToServer(sourceData, state);
            }
        }
Пример #4
0
        public static CResultAErreur VerifieUnicite(
            CContexteDonnee contexte,
            Type typeObjets,
            DataRowState states)
        {
            CResultAErreur           result     = CResultAErreur.True;
            DataTable                table      = contexte.Tables[CContexteDonnee.GetNomTableForType(typeObjets)];
            List <CInfoFiltreUnique> lstFiltres = GetFiltres(typeObjets);

            if (lstFiltres.Count == 0)
            {
                return(result);
            }
            if (table != null)
            {
                ArrayList lstCopie = new ArrayList(table.Rows);
                foreach (DataRow row in table.Rows)
                {
                    if ((row.RowState & states) != 0)
                    {
                        result = VerifieUnicite(row, lstFiltres, typeObjets);
                        if (!result)
                        {
                            return(result);
                        }
                    }
                }
            }
            return(result);
        }
Пример #5
0
        private void AlterarClick(object sender, EventArgs e)
        {
            if (tbl.Rows.Count > 0)
            {
                HabilitarClick(sender, e);
                stt = DataRowState.Modified;

                DataRow row = SelecionarRow();
                if (enumAbaAtual.Equals(EnumAbaAtual.CONTATOS))
                {
                    textBox1.Text = row.Field <string>("Nome");
                    textBox2.Text = row.Field <long>("Fone").ToString();
                    textBox3.Text = row.Field <string>("Endereco");
                }
                else if (enumAbaAtual.Equals(EnumAbaAtual.EVENTOS))
                {
                    textBox1.Text = row.Field <string>("Descrição");
                    textBox2.Text = row.Field <DateTime>("Data/Hora(dd/mm/aaaa HH:mm)").ToString();
                    textBox3.Text = row.Field <string>("Local");
                }
                else
                {
                    textBox1.Text = row.Field <string>("Texto");
                    textBox2.Text = row.Field <DateTime>("Data/Hora(dd/mm/aaaa HH:mm)").ToString();
                }
            }
            textBox1.Focus();
        }
Пример #6
0
        public BasePlanSlotRow()
        {
            _state = DataRowState.Added;


            _IsDefault = false;
        }
Пример #7
0
        /// <summary>
        /// 由资料行的FileType(文件类型)字段创建图标
        /// </summary>
        /// <param name="sourceRow">资料行</param>
        /// <param name="large">返回的大图标</param>
        /// <param name="small">返回的小图标</param>
        /// <param name="writeRow"></param>
        public static void CreateFileIcon(DataRow sourceRow, out Icon large, out Icon small, bool writeRow)
        {
            string fileType = sourceRow[tb_AttachFile.FileType].ToString();

            CreateFileIcon(fileType, out large, out small);

            if (writeRow)
            {
                DataRowState state = sourceRow.RowState;

                MemoryStream ms1 = new MemoryStream();
                large.ToBitmap().Save(ms1, ImageFormat.Bmp);
                sourceRow[tb_AttachFile.IconLarge] = ms1.ToArray();
                ms1.Close();

                MemoryStream ms2 = new MemoryStream();
                small.ToBitmap().Save(ms2, ImageFormat.Bmp);
                sourceRow[tb_AttachFile.IconSmall] = ms2.ToArray();
                ms2.Close();

                if (state == DataRowState.Unchanged)
                {
                    sourceRow.AcceptChanges();
                }
            }
        }
Пример #8
0
 /// <summary>
 /// Returns all the <see cref="DataRow"/> objects of the <see cref="DataTable"/> by state.
 /// </summary>
 /// <param name="dataTable">The instance of <see cref="DataTable"/> where the list of <see cref="DataRow"/> will be extracted.</param>
 /// <param name="rowState">The state of the <see cref="DataRow"/> objects to be extracted.</param>
 /// <returns>The list of <see cref="DataRow"/> objects.</returns>
 private IEnumerable <DataRow> GetDataRows(DataTable dataTable, DataRowState rowState)
 {
     foreach (var row in dataTable.Rows.OfType <DataRow>().Where(r => r.RowState == rowState))
     {
         yield return(row);
     }
 }
Пример #9
0
        /// <summary>
        /// 根据数据表创建参数列表
        /// </summary>
        /// <param name="tab">数据表</param>
        /// <returns>返回参数列表</returns>
        public static NameObjectList[] createParam(DataTable tab, DataRowState state)
        {
            if (null == tab || tab.Rows.Count < 1)
            {
                return(new NameObjectList[0]);
            }
            List <NameObjectList> psList = new List <NameObjectList>();
            DataView             dvsub   = new DataView(tab, "", "", DataViewRowState.ModifiedCurrent | DataViewRowState.Added | DataViewRowState.Deleted);
            DataColumnCollection cols    = tab.Columns;
            int len = cols.Count;

            for (int i = 0; i < dvsub.Count; i++)
            {
                if (state != dvsub[i].Row.RowState)
                {
                    continue;
                }
                DataRowView    drv = dvsub[i];
                NameObjectList ps  = new NameObjectList();
                for (int c = 0; c < len; c++)
                {
                    ps[cols[c].ColumnName] = drv[c];
                }
                psList.Add(ps);
            }
            return(psList.ToArray());
        }
Пример #10
0
        private void secToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!zmslGridView.IsDataRow(zmslGridView.FocusedRowHandle))
            {
                return;
            }

            if (ophLayoutView.RecordCount == 0)
            {
                ophLayoutView.AddNewRow();
            }

            // Kayit edildiyse uzerine Sec ile yazma yeni kayit ekle, ama manuel degistirebilir.
            DataRowState drs = ophLayoutView.GetFocusedDataRow().RowState;

            if (drs == DataRowState.Unchanged || drs == DataRowState.Modified)
            {
                ophLayoutView.AddNewRow();
            }

            ophLayoutView.SetFocusedRowCellValue(colB_PRTNO, zmslGridView.GetFocusedRowCellValue(colPROTOCOL));
            ophLayoutView.SetFocusedRowCellValue(colB_STUDYNO, zmslGridView.GetFocusedRowCellValue(colSTUDY));
            ophLayoutView.SetFocusedRowCellValue(colB_SITENO, zmslGridView.GetFocusedRowCellValue(colSITE));
            //ophLayoutView.SetFocusedRowCellValue(colB_SNDINFO, zmslGridView.GetFocusedRowCellValue(colPICKUPNAME));
            ophLayoutView.SetFocusedRowCellValue(colB_PUDPT, zmslGridView.GetFocusedRowCellValue(colPICKUPDEPARTMENT));

            ophLayoutView.SetFocusedRowCellValue(colDST, zmslGridView.GetFocusedRowCellValue(colCONSIGNEECOUNTRYCODE));
        }
Пример #11
0
        protected void Load(IDataReader reader)
        {
            _state = DataRowState.Unchanged;


            _ReplicaId = (Guid)SqlHelper.DBNull2Null(reader["ReplicaId"]);

            _PrincipalId = (Nullable <int>)SqlHelper.DBNull2Null(reader["PrincipalId"]);

            _TickCount = (int)SqlHelper.DBNull2Null(reader["TickCount"]);

            _ReplicaKeyMap = (string)SqlHelper.DBNull2Null(reader["ReplicaKeyMap"]);

            _CurrentKnowledge = (string)SqlHelper.DBNull2Null(reader["CurrentKnowledge"]);

            _ForgottenKnowledge = (string)SqlHelper.DBNull2Null(reader["ForgottenKnowledge"]);

            _ConflictLog = (string)SqlHelper.DBNull2Null(reader["ConflictLog"]);

            _TombstoneLog = (string)SqlHelper.DBNull2Null(reader["TombstoneLog"]);

            _LastDeletedItemsCleanupTime = (Nullable <DateTime>)SqlHelper.DBNull2Null(reader["LastDeletedItemsCleanupTime"]);


            OnLoad(reader);
        }
Пример #12
0
        public bool HasChanges(DataRowState rowStates)
        {
            if (((int)rowStates & 0xffffffe0) != 0)
            {
                throw new ArgumentOutOfRangeException("rowStates");
            }

            DataTableCollection tableCollection = Tables;
            DataTable           table;
            DataRowCollection   rowCollection;
            DataRow             row;

            for (int i = 0; i < tableCollection.Count; i++)
            {
                table         = tableCollection [i];
                rowCollection = table.Rows;
                for (int j = 0; j < rowCollection.Count; j++)
                {
                    row = rowCollection [j];
                    if ((row.RowState & rowStates) != 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #13
0
        public static DataTable GetDataByRowState(this DataTable dt, DataRowState state)
        {
            if (state == DataRowState.Deleted)
            {
                var dtNew = dt.Clone();

                foreach (DataRow row in dt.AsEnumerable().Where(row => row.RowState == state).ToList())
                {
                    var newRow = dtNew.NewRow();

                    foreach (DataColumn column in dt.Columns)
                    {
                        newRow[column.ColumnName] = row[column.ColumnName, DataRowVersion.Original];
                    }

                    dtNew.Rows.Add(newRow);
                }

                return(dtNew);
            }
            else
            {
                if (dt.AsEnumerable().Where(row => row.RowState == state).Any())
                {
                    return(dt.AsEnumerable().Where(row => row.RowState == state).CopyToDataTable());
                }
                else
                {
                    return(null);
                }
            }
        }
Пример #14
0
        /// <summary>
        /// Bulk insert an instance of <see cref="DataTable"/> object into the database.
        /// </summary>
        /// <param name="connection">The connection object to be used.</param>
        /// <param name="tableName">The target table for bulk-insert operation.</param>
        /// <param name="dataTable">The <see cref="DataTable"/> object to be used in the bulk-insert operation.</param>
        /// <param name="rowState">The state of the rows to be copied to the destination.</param>
        /// <param name="mappings">The list of the columns to be used for mappings. If this parameter is not set, then all columns will be used for mapping.</param>
        /// <param name="options">The bulk-copy options to be used.</param>
        /// <param name="bulkCopyTimeout">The timeout in seconds to be used.</param>
        /// <param name="batchSize">The size per batch to be used.</param>
        /// <param name="transaction">The transaction to be used.</param>
        /// <returns>The number of rows affected by the execution.</returns>
        public static int BulkInsert(this SqlConnection connection,
                                     string tableName,
                                     DataTable dataTable,
                                     DataRowState rowState = DataRowState.Unchanged,
                                     IEnumerable <BulkInsertMapItem> mappings = null,
                                     SqlBulkCopyOptions options = SqlBulkCopyOptions.Default,
                                     int?bulkCopyTimeout        = null,
                                     int?batchSize = null,
                                     SqlTransaction transaction = null)
        {
            // Variables for the operation
            var result = 0;

            // Before Execution Time
            var beforeExecutionTime = DateTime.UtcNow;

            // Actual execution
            result = BulkInsertInternal(connection: connection,
                                        tableName: tableName,
                                        dataTable: dataTable,
                                        rowState: rowState,
                                        mappings: mappings,
                                        options: options,
                                        bulkCopyTimeout: bulkCopyTimeout,
                                        batchSize: batchSize,
                                        transaction: transaction);

            // Return the result
            return(result);
        }
        public OutgoingEmailServiceConfigRow()
        {
            _state = DataRowState.Added;


            _ServiceKey = null;
        }
Пример #16
0
        public VCardRow()
        {
            _state = DataRowState.Added;

            _Birthday = DateTime.MinValue;
            _OrganizationId = -1;
        }
Пример #17
0
        protected void Load(IDataReader reader)
        {
            _state = DataRowState.Unchanged;


            _Id = (Guid)SqlHelper.DBNull2Null(reader["Id"]);

            _UniqueId = (Guid)SqlHelper.DBNull2Null(reader["UniqueId"]);

            _Prefix = (long)SqlHelper.DBNull2Null(reader["Prefix"]);

            _ReplicaId = (Guid)SqlHelper.DBNull2Null(reader["ReplicaId"]);

            _CurrentVersion = (string)SqlHelper.DBNull2Null(reader["CurrentVersion"]);

            _CreationVersion = (string)SqlHelper.DBNull2Null(reader["CreationVersion"]);

            _Uri = (Nullable <Guid>)SqlHelper.DBNull2Null(reader["Uri"]);

            _IsDeleted = (bool)SqlHelper.DBNull2Null(reader["IsDeleted"]);

            _Timestamp = (Nullable <long>)SqlHelper.DBNull2Null(reader["Timestamp"]);


            OnLoad(reader);
        }
Пример #18
0
        /// <summary>
        /// Open connection if it was closed.
        /// Necessary to workaround "connection must be open and valid" error
        /// with batched updates.
        /// </summary>
        /// <param name="state">Row state</param>
        /// <param name="openedConnections"> list of opened connections
        /// If connection is opened by this function, the list is updated
        /// </param>
        /// <returns>true if connection was opened</returns>
        private void OpenConnectionIfClosed(DataRowState state,
                                            List <MySqlConnection> openedConnections)
        {
            MySqlCommand cmd = null;

            switch (state)
            {
            case DataRowState.Added:
                cmd = InsertCommand;
                break;

            case DataRowState.Deleted:
                cmd = DeleteCommand;
                break;

            case DataRowState.Modified:
                cmd = UpdateCommand;
                break;

            default:
                return;
            }

            if (cmd != null && cmd.Connection != null &&
                cmd.Connection.connectionState == ConnectionState.Closed)
            {
                cmd.Connection.Open();
                openedConnections.Add(cmd.Connection);
            }
        }
Пример #19
0
        /// <summary>
        /// 指定したステータスの行を検索する
        /// </summary>
        /// <param name="rowState">行ステータス</param>
        /// <returns>指定したステータスの行</returns>
        /// <remarks>行ステータスは論理和演算で複数条件の指定が可能</remarks>
        public DTRows Find(DataRowState rowState)
        {
            DataRowState workState;     // 行ステータスの退避用

            // List型として、指定したステータスの行を取得する
            List <DTRow> listRow = this._rows.Where <DTRow>(row => (row.RowState & rowState) != 0).ToList <DTRow>();

            // List型⇒DTRows型に行をコピーする
            DTRows rows = new DTRows(this._tblStat, this._cols);

            foreach (DTRow row in listRow)
            {
                // 元の行ステータスを退避させる
                workState = row.RowState;

                // DTRowsに行を追加する
                rows.Add(row);

                // 行ステータスを元に戻す
                row.RowState = workState;
            }

            // 行リストを返す
            return(rows);
        }
Пример #20
0
        //// 新增带控制参数函数

        ///
        /// 检查给定的实体是否有给定状态的更改,如果有把更改的行提交到数据库。
        ///

        /// 要检验的实体
        /// 要检查更改的状态
        public void CommitIN_NAVIGATIONChanges(DataSetIN_NAVIGATION entity, DataRowState drs, ArrayList alUpdateColumn, ArrayList alUpdateControl)
        {
            using (IN_NAVIGATIONBaseDAO dao = new IN_NAVIGATIONBaseDAO())
            {
                dao.CommitChanges(entity, drs, alUpdateColumn, alUpdateControl);
            }
        }
Пример #21
0
        public void Update(DataRowState state, T item)
        {
            DataRow row;

            switch (state)
            {
            case DataRowState.Added:
                row = dt.NewRow();
                item.UpdateRow(row);
                dt.Rows.Add(row);
                break;

            case DataRowState.Modified:
                row = Find(item);
                if (row != null)
                {
                    item.UpdateRow(row);
                }
                break;

            case DataRowState.Deleted:
                row = Find(item);
                if (row != null)
                {
                    row.Delete();
                }
                break;
            }
        }
Пример #22
0
        ///
        /// 检查给定的实体是否有给定状态的更改,如果有把更改的行提交到数据库。
        ///

        /// 要检验的实体
        /// 要检查更改的状态
        public void CommitIN_NAVIGATIONChanges(DataSetIN_NAVIGATION entity, DataRowState drs)
        {
            using (IN_NAVIGATIONBaseDAO dao = new IN_NAVIGATIONBaseDAO())
            {
                dao.CommitChanges(entity, drs);
            }
        }
Пример #23
0
        /// <summary>
        /// 创建保存用的临时数据
        /// </summary>
        /// <param name="currentBusiness">业务数据(组,组的用户,组的权限,功能点的自定义名称)</param>
        /// <param name="lbAvailableUser"></param>
        /// <param name="lbSelectedUser"></param>
        /// <returns></returns>
        public DataSet CreateSaveData(DataSet currentBusiness, ListBox lbAvailableUser, ListBox lbSelectedUser)
        {
            DataSet      save  = new DataSet();
            DataRowState state = currentBusiness.Tables[BusinessDataSetIndex.Groups].Rows[0].RowState;

            currentBusiness.Tables[BusinessDataSetIndex.Groups].AcceptChanges();

            DataTable summary = currentBusiness.Tables[BusinessDataSetIndex.Groups].Copy();

            if (state == DataRowState.Added)
            {
                summary.Rows[0].SetAdded();
                _GroupID = Convert.ToInt32(BridgeFactory.CreateCommonServiceBridge().GetTableID(tb_sys_UserGroup.__TableName, tb_sys_UserGroup.__KeyName));
                summary.Rows[0][tb_sys_UserGroup.__KeyName] = _GroupID;
            }
            else if (state == DataRowState.Modified)
            {
                _GroupID = Convert.ToInt32(summary.Rows[0][tb_sys_UserGroup.__KeyName]);
                summary.Rows[0].SetModified();
            }
            DataTable auths = GetGroupAuthorityChanges(currentBusiness.Tables[BusinessDataSetIndex.GroupAuthorities]).Copy();
            DataTable user  = GetGroupUserChanges(currentBusiness, lbAvailableUser, lbSelectedUser);

            //DataTable tagNames = _FormTagCustomName.GetChanges();

            save.Tables.Add(summary);                                                                                       //用户组
            save.Tables.Add(user);                                                                                          //用户数据
            save.Tables.Add(auths == null ? currentBusiness.Tables[BusinessDataSetIndex.GroupAuthorities].Clone() : auths); //权限数据
            //save.Tables.Add(tagNames == null ? _FormTagCustomName.Clone() : tagNames); //功能点的自定义名称

            return(save);
        }
Пример #24
0
    private static void DisplayRowState(DataTable table)
    {
        for (int i = 0; i <= table.Rows.Count - 1; i++)
        {
            object       current  = "--";
            object       original = "--";
            DataRowState rowState = table.Rows[i].RowState;

            // Attempt to retrieve the current value, which doesn't exist
            // for deleted rows:
            if (rowState != DataRowState.Deleted)
            {
                current = table.Rows[i]["Name", DataRowVersion.Current];
            }

            // Attempt to retrieve the original value, which doesn't exist
            // for added rows:
            if (rowState != DataRowState.Added)
            {
                original = table.Rows[i]["Name", DataRowVersion.Original];
            }
            Console.WriteLine("{0}: {1}, {2} ({3})", i,
                              current, original, rowState);
        }
    }
Пример #25
0
        public VCardRow()
        {
            _state = DataRowState.Added;

            _Birthday       = DateTime.MinValue;
            _OrganizationId = -1;
        }
Пример #26
0
        private void OpenConnectionIfClosed(DataRowState state, List <MySqlConnection> openedConnections)
        {
            MySqlCommand mySqlCommand;

            if (state != DataRowState.Added)
            {
                if (state != DataRowState.Deleted)
                {
                    if (state != DataRowState.Modified)
                    {
                        return;
                    }
                    mySqlCommand = this.UpdateCommand;
                }
                else
                {
                    mySqlCommand = this.DeleteCommand;
                }
            }
            else
            {
                mySqlCommand = this.InsertCommand;
            }
            if (mySqlCommand != null && mySqlCommand.Connection != null && mySqlCommand.Connection.connectionState == ConnectionState.Closed)
            {
                mySqlCommand.Connection.Open();
                openedConnections.Add(mySqlCommand.Connection);
            }
        }
Пример #27
0
        protected void Load(IDataReader reader)
        {
            _state = DataRowState.Unchanged;


            _VCardId = (int)DBNull2Null(reader["VCardId"]);

            _FullName = (string)DBNull2Null(reader["FullName"]);

            _NickName = (string)DBNull2Null(reader["NickName"]);

            _Url = (string)DBNull2Null(reader["Url"]);

            _Birthday = (DateTime)DBNull2Null(reader["Birthday"], DateTime.MinValue);

            _Title = (string)DBNull2Null(reader["Title"]);

            _Role = (string)DBNull2Null(reader["Role"]);

            _Description = (string)DBNull2Null(reader["Description"]);

            _Gender = (string)DBNull2Null(reader["Gender"]);

            _OrganizationId = (int)DBNull2Null(reader["OrganizationId"], -1);
        }
Пример #28
0
        /// <summary>
        /// Copies only rows that match the supplied row state in the supplied <see cref="DataTable" /> to a destination table.
        /// </summary>
        /// <param name="table">A DataTable whose rows will be copied to the destination table.</param>
        /// <param name="rowState">A value from the DataRowState enumeration. Only rows matching the row state are copied to the destination.</param>
        public void WriteToServer(DataTable table, DataRowState rowState)
        {
            AssertDisposed();

            try
            {
                // resolve auto map
                if (_autoMap == true)
                {
                    foreach (DataColumn column in table.Columns)
                    {
                        Mapping(column.ColumnName, column.ColumnName);
                    }
                }

                _dataSession.EnsureConnection();

                using (var bulkCopy = Create())
                {
                    bulkCopy.WriteToServer(table, rowState);
                    bulkCopy.Close();
                }
            }
            finally
            {
                _dataSession.ReleaseConnection();
                Dispose();
            }
        }
Пример #29
0
 public TableChangesBatchApplyingArgs(SyncContext context, SyncTable changes, DataRowState state, DbCommand command, DbConnection connection, DbTransaction transaction)
     : base(context, connection, transaction)
 {
     this.State   = state;
     this.Command = command;
     this.Changes = changes;
 }
Пример #30
0
        public TBuilder From(DataTable dataTable, DataRowState dataRowState)
        {
            CommandRequest.DataTable    = dataTable;
            CommandRequest.DataRowState = dataRowState;

            return(this as TBuilder);
        }
Пример #31
0
        /// <summary>
        /// 创建保存用的临时数据
        /// </summary>
        /// <param name="currentBusiness">业务数据(组,组的用户,组的权限,功能点的自定义名称)</param>
        /// <param name="lbAvailableUser"></param>
        /// <param name="lbSelectedUser"></param>
        /// <returns></returns>
        public DataSet CreateSaveData(DataSet currentBusiness, ListBox lbAvailableUser, ListBox lbSelectedUser)
        {
            DataSet      save  = new DataSet();
            DataRowState state = currentBusiness.Tables[BusinessDataSetIndex.Groups].Rows[0].RowState;

            currentBusiness.Tables[BusinessDataSetIndex.Groups].AcceptChanges();
            DataTable summary = currentBusiness.Tables[BusinessDataSetIndex.Groups].Copy();

            if (state == DataRowState.Added)
            {
                summary.Rows[0].SetAdded();
            }
            else if (state == DataRowState.Modified)
            {
                summary.Rows[0].SetModified();
            }

            DataTable auths    = GetGroupAuthorityChanges(currentBusiness.Tables[BusinessDataSetIndex.GroupAuthorities]).Copy();
            DataTable user     = GetGroupUserChanges(currentBusiness, lbAvailableUser, lbSelectedUser);
            DataTable tagNames = _FormTagCustomName.GetChanges();

            save.Tables.Add(summary);                                                                                       //用户组
            save.Tables.Add(user);                                                                                          //用户数据
            save.Tables.Add(auths == null ? currentBusiness.Tables[BusinessDataSetIndex.GroupAuthorities].Clone() : auths); //权限数据
            save.Tables.Add(tagNames == null ? _FormTagCustomName.Clone() : tagNames);                                      //功能点的自定义名称

            return(save);
        }
Пример #32
0
        public DataSet GetChanges(DataRowState rowStates)
        {
            if (!HasChanges(rowStates))
            {
                return(null);
            }

            DataSet copySet = Clone();
            bool    prev    = copySet.EnforceConstraints;

            copySet.EnforceConstraints = false;

            Hashtable addedRows = new Hashtable();

            for (int i = 0; i < Tables.Count; i++)
            {
                DataTable origTable = Tables [i];
                DataTable copyTable = copySet.Tables[origTable.TableName];
                for (int j = 0; j < origTable.Rows.Count; j++)
                {
                    DataRow row = origTable.Rows [j];
                    if (!row.IsRowChanged(rowStates) || addedRows.Contains(row))
                    {
                        continue;
                    }
                    AddChangedRow(addedRows, copyTable, row);
                }
            }
            copySet.EnforceConstraints = prev;
            return(copySet);
        }
Пример #33
0
        /// <summary>
        /// Bulk insert an instance of <see cref="DbDataReader"/> object into the database in an asynchronous way.
        /// </summary>
        /// <param name="repository">The instance of <see cref="DbRepository{TDbConnection}"/> object.</param>
        /// <param name="tableName">The target table for bulk-insert operation.</param>
        /// <param name="dataTable">The <see cref="DataTable"/> object to be used in the bulk-insert operation.</param>
        /// <param name="rowState">The state of the rows to be copied to the destination.</param>
        /// <param name="mappings">The list of the columns to be used for mappings. If this parameter is not set, then all columns will be used for mapping.</param>
        /// <param name="options">The bulk-copy options to be used.</param>
        /// <param name="batchSize">The size per batch to be used.</param>
        /// <param name="transaction">The transaction to be used.</param>
        /// <returns>The number of rows affected by the execution.</returns>
        public static async Task <int> BulkInsertAsync(this DbRepository <SqlConnection> repository,
                                                       string tableName,
                                                       DataTable dataTable,
                                                       DataRowState rowState = DataRowState.Unchanged,
                                                       IEnumerable <BulkInsertMapItem> mappings = null,
                                                       SqlBulkCopyOptions options = SqlBulkCopyOptions.Default,
                                                       int?batchSize = null,
                                                       SqlTransaction transaction = null)
        {
            // Create a connection
            var connection = (transaction?.Connection ?? repository.CreateConnection());

            try
            {
                // Call the method
                return(await connection.BulkInsertAsync(tableName : tableName,
                                                        dataTable : dataTable,
                                                        rowState : rowState,
                                                        mappings : mappings,
                                                        options : options,
                                                        bulkCopyTimeout : repository.CommandTimeout,
                                                        batchSize : batchSize,
                                                        transaction : transaction));
            }
            catch
            {
                // Throw back the error
                throw;
            }
            finally
            {
                // Dispose the connection
                repository.DisposeConnectionForPerCall(connection, transaction);
            }
        }
Пример #34
0
        public ProjectSpreadSheetDataRow()
        {
            _state = DataRowState.Added;

            _Index = 0;

            _CellType = 1;
        }
Пример #35
0
        public SynchronizationMetadataRow()
        {
            _state = DataRowState.Added;

            _Uri = null;

            _Timestamp = null;
        }
Пример #36
0
        public EMailRouterPop3BoxActivityRow()
        {
            _state = DataRowState.Added;

            _IsActive = false;

            _TotalMessageCount = 0;
        }
Пример #37
0
        public EMailMessageLogSettingsRow()
        {
            _state = DataRowState.Added;

            _IsActive = false;

            _Period = 7;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connectionName"></param>
        /// <param name="dbTableName"></param>
        /// <param name="table"></param>
        /// <returns></returns>
        public static List<SqlCommandObject> GeneratorCommand(string connectionName, string dbTableName, DataTable table, DataRowState state)
        {
            if (connectionName.IsEmpty())
                throw new Exception("GeneratorCommand方法中的connectionName为空.");

            List<SqlCommandObject> cmds = new List<SqlCommandObject>();
            if (table.IsEmpty())
                return cmds;

            InsertCommandGenerator insertCommandGenerator = new InsertCommandGenerator();
            DeleteCommandGenerator deleteCommandGenerator = new DeleteCommandGenerator();
            UpdateCommandGenerator updateCommandGenerator = new UpdateCommandGenerator();

            SqlCommandObject cmd = null;
            if (table != null)
            {
                DataTable dtChanges = null;
                if (state == DataRowState.Unchanged)
                {
                    dtChanges = table.GetChanges();
                }
                else
                {
                    dtChanges = table.GetChanges(state);
                }

                if (dtChanges == null) return cmds;

                if (dbTableName.IsEmpty())
                    throw new Exception("GeneratorCommand方法中的tableName为空.");

                foreach (DataRow dr in dtChanges.Rows)
                {
                    switch (dr.RowState)
                    {
                        case DataRowState.Deleted:
                            cmd = deleteCommandGenerator.GenerateCommand(connectionName, dbTableName, dr);
                            break;
                        case DataRowState.Modified:
                            cmd = updateCommandGenerator.GenerateCommand(connectionName, dbTableName, dr);
                            break;
                        case DataRowState.Added:
                            cmd = insertCommandGenerator.GenerateCommand(connectionName, dbTableName, dr);
                            break;
                        default:
                            cmd = null;
                            break;
                    }
                    if (cmd != null)
                    {
                        cmds.Add(cmd);
                    }
                }
            }
            return cmds;
        }
Пример #39
0
        /// <summary>
        /// Overloaded constructor.
        /// </summary>
        /// <param name="key">An <see cref="System.Object"/> that 
        /// represents the primary identifier value for the 
        /// class.</param>
        protected Entity(Guid key)
        {
            _keyID = key;
            if (_keyID == Guid.Empty)
            {
                _keyID = Entity.NewKey();
            }

            _state = DataRowState.Unchanged;
        }
Пример #40
0
        public mcweb_ReportAceRow()
        {
            _state = DataRowState.Added;

            _Role = null;

            _PrincipalId = null;

            _Allow = false;
        }
Пример #41
0
        public EMailRouterPop3BoxRow()
        {
            _state = DataRowState.Added;

            _Port = 110;

            _IsInternal = false;

            _InternalEMailAddress = null;

            _UseSecureConnection = 0;
        }
Пример #42
0
        public SmtpBoxRow()
        {
            _state = DataRowState.Added;

            _Port = 25;

            _SecureConnection = 0;

            _Authenticate = false;

            _IsDefault = false;

            _Checked = false;
        }
Пример #43
0
        public SynchronizationReplicaRow()
        {
            _state = DataRowState.Added;

            _PrincipalId = null;

            _ReplicaKeyMap = null;

            _CurrentKnowledge = null;

            _ForgottenKnowledge = null;

            _ConflictLog = null;

            _TombstoneLog = null;

            _LastDeletedItemsCleanupTime = null;
        }
Пример #44
0
		public bool EnumRow(DataRowState RowState)
		{
			if (OnRowEnumed != null)
			{
				foreach (DataRow row in dt.Rows)
				{
					OnRowEnumed(row);
				}
				if (dt != null && dt.Rows.Count > 0)
				{
					return true;
				}
				else
				{
					return false;
				}
			}
			return false;
		}
Пример #45
0
        public ucImageCollection(StateCollection aIC)
        {
            pStatusBarText = string.Empty;

            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            _pnl = new Panel();
            _nav = new ucMoveNavigator();
            _txt = new TextBox();

            _nav.Location = new System.Drawing.Point(0, this.Height-_nav.Height);
            _txt.Location = new System.Drawing.Point(_nav.Width+10, _nav.Top);
            _txt.Width = Width - _txt.Left-10;
            _txt.BackColor = SystemColors.Control;
            _txt.TextAlign = HorizontalAlignment.Center;
            _pnl.Location = new System.Drawing.Point(5, 5);
            _pnl.Size = new System.Drawing.Size(this.Width-10, _nav.Top-10);

            _pnl.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
            _nav.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
            _txt.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;

            Controls.AddRange(new Control [] {_pnl, _nav, _txt});

            _pnl.Paint += new PaintEventHandler(_pnl_Paint);
            _nav.MoveNavigator += new EvH_MoveNavigator(_nav_MoveNavigator);
            _txt.TextChanged += new EventHandler(_txt_TextChanged);

            _nav.pMinValue = 1;
            pImageCollection = aIC;

            _isFill = true;
            _curImg = null;
            _curState = DataRowState.Unchanged;

            ResizeRedraw = true;

            _tw = new Twain();
            _tw.Init( this.Handle );
            _msgfilter = false;
        }
Пример #46
0
 /// <summary>
 /// 根据数据表创建参数列表
 /// </summary>
 /// <param name="tab">数据表</param>
 /// <returns>返回参数列表</returns>
 public static NameObjectList[] createParam(DataTable tab, DataRowState state)
 {
     if (null == tab || tab.Rows.Count < 1)
         return new NameObjectList[0];
     List<NameObjectList> psList = new List<NameObjectList>();
     DataView dvsub = new DataView(tab, "", "", DataViewRowState.ModifiedCurrent | DataViewRowState.Added | DataViewRowState.Deleted);
     DataColumnCollection cols = tab.Columns;
     int len = cols.Count;
     for (int i = 0; i < dvsub.Count; i++)
     {
         if (state != dvsub[i].Row.RowState)
             continue;
         DataRowView drv = dvsub[i];
         NameObjectList ps = new NameObjectList();
         for (int c = 0; c < len; c++)
             ps[cols[c].ColumnName] = drv[c];
         psList.Add(ps);
     }
     return psList.ToArray();
 }
Пример #47
0
		private void BulkCopyToServer (DataTable table, DataRowState state)
		{
			if (connection == null || connection.State == ConnectionState.Closed)
				throw new InvalidOperationException ("This method should not be called on a closed connection");
			if (_destinationTableName == null)
				throw new ArgumentNullException ("DestinationTableName");
			if (isLocalConnection && connection.State != ConnectionState.Open)
				connection.Open();
			
			if ((copyOptions & SqlBulkCopyOptions.KeepIdentity) == SqlBulkCopyOptions.KeepIdentity) {
				SqlCommand cmd = new SqlCommand ("set identity_insert " +
								 table.TableName + " on",
								 connection);
				cmd.ExecuteScalar ();
			}
			DataTable [] columnMetaDataTables = GetColumnMetaData ();
			DataTable colMetaData = columnMetaDataTables [0];
			DataTable tableCollations = columnMetaDataTables [1];

			if (_columnMappingCollection.Count > 0) {
				if (_columnMappingCollection [0].SourceOrdinal != -1)
					ordinalMapping = true;
				ValidateColumnMapping (table, tableCollations);
			}

			SqlCommand tmpCmd = new SqlCommand ();
			TdsBulkCopy blkCopy = new TdsBulkCopy ((Tds)connection.Tds);
			if (((Tds)connection.Tds).TdsVersion >= TdsVersion.tds70) {
				string statement = "insert bulk " + DestinationTableName + " (";
				statement += GenerateColumnMetaData (tmpCmd, colMetaData, tableCollations);
				statement += ")";
				
				#region Check requested options and add corresponding modifiers to the statement
				if ((copyOptions & insertModifiers) != SqlBulkCopyOptions.Default) {
					statement += " WITH (";
					bool commaRequired = false;
					
					if ((copyOptions & SqlBulkCopyOptions.CheckConstraints) == SqlBulkCopyOptions.CheckConstraints) {
						if (commaRequired)
							statement += ", ";
						statement += "CHECK_CONSTRAINTS";
						commaRequired = true;
					}
					
					if ((copyOptions & SqlBulkCopyOptions.TableLock) == SqlBulkCopyOptions.TableLock) {
						if (commaRequired)
							statement += ", ";
						statement += "TABLOCK";
						commaRequired = true;
					}
					
					if ((copyOptions & SqlBulkCopyOptions.KeepNulls) == SqlBulkCopyOptions.KeepNulls) {
						if (commaRequired)
							statement += ", ";
						statement += "KEEP_NULLS";
						commaRequired = true;
					}
					
					if ((copyOptions & SqlBulkCopyOptions.FireTriggers) == SqlBulkCopyOptions.FireTriggers) {
						if (commaRequired)
							statement += ", ";
						statement += "FIRE_TRIGGERS";
						commaRequired = true;
					}
					
					statement += ")";
				}
				#endregion Check requested options and add corresponding modifiers to the statement

				blkCopy.SendColumnMetaData (statement);
			}
			blkCopy.BulkCopyStart (tmpCmd.Parameters.MetaParameters);
			long noRowsCopied = 0;
			foreach (DataRow row in table.Rows) {
				if (row.RowState == DataRowState.Deleted)
					continue; // Don't copy the row that's in deleted state
				if (state != 0 && row.RowState != state)
					continue;
				bool isNewRow = true;
				int i = 0;
				foreach (SqlParameter param in tmpCmd.Parameters) {
					int size = 0;
					object rowToCopy = null;
					if (_columnMappingCollection.Count > 0) {
						if (ordinalMapping) {
							foreach (SqlBulkCopyColumnMapping mapping
								 in _columnMappingCollection) {
								if (mapping.DestinationOrdinal == i && param.Value == null) {
									rowToCopy = row [mapping.SourceOrdinal];
									SqlParameter parameter = new SqlParameter (mapping.SourceOrdinal.ToString (),
														   rowToCopy);
									if (param.MetaParameter.TypeName != parameter.MetaParameter.TypeName) {
										parameter.SqlDbType = param.SqlDbType;
										rowToCopy = parameter.Value = parameter.ConvertToFrameworkType (rowToCopy);
									}
									string colType = string.Format ("{0}", parameter.MetaParameter.TypeName);
									if (colType == "nvarchar" || colType == "ntext" || colType == "nchar") {
										if (row [i] != null && row [i] != DBNull.Value) {
											size = ((string) parameter.Value).Length;
											size <<= 1;
										}
									} else if (colType == "varchar" || colType == "text" || colType == "char") {
										if (row [i] != null && row [i] != DBNull.Value)
											size = ((string) parameter.Value).Length;
									} else {
										size = parameter.Size;
									}
									break;
								}
							}
						} else {
							foreach (SqlBulkCopyColumnMapping mapping
								 in _columnMappingCollection) {
								if (mapping.DestinationColumn == param.ParameterName) {
									rowToCopy = row [mapping.SourceColumn];
									SqlParameter parameter = new SqlParameter (mapping.SourceColumn, rowToCopy);
									if (param.MetaParameter.TypeName != parameter.MetaParameter.TypeName) {
										parameter.SqlDbType = param.SqlDbType;
										rowToCopy = parameter.Value = parameter.ConvertToFrameworkType (rowToCopy);
									}
									string colType = string.Format ("{0}", parameter.MetaParameter.TypeName);
									if (colType == "nvarchar" || colType == "ntext" || colType == "nchar") {
										if (row [mapping.SourceColumn] != null && row [mapping.SourceColumn] != DBNull.Value) {
											size = ((string) rowToCopy).Length;
											size <<= 1;
										}
									} else if (colType == "varchar" || colType == "text" || colType == "char") {
										if (row [mapping.SourceColumn] != null && row [mapping.SourceColumn] != DBNull.Value)
											size = ((string) rowToCopy).Length;
									} else {
										size = parameter.Size;
									}
									break;
								}
							}
						}
						i++;
					} else {
						rowToCopy = row [param.ParameterName];
						string colType = param.MetaParameter.TypeName;
						/*
						  If column type is SqlDbType.NVarChar the size of parameter is multiplied by 2
						  FIXME: Need to check for other types
						*/
						if (colType == "nvarchar" || colType == "ntext" || colType == "nchar") {
							size = ((string) row [param.ParameterName]).Length;
							size <<= 1;
						} else if (colType == "varchar" || colType == "text" || colType == "char") {
							size = ((string) row [param.ParameterName]).Length;
						} else {
							size = param.Size;
						}
					}
					if (rowToCopy == null)
						continue;

					blkCopy.BulkCopyData (rowToCopy, isNewRow, size, param.MetaParameter);
                    
					if (isNewRow)
						isNewRow = false;
				} // foreach (SqlParameter)
				if (_notifyAfter > 0) {
					noRowsCopied ++;
					if (noRowsCopied >= _notifyAfter) {
						RowsCopied (noRowsCopied);
						noRowsCopied = 0;
					}
				}
			} // foreach (DataRow)
			blkCopy.BulkCopyEnd ();
		}
Пример #48
0
    /// <summary>
    /// Open connection if it was closed.
    /// Necessary to workaround "connection must be open and valid" error
    /// with batched updates.
    /// </summary>
    /// <param name="state">Row state</param>
    /// <param name="openedConnections"> list of opened connections 
    /// If connection is opened by this function, the list is updated
    /// </param>
    /// <returns>true if connection was opened</returns>
    private void OpenConnectionIfClosed(DataRowState state,
      List<MySqlConnection> openedConnections)
    {
      MySqlCommand cmd = null;
      switch (state)
      {
        case DataRowState.Added:
          cmd = InsertCommand;
          break;
        case DataRowState.Deleted:
          cmd = DeleteCommand;
          break;
        case DataRowState.Modified:
          cmd = UpdateCommand;
          break;
        default:
          return;
      }

      if (cmd != null && cmd.Connection != null &&
        cmd.Connection.connectionState == ConnectionState.Closed)
      {
        cmd.Connection.Open();
        openedConnections.Add(cmd.Connection);
      }
    }
Пример #49
0
        /*
            Sets the two bits in the bitArray to represent the DataRowState.
            The 4 rowstates[Unchanged, Added, Modified, Deleted] are represented with 2 bits. The length of the BitArray will be twice the size of the number of rows.
            Serialozed rowstate format : [00]->UnChanged, [01]->Added, [10]->Modified, [11]->Deleted.
        */
        private void ConvertToSurrogateRowState(DataRowState rowState, int bitIndex)
        {
            Debug.Assert(_rowStates != null);
            Debug.Assert(_rowStates.Length > bitIndex);

            switch (rowState)
            {
                case DataRowState.Unchanged:
                    _rowStates[bitIndex] = false;
                    _rowStates[bitIndex + 1] = false;
                    break;
                case DataRowState.Added:
                    _rowStates[bitIndex] = false;
                    _rowStates[bitIndex + 1] = true;
                    break;
                case DataRowState.Modified:
                    _rowStates[bitIndex] = true;
                    _rowStates[bitIndex + 1] = false;
                    break;
                case DataRowState.Deleted:
                    _rowStates[bitIndex] = true;
                    _rowStates[bitIndex + 1] = true;
                    break;
                default:
                    throw new InvalidEnumArgumentException(String.Format("Unrecognized row state {0}", rowState));
            }
        }
Пример #50
0
 public void CI_MoveForward()
 {
     mIC.MoveForward();
     _nav.pPosition = mIC.pCurrentIndex+1;
     PicItem pic = mIC.pCurrentItem as PicItem;
     if (pic != null)
         _curState				= pic.pState;
 }
Пример #51
0
 private void _SetStatusCurrentImage()
 {
     if (_curState == DataRowState.Unchanged)
         _curState = DataRowState.Modified;
 }
        protected virtual void UpdateSearchIndexWithParentCategoryIdChanges(int id, int catalogNodeId, DataRowState action)
        {
            var referenceConverter = ServiceLocator.Current.GetInstance<ReferenceConverter>();
            var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();

            var catalogNode = CatalogContext.Current.GetCatalogNode(catalogNodeId);
            var parentCategoryLink = referenceConverter.GetContentLink(catalogNode.ID, CatalogContentType.CatalogNode);
            IContent parentCategory = null;
            try {
                parentCategory = contentLoader.Get<IContent>(parentCategoryLink, new LanguageSelector("no"));
            } catch(Exception) {
            }
            var parentCategoryName = parentCategory != null ? parentCategory.Name : "did not find the name";
            var parentCategoryId = parentCategoryLink.ID;

            IClient client = SearchClient.Instance;

            // find all languages in the index
            var results = client.Search<FindProduct>()
                .Filter(x => x.Id.Match(id))
                .StaticallyCacheFor(TimeSpan.FromMinutes(1))
                .GetResult();

            foreach (var product in results)
            {

                if (action == DataRowState.Deleted)
                {
                    var categoryIndex = product.ParentCategoryId.IndexOf(parentCategoryId);
                    if (categoryIndex > -1)
                    {
                        product.ParentCategoryId.RemoveAt(categoryIndex);
                        product.ParentCategoryName.RemoveAt(categoryIndex);

                        client.Index(product);
                    }
                }
                else if(!product.ParentCategoryId.Any(x => x == parentCategoryId))
                {
                    product.ParentCategoryId.Add(parentCategoryId);
                    product.ParentCategoryName.Add(parentCategoryName);

                    client.Index(product);
                }

            }
        }
Пример #53
0
		/// <summary>
		/// Gets a copy of the DataTable containing all
		/// changes made to it since it was last loaded, or
		/// since AcceptChanges was called, filtered by DataRowState.
		/// </summary>
		public DataTable GetChanges (DataRowState rowStates)
		{
			DataTable copyTable = null;

			foreach (DataRow row in Rows) {
				// The spec says relationship constraints may cause Unchanged parent rows to be included but
				// MS .NET 1.1 does not include Unchanged rows even if their child rows are changed.
				if (!row.IsRowChanged (rowStates))
					continue;
				if (copyTable == null)
					copyTable = Clone ();
				DataRow newRow = copyTable.NewNotInitializedRow ();
				// Don't check for ReadOnly, when cloning data to new uninitialized row.
				row.CopyValuesToRow (newRow, false);
				newRow.XmlRowID = row.XmlRowID;
				copyTable.Rows.AddInternal (newRow);
			}

			return copyTable;
		}
Пример #54
0
		private DataRow[] GetResultRows(DataTable dt,DataRowState State)
		{
			//get expected rows
			ArrayList al = new ArrayList();
			DataRowVersion drVer = DataRowVersion.Current;

			//From MSDN -	The row the default version for the current DataRowState.
			//				For a DataRowState value of Added, Modified or Current, 
			//				the default version is Current. 
			//				For a DataRowState of Deleted, the version is Original.
			//				For a DataRowState value of Detached, the version is Proposed.

			if (	((State & DataRowState.Added)		> 0)  
				| ((State & DataRowState.Modified)	> 0)  
				| ((State & DataRowState.Unchanged)	> 0) ) 
				drVer = DataRowVersion.Current;
			if ( (State & DataRowState.Deleted)		> 0
				| (State & DataRowState.Detached)	> 0 )  
				drVer = DataRowVersion.Original; 

			foreach (DataRow dr in dt.Rows )
			{
				if ( dr.HasVersion(drVer) 
					//&& ((int)dr["ParentId", drVer] == 1) 
					&& ((dr.RowState & State) > 0 ) 
					)
					al.Add(dr);
			}
			DataRow[] result = (DataRow[])al.ToArray((typeof(DataRow)));
			return result; 
		}
Пример #55
0
 public void Insert(string connectionString, string tableName, DataTable sourceData, Dictionary<string, string> columnMappings = null, DataRowState state = DataRowState.Added)
 {
     SqlConnection sqlConn = new SqlConnection(connectionString);
     Insert(sqlConn, tableName, sourceData, columnMappings, state);
 }
Пример #56
0
        private void _nav_MoveNavigator(object sender, EvA_MoveNavigator e)
        {
            PicItem pic = mIC.pCurrentItem as PicItem;
            if (pic != null)
            {
                pic.pImage	= pImage;
                pic.pText		= _txt.Text;
                pic.pState	= _curState;
            }

            switch (e.pDirection)
            {
                case eDirection.First:
                    mIC.GoFirst();
                    break;
                case eDirection.Last:
                    mIC.GoLast();
                    break;
                case eDirection.Next:
                    mIC.GoNext();
                    break;
                case eDirection.Prev:
                    mIC.GoPrev();
                    break;
                case eDirection.Position:
                    mIC.pCurrentIndex = e.pPosition - 1;
                    break;
            }

            pic = mIC.pCurrentItem as PicItem;
            if (pic != null)
            {
                pImage					= pic.pImage;
                _txt.Text				= pic.pText;
                _curState				= pic.pState;
            pStatusBarText = ImageTools.ImageInformation(pImage);
            }

            if (CollectionCurrentItemChange != null)
                CollectionCurrentItemChange(this, new EventArgs());
        }
Пример #57
0
		public void WriteToServer (DataTable table, DataRowState rowState)
		{
			BulkCopyToServer (table, rowState);
		}
Пример #58
0
 public void CI_New()
 {
     PicItem pic = new PicItem();
     pImage = pic.pImage;
     _txt.Text = pic.pText;
     mIC.Add(pic);
     _curState = pic.pState;
     _nav.pMaxValue = mIC.Count;
     _nav.pPosition = _nav.pMaxValue;
 }
Пример #59
0
        public DataTable GetChanges(DataRowState rowStates)
        {
            IntPtr hscp;
            Bid.ScopeEnter(out hscp, "<ds.DataTable.GetChanges|API> %d#, rowStates=%d{ds.DataRowState}\n", ObjectID, (int)rowStates);
            try {
                DataTable dtChanges = this.Clone();
                DataRow row = null;

                // check that rowStates is valid DataRowState
                Debug.Assert(Enum.GetUnderlyingType(typeof(DataRowState)) == typeof(Int32), "Invalid DataRowState type");

                for (int i = 0; i < Rows.Count; i++) {
                    row = Rows[i];
                    if ((row.RowState & rowStates) != 0)
                        dtChanges.ImportRow(row);
                }

                if (dtChanges.Rows.Count == 0)
                    return null;

                return dtChanges;
            }
            finally {
                Bid.ScopeLeave(ref hscp);
            }
        }
Пример #60
0
 /// <summary>
 ///     开始写入数据库
 /// </summary>
 /// <param name="srcDataTable">DataTable</param>
 /// <param name="rowState">行状态</param>
 public void StartWrite(DataTable srcDataTable, DataRowState rowState) {
     using (SqlBulkCopyObj) {
         SqlBulkCopyObj.WriteToServer(srcDataTable, rowState);
     }
 }