Inheritance: System.EventArgs
Exemplo n.º 1
0
			protected override void OnRowUpdating (RowUpdatingEventArgs value)
			{
				throw new NotImplementedException ();
			}
Exemplo n.º 2
0
    /// <summary>
    /// Raised by the underlying DbDataAdapter when a row is being updated
    /// </summary>
    /// <param name="value">The event's specifics</param>
    protected override void OnRowUpdating(RowUpdatingEventArgs value)
    {
      EventHandler<RowUpdatingEventArgs> handler = base.Events[_updatingEventPH] as EventHandler<RowUpdatingEventArgs>;

      if (handler != null)
        handler(this, value);
    }
		private void RowUpdatingHandler (object sender, RowUpdatingEventArgs args)
                {
                        if (args.Command != null)
                                return;
                        try {
                                switch (args.StatementType) {
                                case StatementType.Insert:
                                        args.Command = GetInsertCommand ();
                                        break;
                                case StatementType.Update:
                                        args.Command = GetUpdateCommand ();
                                        break;
                                case StatementType.Delete:
                                        args.Command = GetDeleteCommand ();
                                        break;
                                }
                        } catch (Exception e) {
                                args.Errors = e;
                                args.Status = UpdateStatus.ErrorsOccurred;
                        }
                }
Exemplo n.º 4
0
 /// <summary>
 /// Overridden. Raises the RowUpdating event.
 /// </summary>
 /// <param name="value">A MySqlRowUpdatingEventArgs that contains the event data.</param>
 override protected void OnRowUpdating(RowUpdatingEventArgs value)
 {
   if (RowUpdating != null)
     RowUpdating(this, (value as MySqlRowUpdatingEventArgs));
 }
Exemplo n.º 5
0
		protected override void OnRowUpdating(RowUpdatingEventArgs value) {
			if (this.RowUpdating != null) {
				this.RowUpdating(this, value as MySqlRowUpdatingEventArgs);
			}
		}
Exemplo n.º 6
0
 protected override void OnRowUpdating(RowUpdatingEventArgs value)
 {
     var handler = Events[updatingEventKey] as EventHandler<RowUpdatingEventArgs>;
     if (handler != null)
         handler(this, value);
 }
        protected void RowUpdatingHandler(RowUpdatingEventArgs rowUpdatingEvent)
        {
            if (rowUpdatingEvent == null)
            {
                throw ADP.ArgumentNull("rowUpdatingEvent");
            }
            try
            {
                if (rowUpdatingEvent.Status == UpdateStatus.Continue)
                {
                    StatementType statementType = rowUpdatingEvent.StatementType;
                    DbCommand insertCommand = (DbCommand) rowUpdatingEvent.Command;
                    if (insertCommand != null)
                    {
                        switch (statementType)
                        {
                            case StatementType.Select:
                                return;

                            case StatementType.Insert:
                                insertCommand = this.InsertCommand;
                                break;

                            case StatementType.Update:
                                insertCommand = this.UpdateCommand;
                                break;

                            case StatementType.Delete:
                                insertCommand = this.DeleteCommand;
                                break;

                            default:
                                throw ADP.InvalidStatementType(statementType);
                        }
                        if (insertCommand != rowUpdatingEvent.Command)
                        {
                            insertCommand = (DbCommand) rowUpdatingEvent.Command;
                            if ((insertCommand != null) && (insertCommand.Connection == null))
                            {
                                DbDataAdapter dataAdapter = this.DataAdapter;
                                DbCommand command2 = (dataAdapter != null) ? dataAdapter.SelectCommand : null;
                                if (command2 != null)
                                {
                                    insertCommand.Connection = command2.Connection;
                                }
                            }
                        }
                        else
                        {
                            insertCommand = null;
                        }
                    }
                    if (insertCommand == null)
                    {
                        this.RowUpdatingHandlerBuilder(rowUpdatingEvent);
                    }
                }
            }
            catch (Exception exception)
            {
                if (!ADP.IsCatchableExceptionType(exception))
                {
                    throw;
                }
                ADP.TraceExceptionForCapture(exception);
                rowUpdatingEvent.Status = UpdateStatus.ErrorsOccurred;
                rowUpdatingEvent.Errors = exception;
            }
        }
