//synchronize the appointment id between the dataset and the database
        //http://msdn.microsoft.com/en-us/library/ks9f57t0%28VS.71%29.aspx
        void Adapter_RowUpdated(object sender, System.Data.OleDb.OleDbRowUpdatedEventArgs e)
        {
            if (e.StatementType == StatementType.Insert)
            {
                SchedulerDataSet.AppointmentsRow appointnmentsRow = e.Row as SchedulerDataSet.AppointmentsRow;
                if (appointnmentsRow != null)
                {
                    this.schedulerDataSet.EnforceConstraints = false;
                    bool oldReadOnly = this.schedulerDataSet.Appointments.IDColumn.ReadOnly;
                    this.schedulerDataSet.Appointments.IDColumn.ReadOnly = false;
                    int newId = GetIndentity();

                    foreach (SchedulerDataSet.AppointmentsResourcesRow row in this.schedulerDataSet.AppointmentsResources)
                    {
                        if (row.RowState == DataRowState.Added && row.AppointmentID == appointnmentsRow.ID)
                        {
                            row.AppointmentID = newId;
                        }
                    }

                    foreach (SchedulerDataSet.AppointmentsRow row in this.schedulerDataSet.Appointments)
                    {
                        if (row.RowState == DataRowState.Added && row[this.schedulerDataSet.Appointments.ParentIDColumn] != DBNull.Value && row.ParentID == appointnmentsRow.ID)
                        {
                            row.ParentID = newId;
                        }
                    }
                    appointnmentsRow.ID = newId;

                    this.schedulerDataSet.Appointments.IDColumn.ReadOnly = oldReadOnly;
                    this.schedulerDataSet.EnforceConstraints             = true;
                }
            }
        }
		// If it's an Insert we fetch the @@Identity value and stuff it in the proper column
		protected void OnRowUpdated(object sender, OleDbRowUpdatedEventArgs e)
		{
			try
			{
				if (e.Status == UpdateStatus.Continue && e.StatementType == StatementType.Insert)
				{
					TransactionMgr txMgr = TransactionMgr.ThreadTransactionMgr();

					OleDbCommand cmd = new OleDbCommand("SELECT @@IDENTITY");

					// We make sure we enlist in the ongoing transaction, otherwise, we 
					// would most likely deadlock
					txMgr.Enlist(cmd, this);
					object o = cmd.ExecuteScalar(); // Get the Identity Value
					txMgr.DeEnlist(cmd, this);

					if (o != null)
					{
						e.Row[this.GetAutoKeyColumn()] = o;
						e.Row.AcceptChanges();
					}
				}
			}
			catch { }
		}
 /// <summary>
 /// Executed when the row is updated. This allows us to capture the 
 /// key assigned by the database.
 /// </summary>
 protected static void RowUpdated(object sender, OleDbRowUpdatedEventArgs args)
 {
     OleDbCommand idCMD = new OleDbCommand("SELECT @@IDENTITY", dbConn);
     if (args.StatementType == StatementType.Insert)
     {
         int newID;
         newID = (int)idCMD.ExecuteScalar();
         args.Row["ProductID"] = newID;
     }
 }