Exemplo n.º 8
0
 protected virtual void OnRowUpdating(RowUpdatingEventArgs value)
 {
 }
		protected void RowUpdatingHandler (object sender, RowUpdatingEventArgs rowUpdatingEvent)
		{
			throw new NotImplementedException ();
		}
Exemplo n.º 10
0
 protected override void OnRowUpdating(
 RowUpdatingEventArgs value)
 {
 }
Exemplo n.º 11
0
 /// <summary>
 ///   Raises the RowUpdating event of a .NET Framework data provider.
 /// </summary>
 /// <param name="value"> An <see cref="T:System.Data.Common.RowUpdatingEventArgs" /> that contains the event data. </param>
 protected override void OnRowUpdating(RowUpdatingEventArgs value)
 {
   if (RowUpdating != null)
     RowUpdating(this, (value as CUBRIDRowUpdatingEventArgs));
 }
Exemplo n.º 12
0
		protected virtual void OnRowUpdating (RowUpdatingEventArgs value)
		{
			if (Events ["RowUpdating"] != null) {
				Delegate [] rowUpdatingList = Events ["RowUpdating"].GetInvocationList ();
				foreach (Delegate rowUpdating in rowUpdatingList) {
					MethodInfo rowUpdatingMethod = rowUpdating.Method;
					rowUpdatingMethod.Invoke (value, null);
				}
			}
		}
Exemplo n.º 13
0
		protected abstract void OnRowUpdating (RowUpdatingEventArgs value);
Exemplo n.º 14
0
		/// <summary>
		/// Raises the RowUpdated event of a Sqlite data provider.
		/// </summary>
		/// <param name="args">A RowUpdatedEventArgs that contains the event data.</param>
		protected override void OnRowUpdating (RowUpdatingEventArgs args)
		{
			if (RowUpdating != null)
				RowUpdating(this, args);
		}
        private void RowUpdatingHandlerBuilder(RowUpdatingEventArgs rowUpdatingEvent)
        {
            DbCommand command;
            DataRow dataRow = rowUpdatingEvent.Row;
            this.BuildCache(false, dataRow, false);
            switch (rowUpdatingEvent.StatementType)
            {
                case StatementType.Insert:
                    command = this.BuildInsertCommand(rowUpdatingEvent.TableMapping, dataRow);
                    break;

                case StatementType.Update:
                    command = this.BuildUpdateCommand(rowUpdatingEvent.TableMapping, dataRow);
                    break;

                case StatementType.Delete:
                    command = this.BuildDeleteCommand(rowUpdatingEvent.TableMapping, dataRow);
                    break;

                default:
                    throw ADP.InvalidStatementType(rowUpdatingEvent.StatementType);
            }
            if (command == null)
            {
                if (dataRow != null)
                {
                    dataRow.AcceptChanges();
                }
                rowUpdatingEvent.Status = UpdateStatus.SkipCurrentRow;
            }
            rowUpdatingEvent.Command = command;
        }
Exemplo n.º 16
0
        protected virtual int Update(DataRow [] dataRows, DataTableMapping tableMapping)
        {
            int updateCount = 0;

            foreach (DataRow row in dataRows)
            {
                StatementType statementType = StatementType.Update;
                IDbCommand    command       = null;
                string        commandName   = String.Empty;

                switch (row.RowState)
                {
                case DataRowState.Added:
                    statementType = StatementType.Insert;
                    command       = ((IDbDataAdapter)this).InsertCommand;
                    commandName   = "Insert";
                    break;

                case DataRowState.Deleted:
                    statementType = StatementType.Delete;
                    command       = ((IDbDataAdapter)this).DeleteCommand;
                    commandName   = "Delete";
                    break;

                case DataRowState.Modified:
                    statementType = StatementType.Update;
                    command       = ((IDbDataAdapter)this).UpdateCommand;
                    commandName   = "Update";
                    break;

                case DataRowState.Unchanged:
                case DataRowState.Detached:
                    continue;
                }

                RowUpdatingEventArgs argsUpdating = CreateRowUpdatingEvent(row, command, statementType, tableMapping);
                row.RowError = null;
                OnRowUpdating(argsUpdating);
                switch (argsUpdating.Status)
                {
                case UpdateStatus.Continue:
                    //continue in update operation
                    break;

                case UpdateStatus.ErrorsOccurred:
                    if (argsUpdating.Errors == null)
                    {
                        argsUpdating.Errors = ExceptionHelper.RowUpdatedError();
                    }
                    row.RowError += argsUpdating.Errors.Message;
                    if (!ContinueUpdateOnError)
                    {
                        throw argsUpdating.Errors;
                    }
                    continue;

                case UpdateStatus.SkipAllRemainingRows:
                    return(updateCount);

                case UpdateStatus.SkipCurrentRow:
                    updateCount++;
                    continue;

                default:
                    throw ExceptionHelper.InvalidUpdateStatus(argsUpdating.Status);
                }
                command = argsUpdating.Command;
                try {
                    if (command != null)
                    {
                        DataColumnMappingCollection columnMappings = tableMapping.ColumnMappings;
#if ONLY_1_1
                        IDataParameter nullCheckParam = null;
#endif
                        foreach (IDataParameter parameter in command.Parameters)
                        {
                            if ((parameter.Direction & ParameterDirection.Input) == 0)
                            {
                                continue;
                            }

                            DataRowVersion rowVersion = parameter.SourceVersion;
                            // Parameter version is ignored for non-update commands
                            if (statementType == StatementType.Delete)
                            {
                                rowVersion = DataRowVersion.Original;
                            }

                            string dsColumnName = parameter.SourceColumn;
#if NET_2_0
                            if (columnMappings.Contains(dsColumnName))
                            {
                                dsColumnName    = columnMappings [dsColumnName].DataSetColumn;
                                parameter.Value = row [dsColumnName, rowVersion];
                            }
                            else
                            {
                                parameter.Value = null;
                            }

                            DbParameter nullCheckParam = parameter as DbParameter;
#else
                            if (columnMappings.Contains(dsColumnName))
                            {
                                dsColumnName = columnMappings [dsColumnName].DataSetColumn;
                            }
                            if (dsColumnName == null || dsColumnName.Length == 0)
                            {
                                nullCheckParam = parameter;
                                continue;
                            }
                            parameter.Value = row [dsColumnName, rowVersion];
#endif

#if NET_2_0
                            if (nullCheckParam != null && nullCheckParam.SourceColumnNullMapping)
                            {
#else
                            if (nullCheckParam != null)
                            {
#endif
                                if (parameter.Value != null && parameter.Value != DBNull.Value)
                                {
                                    nullCheckParam.Value = 0;
                                }
                                else
                                {
                                    nullCheckParam.Value = 1;
                                }
                                nullCheckParam = null;
                            }
                        }
                    }
                } catch (Exception e) {
                    argsUpdating.Errors = e;
                    argsUpdating.Status = UpdateStatus.ErrorsOccurred;
                }

                IDataReader reader = null;
                try {
                    if (command == null)
                    {
                        throw ExceptionHelper.UpdateRequiresCommand(commandName);
                    }

                    CommandBehavior commandBehavior = CommandBehavior.Default;
                    if (command.Connection.State == ConnectionState.Closed)
                    {
                        command.Connection.Open();
                        commandBehavior |= CommandBehavior.CloseConnection;
                    }

                    // use ExecuteReader because we want to use the commandbehavior parameter.
                    // so the connection will be closed if needed.
                    reader = command.ExecuteReader(commandBehavior);

                    // update the current row, if the update command returns any resultset
                    // ignore other than the first record.
                    DataColumnMappingCollection columnMappings = tableMapping.ColumnMappings;

                    if (command.UpdatedRowSource == UpdateRowSource.Both ||
                        command.UpdatedRowSource == UpdateRowSource.FirstReturnedRecord)
                    {
                        if (reader.Read())
                        {
                            DataTable retSchema = reader.GetSchemaTable();
                            foreach (DataRow dr in retSchema.Rows)
                            {
                                string columnName    = dr ["ColumnName"].ToString();
                                string dstColumnName = columnName;
                                if (columnMappings != null &&
                                    columnMappings.Contains(columnName))
                                {
                                    dstColumnName = columnMappings [dstColumnName].DataSetColumn;
                                }
                                DataColumn dstColumn = row.Table.Columns [dstColumnName];
                                if (dstColumn == null ||
                                    (dstColumn.Expression != null &&
                                     dstColumn.Expression.Length > 0))
                                {
                                    continue;
                                }
                                // info from : http://www.error-bank.com/microsoft.public.dotnet.framework.windowsforms.databinding/
                                // [email protected]_Thread.aspx
                                // disable readonly for non-expression columns.
                                bool readOnlyState = dstColumn.ReadOnly;
                                dstColumn.ReadOnly = false;
                                try {
                                    row [dstColumnName] = reader [columnName];
                                } finally {
                                    dstColumn.ReadOnly = readOnlyState;
                                }
                            }
                        }
                    }
                    reader.Close();

                    int tmp = reader.RecordsAffected;                     // records affected is valid only after closing reader
                    // if the execute does not effect any rows we throw an exception.
                    if (tmp == 0)
                    {
                        throw new DBConcurrencyException("Concurrency violation: the " +
                                                         commandName + "Command affected 0 records.", null,
                                                         new DataRow [] { row });
                    }
                    updateCount += tmp;

                    if (command.UpdatedRowSource == UpdateRowSource.Both ||
                        command.UpdatedRowSource == UpdateRowSource.OutputParameters)
                    {
                        // Update output parameters to row values
                        foreach (IDataParameter parameter in command.Parameters)
                        {
                            if (parameter.Direction != ParameterDirection.InputOutput &&
                                parameter.Direction != ParameterDirection.Output &&
                                parameter.Direction != ParameterDirection.ReturnValue)
                            {
                                continue;
                            }

                            string dsColumnName = parameter.SourceColumn;
                            if (columnMappings != null &&
                                columnMappings.Contains(parameter.SourceColumn))
                            {
                                dsColumnName = columnMappings [parameter.SourceColumn].DataSetColumn;
                            }
                            DataColumn dstColumn = row.Table.Columns [dsColumnName];
                            if (dstColumn == null ||
                                (dstColumn.Expression != null &&
                                 dstColumn.Expression.Length > 0))
                            {
                                continue;
                            }
                            bool readOnlyState = dstColumn.ReadOnly;
                            dstColumn.ReadOnly = false;
                            try {
                                row [dsColumnName] = parameter.Value;
                            } finally {
                                dstColumn.ReadOnly = readOnlyState;
                            }
                        }
                    }

                    RowUpdatedEventArgs updatedArgs = CreateRowUpdatedEvent(row, command, statementType, tableMapping);
                    OnRowUpdated(updatedArgs);
                    switch (updatedArgs.Status)
                    {
                    case UpdateStatus.Continue:
                        break;

                    case UpdateStatus.ErrorsOccurred:
                        if (updatedArgs.Errors == null)
                        {
                            updatedArgs.Errors = ExceptionHelper.RowUpdatedError();
                        }
                        row.RowError += updatedArgs.Errors.Message;
                        if (!ContinueUpdateOnError)
                        {
                            throw updatedArgs.Errors;
                        }
                        break;

                    case UpdateStatus.SkipCurrentRow:
                        continue;

                    case UpdateStatus.SkipAllRemainingRows:
                        return(updateCount);
                    }
#if NET_2_0
                    if (!AcceptChangesDuringUpdate)
                    {
                        continue;
                    }
#endif
                    row.AcceptChanges();
                } catch (Exception e) {
                    row.RowError = e.Message;
                    if (!ContinueUpdateOnError)
                    {
                        throw e;
                    }
                } finally {
                    if (reader != null && !reader.IsClosed)
                    {
                        reader.Close();
                    }
                }
            }
            return(updateCount);
        }
Exemplo n.º 17
0
        protected void RowUpdatingHandler(RowUpdatingEventArgs rowUpdatingEvent) {
            if (null == rowUpdatingEvent) {
                throw ADP.ArgumentNull("rowUpdatingEvent");
            }
            try {
                if (UpdateStatus.Continue == rowUpdatingEvent.Status) {
                    StatementType stmtType = rowUpdatingEvent.StatementType;
                    DbCommand command = (DbCommand)rowUpdatingEvent.Command;

                    if (null != command) {
                        switch(stmtType) {
                        case StatementType.Select:
                            Debug.Assert(false, "how did we get here?");
                            return; // don't mess with it
                        case StatementType.Insert:
                            command = InsertCommand;
                            break;
                        case StatementType.Update:
                            command = UpdateCommand;
                            break;
                        case StatementType.Delete:
                            command = DeleteCommand;
                            break;
                        default:
                            throw ADP.InvalidStatementType(stmtType);
                        }

                        if (command != rowUpdatingEvent.Command) {
                            command = (DbCommand)rowUpdatingEvent.Command;
                            if ((null != command) && (null == command.Connection)) { // MDAC 87649
                                DbDataAdapter adapter = DataAdapter;
                                DbCommand select = ((null != adapter) ? ((DbCommand)adapter.SelectCommand) : null);
                                if (null != select) {
                                    command.Connection = (DbConnection)select.Connection;

                                }
                            }
                            // user command, not a command builder command
                        }
                        else command = null;
                    }
                    if (null == command) {
                        RowUpdatingHandlerBuilder(rowUpdatingEvent);
                    }
                 }
            }
            catch(Exception e) {
                // 
                if (!ADP.IsCatchableExceptionType(e)) {
                    throw;
                }

                ADP.TraceExceptionForCapture(e);

                rowUpdatingEvent.Status = UpdateStatus.ErrorsOccurred;
                rowUpdatingEvent.Errors = e;
            }
        }
		protected override void OnRowUpdating (RowUpdatingEventArgs value) 
		{
         		SybaseRowUpdatingEventHandler handler = (SybaseRowUpdatingEventHandler) Events[EventRowUpdating];
			if ((handler != null) && (value is SybaseRowUpdatingEventArgs))
            			handler(this, (SybaseRowUpdatingEventArgs) value);
		}
Exemplo n.º 19
0
        private void RowUpdatingHandlerBuilder(RowUpdatingEventArgs rowUpdatingEvent) {
            // MDAC 58710 - unable to tell Update method that Event opened connection and Update needs to close when done
            // HackFix - the Update method will close the connection if command was null and returned command.Connection is same as SelectCommand.Connection
            DataRow datarow = rowUpdatingEvent.Row;
            BuildCache(false, datarow, false);

            DbCommand command;
            switch(rowUpdatingEvent.StatementType) {
            case StatementType.Insert:
                command = BuildInsertCommand(rowUpdatingEvent.TableMapping, datarow);
                break;
            case StatementType.Update:
                command = BuildUpdateCommand(rowUpdatingEvent.TableMapping, datarow);
                break;
            case StatementType.Delete:
                command = BuildDeleteCommand(rowUpdatingEvent.TableMapping, datarow);
                break;
#if DEBUG
            case StatementType.Select:
                Debug.Assert(false, "how did we get here?");
                goto default;
#endif
            default:
                throw ADP.InvalidStatementType(rowUpdatingEvent.StatementType);
            }
            if (null == command) {
                if (null != datarow) {
                    datarow.AcceptChanges();
                }
                rowUpdatingEvent.Status = UpdateStatus.SkipCurrentRow;
            }
            rowUpdatingEvent.Command = command;
        }
Exemplo n.º 20
0
 protected override void OnRowUpdating(RowUpdatingEventArgs value)
 {
     CrmDataAdapterRowUpdatingEventHandler handler = (CrmDataAdapterRowUpdatingEventHandler)Events[EventRowUpdating];
     if ((null != handler) && (value is CrmDataAdapterRowUpdatingEventArgs))
     {
         handler(this, (CrmDataAdapterRowUpdatingEventArgs)value);
     }
 }
Exemplo n.º 21
0
        private void OnRowUpdating(Object sender, RowUpdatingEventArgs args)
        {
            // make sure we are still to proceed
            if (args.Status != UpdateStatus.Continue) return;

            switch( args.StatementType )
            {
                case StatementType.Delete:	args.Command = GetDeleteCommand();	break;
                case StatementType.Update:	args.Command = GetUpdateCommand();	break;
                case StatementType.Insert:	args.Command = GetInsertCommand();	break;
                default:	return;
            }

            SetParameterValues(args.Command, args.Row);
        }
 override protected void OnRowUpdating(RowUpdatingEventArgs value)
 {
     VirtuosoRowUpdatingEventHandler handler = (VirtuosoRowUpdatingEventHandler) Events[EventRowUpdating];
     if ((null != handler) && (value is VirtuosoRowUpdatingEventArgs)) 
     {
         handler(this, (VirtuosoRowUpdatingEventArgs) value);
     }
 }
Exemplo n.º 23
0
 protected override void OnRowUpdating(System.Data.Common.RowUpdatingEventArgs value)
 {
 }
 private void RowUpdatingEventHandler(object sender, RowUpdatingEventArgs e)
 {
   base.RowUpdatingHandler(e);
 }
Exemplo n.º 25
0
 virtual protected void OnRowUpdating(RowUpdatingEventArgs value) { // V1.0.3300
 }
 protected override void OnRowUpdating(RowUpdatingEventArgs value)
 {
     OdbcRowUpdatingEventHandler handler = (OdbcRowUpdatingEventHandler) base.Events[EventRowUpdating];
     if ((handler != null) && (value is OdbcRowUpdatingEventArgs))
     {
         handler(this, (OdbcRowUpdatingEventArgs) value);
     }
     base.OnRowUpdating(value);
 }
Exemplo n.º 27
0
 override protected void OnRowUpdating(RowUpdatingEventArgs value) {
     SqlRowUpdatingEventHandler handler = (SqlRowUpdatingEventHandler) Events[EventRowUpdating];
     if ((null != handler) && (value is SqlRowUpdatingEventArgs)) {
         handler(this, (SqlRowUpdatingEventArgs) value);
     }
     base.OnRowUpdating(value);
 }
Exemplo n.º 28
0
		protected override void OnRowUpdating(RowUpdatingEventArgs value)
		{
			NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "OnRowUpdating");
			if ((RowUpdating != null) && (value is NpgsqlRowUpdatingEventArgs))
			{
				RowUpdating(this, (NpgsqlRowUpdatingEventArgs) value);
			}
		}