Exemple #4
0
        void PosesenieAdapter_RowUpdated(object sender, System.Data.OleDb.OleDbRowUpdatedEventArgs e)
        {
            if (e.StatementType == StatementType.Insert)
            {
                OleDbCommand cmdNewID = new OleDbCommand("SELECT @@IDENTITY", posesenieTableAdapter.Connection);
                cmdNewID.Transaction = posesenieTableAdapter.Transaction;  // Retrieve the Autonumber and store it in the CategoryID column.

                ((___BASA__DataSet.PosesenieRow)e.Row).ID = (int)cmdNewID.ExecuteScalar();
            }
        }
 private void adapter_RowUpdated(object sender, System.Data.OleDb.OleDbRowUpdatedEventArgs e)
 {
     if (e.Status == UpdateStatus.Continue && e.StatementType == StatementType.Insert)
     {
         int id = 0;
         using (OleDbCommand cmd = new OleDbCommand("SELECT @@IDENTITY", tableAdapterAppointments.Connection)) {
             id = (int)cmd.ExecuteScalar();
         }
         e.Row["ID"] = id;
     }
 }
        void ULAdapter_RowUpdated(object sender, System.Data.OleDb.OleDbRowUpdatedEventArgs e)
        {
            //throw new NotImplementedException();
            if (e.StatementType == StatementType.Insert)
            {
                OleDbCommand cmdNewID = new OleDbCommand("SELECT @@IDENTITY", ulizaTableAdapter.Connection);
                cmdNewID.Transaction = ulizaTableAdapter.Transaction;  // Retrieve the Autonumber and store it in the CategoryID column.

                ((___BASA__DataSet.UlizaRow)e.Row).UlizaID = (int)cmdNewID.ExecuteScalar();
            }
        }
Exemple #7
0
        void WhenAdapter_RowUpdated(object sender, System.Data.OleDb.OleDbRowUpdatedEventArgs e)
        {
            progressBar1.PerformStep();
            progressBar1.Refresh();

            if (e.StatementType == StatementType.Insert)
            {
                OleDbCommand cmdNewID = new OleDbCommand("SELECT @@IDENTITY", whenDatesTableAdapter.Connection);
                cmdNewID.Transaction = whenDatesTableAdapter.Transaction;
                int newID = (int)cmdNewID.ExecuteScalar();
                foreach (___BASA__DataSet.raspisanieRow rR in ___BASA__DataSet.raspisanie.Select("whenID=" + ((___BASA__DataSet.whenDatesRow)e.Row).ID))
                {
                    rR.whenID = newID;
                }
                ((___BASA__DataSet.whenDatesRow)e.Row).ID = (int)cmdNewID.ExecuteScalar();
            }
        }
Exemple #8
0
        private void Adapter_RowUpdated(object sender, System.Data.OleDb.OleDbRowUpdatedEventArgs e)
        {
            if (e.StatementType == StatementType.Insert)
            {
                OleDbCommand cmdNewID = new OleDbCommand("SELECT @@IDENTITY", e.Command.Connection);
                id = (int)cmdNewID.ExecuteScalar();
                e.Row["TrebovanieId"] = id;
                e.Status = UpdateStatus.SkipCurrentRow;

                for (int i = 0; i < ds.TrebovanieDetails.Rows.Count; i++)
                {
                    dataDataSet.TrebovanieDetailsRow r = (dataDataSet.TrebovanieDetailsRow)ds.TrebovanieDetails.Rows[i];
                    if (r.tblTrebovanieDetailId < 0)
                    {
                        r.tblTrebovanielId = id;
                    }
                }
            }
        }
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// oledbrowupdatedeventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this OleDbRowUpdatedEventHandler oledbrowupdatedeventhandler, Object sender, OleDbRowUpdatedEventArgs e, AsyncCallback callback)
        {
            if(oledbrowupdatedeventhandler == null) throw new ArgumentNullException("oledbrowupdatedeventhandler");

            return oledbrowupdatedeventhandler.BeginInvoke(sender, e, callback, null);
        }
Exemple #10
0
        //vehicle
        private void vehicleDataAdapter_RowUpdated(object sender, OleDbRowUpdatedEventArgs e)
        {
            // initialize a variable and a command to retrieve the last identity value created in the vehicle table.
            int newID = 0;
            // @@IDENTITY returns the last identity value (primary key) that was generated by a statement.
            OleDbCommand getLastIdentityCommand = new OleDbCommand("SELECT @@IDENTITY", greenConnection);

            if (e.StatementType == StatementType.Insert)
            {
                // if the statement was an insert statement
                newID = (int)getLastIdentityCommand.ExecuteScalar();
                e.Row["VehicleID"] = newID;
            }
        }