Exemplo n.º 29
0
 protected override void OnRowUpdating(RowUpdatingEventArgs value)
 {
     EventHandler<H2RowUpdatingEventArgs> handler = (EventHandler<H2RowUpdatingEventArgs>)Events[EventRowUpdating];
     if (null != handler)
     {
         handler(this, (H2RowUpdatingEventArgs)value);
     }
 }
		protected override void OnRowUpdating(RowUpdatingEventArgs value)
		{
			FbRowUpdatingEventHandler handler = null;

			handler = (FbRowUpdatingEventHandler)base.Events[EventRowUpdating];

			if ((null != handler) &&
				(value is FbRowUpdatingEventArgs) &&
				(value != null))
			{
				handler(this, (FbRowUpdatingEventArgs)value);
			}
		}
Exemplo n.º 31
0
        private void UpdatingRowStatusErrors(RowUpdatingEventArgs rowUpdatedEvent, DataRow dataRow)
        {
            Debug.Assert(null != dataRow, "null dataRow");
            Exception errors = rowUpdatedEvent.Errors;

            if (null == errors)
            {
                // user changed status to ErrorsOccured without supplying an exception message
                errors = ADP.RowUpdatingErrors();
                rowUpdatedEvent.Errors = errors;
            }
            string message = errors.Message;
            dataRow.RowError += message;

            if (!ContinueUpdateOnError)
            {
                throw errors; // out of Update
            }
        }
Exemplo n.º 32
0
		protected override void OnRowUpdating (RowUpdatingEventArgs value) 
		{
			if (RowUpdating != null)
				RowUpdating (this, (SqlRowUpdatingEventArgs) value);
		}
Exemplo n.º 33
0
 protected abstract void OnRowUpdating(RowUpdatingEventArgs value);