Exemple #11
0
 private void oleDbDataAdapter2_RowUpdated(object sender, System.Data.OleDb.OleDbRowUpdatedEventArgs e)
 {
 }
Exemple #12
0
 /// <devdoc>
 /// Listens for the RowUpdate event on a dataadapter to support UpdateBehavior.Continue
 /// </devdoc>
 private void OnOleDbRowUpdated(object sender, OleDbRowUpdatedEventArgs rowThatCouldNotBeWritten)
 {
     if (rowThatCouldNotBeWritten.RecordsAffected == 0)
      {
     if (rowThatCouldNotBeWritten.Errors != null)
     {
        rowThatCouldNotBeWritten.Row.RowError = SR.ExceptionMessageUpdateDataSetRowFailure;
        rowThatCouldNotBeWritten.Status = UpdateStatus.SkipCurrentRow;
     }
      }
 }
Exemple #13
0
        /// <summary>
        /// Pre-condition:  true
        /// Post-condition: Child record will be persisted in the database consistent
        ///                 with the primary key of the parent record.
        /// Description:    This method will synchronize the primary and foreign key.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void dbDA_RowUpdated(object sender, OleDbRowUpdatedEventArgs e)
        {
            int intID = 0;

            if (_dbConn.State == ConnectionState.Closed) _dbConn.Open();

            OleDbCommand dbCMD = new OleDbCommand("SELECT @@IDENTITY", _dbConn);

            if (e.StatementType == StatementType.Insert)
            {
                intID = (int)dbCMD.ExecuteScalar();
                e.Row[0] = intID;
            }
        }
 private void daService_RowUpdated(object sender, OleDbRowUpdatedEventArgs e)
 {
 }
 protected void OnRowUpdated(object sender, OleDbRowUpdatedEventArgs args)
 {
     _rowCount++;
     RaiseProgressStatus("Saving row {0} of {1}", _rowCount, _rowTotal);
 }
 // Event Handler for RowUpdated Event
 private void HandleRowUpdated(object sender, OleDbRowUpdatedEventArgs e)
 {
     if (e.Status == UpdateStatus.Continue && e.StatementType == StatementType.Insert)
     {
         // Get the Identity column value
         e.Row["id"] = Int32.Parse(cmdGetIdentity.ExecuteScalar().ToString());
         e.Row.AcceptChanges();
     }
 }
        // If it's an Insert we fetch the @@Identity value and stuff it in the proper column
        protected static void OnRowUpdated1(object sender, OleDbRowUpdatedEventArgs e)
        {
            try
            {
                if(e.StatementType == StatementType.Delete || e.Status != UpdateStatus.Continue) return;

                PropertyCollection props = e.Row.Table.ExtendedProperties;

                if (e.StatementType == StatementType.Insert)
                {
                    esEntitySavePacket packet = (esEntitySavePacket)props["esEntityData"];

                    if (e.Row.Table.ExtendedProperties.Contains("AutoInc"))
                    {
                        esDataRequest request = props["esDataRequest"] as esDataRequest;
                        string autoInc = props["AutoInc"] as string;

                        OleDbCommand cmd = new OleDbCommand();
                        cmd.Connection = e.Command.Connection;
                        cmd.Transaction = e.Command.Transaction;

                        cmd.CommandText = "SELECT @@IDENTITY";
                        cmd.CommandType = CommandType.Text;

                        object o = null;

                        #region Profiling
                        if (sTraceHandler != null)
                        {
                            using (esTraceArguments esTrace = new esTraceArguments(request, cmd, "OnRowUpdated", System.Environment.StackTrace))
                            {
                                try
                                {
                                    o = cmd.ExecuteScalar();
                                }
                                catch (Exception ex)
                                {
                                    esTrace.Exception = ex.Message;
                                    throw;
                                }
                            }
                        }
                        else
                        #endregion
                        {
                            o = cmd.ExecuteScalar();
                        }

                        if (o != null)
                        {
                            packet.CurrentValues[autoInc] = o;
                        }
                    }

                    if (props.Contains("EntitySpacesConcurrency"))
                    {
                        string colName = props["EntitySpacesConcurrency"] as string;
                        packet.CurrentValues[colName] = 1;
                    }
                }
                else if (e.StatementType == StatementType.Update)
                {
                    if (props.Contains("EntitySpacesConcurrency"))
                    {
                        esEntitySavePacket packet = (esEntitySavePacket)props["esEntityData"];

                        string colName = props["EntitySpacesConcurrency"] as string;
                        object o = e.Row[colName];

                        switch (Type.GetTypeCode(o.GetType()))
                        {
                            case TypeCode.Int16: packet.CurrentValues[colName] = ((System.Int16)o) + 1; break;
                            case TypeCode.Int32: packet.CurrentValues[colName] = ((System.Int32)o) + 1; break;
                            case TypeCode.Int64: packet.CurrentValues[colName] = ((System.Int64)o) + 1; break;
                            case TypeCode.UInt16: packet.CurrentValues[colName] = ((System.UInt16)o) + 1; break;
                            case TypeCode.UInt32: packet.CurrentValues[colName] = ((System.UInt32)o) + 1; break;
                            case TypeCode.UInt64: packet.CurrentValues[colName] = ((System.UInt64)o) + 1; break;
                        }

                        e.Row.AcceptChanges();
                    }
                }
            }
            catch { }
        }
 /// <summary>
 /// Get the new primary key on added rows
 /// </summary>
 /// <param name="sender">The sender of the event</param>
 /// <param name="e">The event arguments</param>
 private void daAddresses_RowUpdated(object sender, OleDbRowUpdatedEventArgs e)
 {
     if(e.Status == UpdateStatus.Continue && e.StatementType == StatementType.Insert)
     {
         OleDbCommand cmd = new OleDbCommand("Select @@Identity", dbConn);
         e.Row["ID"] = cmd.ExecuteScalar();
         e.Row.AcceptChanges();
     }
 }
        protected static void OnRowUpdated(object sender, OleDbRowUpdatedEventArgs e)
        {
            try
            {
                PropertyCollection props = e.Row.Table.ExtendedProperties;
                if (props.ContainsKey("props"))
                {
                    props = (PropertyCollection)props["props"];
                }

                if (e.Status == UpdateStatus.Continue && (e.StatementType == StatementType.Insert || e.StatementType == StatementType.Update))
                {
                    esDataRequest request = props["esDataRequest"] as esDataRequest;
                    esEntitySavePacket packet = (esEntitySavePacket)props["esEntityData"];

                    if (e.StatementType == StatementType.Insert)
                    {
                        if (props.Contains("AutoInc"))
                        {
                            string autoInc = props["AutoInc"] as string;

                            OleDbCommand cmd = new OleDbCommand();
                            cmd.Connection = e.Command.Connection;
                            cmd.Transaction = e.Command.Transaction;

                            cmd.CommandText = "SELECT @@IDENTITY";
                            cmd.CommandType = CommandType.Text;

                            object o = null;

                            #region Profiling
                            if (sTraceHandler != null)
                            {
                                using (esTraceArguments esTrace = new esTraceArguments(request, cmd, "OnRowUpdated", System.Environment.StackTrace))
                                {
                                    try
                                    {
                                        o = cmd.ExecuteScalar();
                                    }
                                    catch (Exception ex)
                                    {
                                        esTrace.Exception = ex.Message;
                                        throw;
                                    }
                                }
                            }
                            else
                            #endregion
                            {
                                o = cmd.ExecuteScalar();
                            }

                            if (o != null)
                            {
                                packet.CurrentValues[autoInc] = o;
                                e.Row[autoInc] = o;
                            }
                        }

                        if (props.Contains("EntitySpacesConcurrency"))
                        {
                            string esConcurrencyColumn = props["EntitySpacesConcurrency"] as string;
                            packet.CurrentValues[esConcurrencyColumn] = 1;
                        }
                    }

                    //-------------------------------------------------------------------------------------------------
                    // Fetch any defaults, SQLite doesn't support output parameters so we gotta do this the hard way
                    //-------------------------------------------------------------------------------------------------
                    if (props.Contains("Defaults"))
                    {
                        // Build the Where parameter and parameters
                        OleDbCommand cmd = new OleDbCommand();
                        cmd.Connection = e.Command.Connection;
                        cmd.Transaction = e.Command.Transaction;

                        string select = (string)props["Defaults"];

                        string[] whereParameters = ((string)props["Where"]).Split(',');

                        string comma = String.Empty;
                        string where = String.Empty;
                        int i = 1;
                        foreach (string parameter in whereParameters)
                        {
                            OleDbParameter p = new OleDbParameter("@p" + i++.ToString(), e.Row[parameter]);
                            cmd.Parameters.Add(p);
                            where += comma + "[" + parameter + "] = " + p.ParameterName;
                            comma = " AND ";
                        }

                        // Okay, now we can execute the sql and get any values that have defaults that were
                        // null at the time of the insert and/or our timestamp
                        cmd.CommandText = "SELECT " + select + " FROM [" + request.ProviderMetadata.Source + "] WHERE " + where + ";";

                        OleDbDataReader rdr = null;

                        try
                        {
                            #region Profiling
                            if (sTraceHandler != null)
                            {
                                using (esTraceArguments esTrace = new esTraceArguments(request, cmd, "OnRowUpdated", System.Environment.StackTrace))
                                {
                                    try
                                    {
                                        rdr = cmd.ExecuteReader(CommandBehavior.SingleResult);
                                    }
                                    catch (Exception ex)
                                    {
                                        esTrace.Exception = ex.Message;
                                        throw;
                                    }
                                }
                            }
                            else
                            #endregion
                            {
                                rdr = cmd.ExecuteReader(CommandBehavior.SingleResult);
                            }

                            if (rdr.Read())
                            {
                                select = select.Replace("[", String.Empty).Replace("]", String.Empty);
                                string[] selectCols = select.Split(',');

                                for (int k = 0; k < selectCols.Length; k++)
                                {
                                    packet.CurrentValues[selectCols[k]] = rdr.GetValue(k);
                                }
                            }
                        }
                        finally
                        {
                            // Make sure we close the reader no matter what
                            if (rdr != null) rdr.Close();
                        }
                    }

                    if (e.StatementType == StatementType.Update)
                    {
                        string colName = props["EntitySpacesConcurrency"] as string;
                        object o = e.Row[colName];

                        switch (Type.GetTypeCode(o.GetType()))
                        {
                            case TypeCode.Int16: packet.CurrentValues[colName] = ((System.Int16)o) + 1; break;
                            case TypeCode.Int32: packet.CurrentValues[colName] = ((System.Int32)o) + 1; break;
                            case TypeCode.Int64: packet.CurrentValues[colName] = ((System.Int64)o) + 1; break;
                            case TypeCode.UInt16: packet.CurrentValues[colName] = ((System.UInt16)o) + 1; break;
                            case TypeCode.UInt32: packet.CurrentValues[colName] = ((System.UInt32)o) + 1; break;
                            case TypeCode.UInt64: packet.CurrentValues[colName] = ((System.UInt64)o) + 1; break;
                        }
                    }
                }
            }
            catch { }
        }
Exemple #20
0
		/// <summary>
		/// Handles the RowUpdated event
		/// </summary>
		/// <param name="obj">The object that published the event</param>
		/// <param name="e">The OleDbRowUpdatedEventArgs</param>
		protected void RowUpdated(object obj, OleDbRowUpdatedEventArgs e)
		{
			base.RowUpdated(obj, e);
		}
        private void daEquipment_RowUpdated(object sender, OleDbRowUpdatedEventArgs e)
        {
            // Include a variable and a command to retrieve
            // the identity value from the Access database.
            int newID = 0;
            OleDbCommand idCMD = new OleDbCommand("SELECT @@IDENTITY", CtnGreen);

            if (e.StatementType == StatementType.Insert)
            {
                // Retrieve the identity value and
                // store it in the TreatmentID column.
                newID = (int)idCMD.ExecuteScalar();
                e.Row["EquipmentID"] = newID;
            }
        }
Exemple #22
0
 private void adpDetalle_RowUpdated(object sender, System.Data.OleDb.OleDbRowUpdatedEventArgs e)
 {
 }
        protected void OleDBOnRowUpdated(object sender, OleDbRowUpdatedEventArgs args)
        {
            OleDbCommand idCMD = new OleDbCommand("SELECT @@IDENTITY", OleConn);

            if (args.StatementType == StatementType.Insert)
            {
                InsertAutoFieldsID = (int)idCMD.ExecuteScalar();
            }
        }
Exemple #24
0
 private void adpEncabezado_RowUpdated(object sender, System.Data.OleDb.OleDbRowUpdatedEventArgs e)
 {
 }
        /// <summary>
        /// pre-condition: The frist column in the query is the autonumber field
        /// post-condition: Child will be perssisted in the database consistent with the primary key of the parent record
        /// description:    this method will synchronize the primary and foriegn key togehter 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void onRowUpdated(object sender, OleDbRowUpdatedEventArgs args)
        {
            int intNewID = 0;

            if (_dbConn.State == ConnectionState.Closed) _dbConn.Open();

            OleDbCommand dbCmd = new OleDbCommand("SELECT @@IDENTITY", _dbConn);

            if (args.StatementType == StatementType.Insert)
            {
                intNewID = (int)dbCmd.ExecuteScalar();
                args.Row[0] = intNewID;
            }
        }
Exemple #26
0
 private void MatrixAdapter_RowUpdated(object sender, System.Data.OleDb.OleDbRowUpdatedEventArgs e)
 {
 }
Exemple #27
0
 private void poHeaderAdapter_RowUpdated(object sender, OleDbRowUpdatedEventArgs e)
 {
 }
		private void DACompetition_RowUpdated(object sender, OleDbRowUpdatedEventArgs e)
		{
			if (e.Status == UpdateStatus.Continue && e.StatementType == StatementType.Insert )
			{
				// Get the Identity column value
				int identity = Int32.Parse(identityCommandCompetition.ExecuteScalar().ToString());
				e.Row["CompetitionId"] = identity;
				e.Row.AcceptChanges();
			}
		}
 public static Client GetOneClientRow(OleDbRowUpdatedEventArgs e)
 {
     DataRow row = e.Row;
     return new Client(int.Parse(row[0].ToString()), row[1].ToString(), row[2].ToString(), row[3].ToString(), row[4].ToString(), (bool)row[6], row[5].ToString());
 }
        /// <summary>
        /// Get the new primary key on added rows
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void daPhones_RowUpdated(object sender, OleDbRowUpdatedEventArgs e)
        {
            if(e.Status == UpdateStatus.Continue && e.StatementType == StatementType.Insert)
            {
                OleDbCommand cmd = new OleDbCommand("Select @@Identity", dbConn);
                e.Row["PhoneKey"] = cmd.ExecuteScalar();
                e.Row.AcceptChanges();
            }

            // Ignore deletions that don't find their row.  The cascade delete took care of them already.
            if(e.StatementType == StatementType.Delete && e.RecordsAffected == 0 && e.Status == UpdateStatus.ErrorsOccurred)
            {
                e.Status = UpdateStatus.Continue;
                e.Row.AcceptChanges();
            }
        }
		/// <summary>
		/// 忽略空的更新
		/// </summary>
		/// <param name="sender">引发事件的对象</param>
		/// <param name="args">事件参数</param>
		protected static void OnRowUpdated(object sender, OleDbRowUpdatedEventArgs args)
		{
			if (args.Errors!=null)
				if(args.Errors is DBConcurrencyException)
					args.Status=UpdateStatus.SkipCurrentRow;
		}