Beispiel #1
0
 void _oraDataAdp_RowUpdated(object sender, MySqlRowUpdatedEventArgs e)
 {
     if (RowUpdated != null)
     {
         RowUpdated(sender, e);
     }
 }
Beispiel #2
0
 /// <summary>
 /// est appellé dès lors q'une ligne de la datatble à été traitée par le dataadapter
 /// (après que le dataadapter ait réalisé une opération de base de données)
 /// </summary>
 /// <param name="sender"> </param>
 /// <param name="e"></param>
 void dataAdap_RowUpdated(object sender, MySqlRowUpdatedEventArgs e)
 {
     if (e.RecordsAffected == 1 && e.Command == this.dataAdap.InsertCommand) //si une ligne a été modifiée et que la commande sql est un insert
     {                                                                       //Dans ce cas il me faut récupérer l'id qui a été généré pour cette nouvelle ligne
         MySqlCommand idQuery = this.connex.CreateCommand();
         idQuery.CommandText = "SELECT LAST_INSERT_ID();";                   // requête renvoie l'id du dernier enregistement
         try
         {
             int id = (int)(ulong)idQuery.ExecuteScalar();     // lancement de cette requête avec récupération de la première valeur retournée (première valeur de la première ligne du premier jeu de résultat)
             //dataAdap.InsertCommand.Parameters["@id"].Value = id; //Pas utilisé dans la commande insert
             //e.Row["id"] = id; // affiche l'id dans la collone id
             foreach (DataColumn col in e.Row.Table.Columns)
             {
                 if (col.AutoIncrement)
                 {
                     e.Row[col.Ordinal] = id;
                 }
             }
         }
         catch (Exception ex)
         {
             Debug.Print(ex.Message);
         }
     }
 }
Beispiel #3
0
        // If it's an Insert we fetch the @@Identity value and stuff it in the proper column
        protected void OnRowUpdated(object sender, MySqlRowUpdatedEventArgs e)
        {
            try
            {
                if (e.Status == UpdateStatus.Continue && e.StatementType == StatementType.Insert)
                {
                    TransactionMgr txMgr = TransactionMgr.ThreadTransactionMgr();

                    string identityCol = this.GetAutoKeyColumns();

                    MySqlCommand cmd = new MySqlCommand();

                    cmd.CommandText = "SELECT LAST_INSERT_ID();";

                    // 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[identityCol] = o;
                    }

                    e.Row.AcceptChanges();
                }
            }
            catch {}
        }
Beispiel #4
0
        private void OnRowUpdated(object sender, MySqlRowUpdatedEventArgs args)// utile pour ajout,modif,supp
        {
            string msg = "";
            Int64  nb  = 0;

            if (args.Status == UpdateStatus.ErrorsOccurred)
            {
                if (vaction == 'd' || vaction == 'u') // on veut savoir si la personne existe encore dans la base
                {
                    MySqlCommand vcommand = myConnection.CreateCommand();
                    if (vtable == 'p') // ‘p’ pour table PERSONNE
                    {
                        vcommand.CommandText = "SELECT COUNT(*) FROM personne WHERE IdPersonne = '" + args.Row[0, DataRowVersion.Original] + "'";
                    }
                    nb = (Int64)vcommand.ExecuteScalar();
                }
                if (vaction == 'd')
                {
                    if (nb == 1) // pour delete si l'enr a été supprimé on n'affiche pas l'erreur
                    {
                        if (vtable == 'p')
                        {
                            msg = "Pour le numéro de personnes : " + args.Row[0, DataRowVersion.Original] + "impossible delete car enr modifié dans la base";
                        }
                        rapport.Add(msg);
                        errmaj = true;
                    }
                }
                if (vaction == 'u')
                {
                    if (nb == 1)
                    {
                        if (vtable == 'p')
                        {
                            msg = "pour le numéro de personne: " + args.Row[0, DataRowVersion.Original] + "impossible MAJ car enr modifié dans la base";
                        }
                        rapport.Add(msg);
                        errmaj = true;
                    }
                    else
                    {
                        if (vtable == 'p')
                        {
                            msg = "pour le numéro de personne : " + args.Row[0, DataRowVersion.Original] + "impossible MAJ car enr supprimé dans la base";
                        }
                        rapport.Add(msg);
                        errmaj = true;
                    }
                }
                if (vaction == 'c')
                {
                    if (vtable == 'p')
                    {
                        msg = "pour le numéro de personne : " + args.Row[0, DataRowVersion.Current] + "impossible ADD car erreur données";
                    }
                    rapport.Add(msg);
                    errmaj = true;
                }
            }
        }
Beispiel #5
0
 protected static void OnRowUpdated(object sender, MySqlRowUpdatedEventArgs args)
 {
     if (args.RecordsAffected == 0)
     {
         args.Row.RowError = "Optimistic ConCurrency Violation Encountered";
         args.Status       = UpdateStatus.SkipCurrentRow;
     }
 }
Beispiel #6
0
 private void onTienTCSRowUpdated(object sender, MySqlRowUpdatedEventArgs e)
 {
     // Conditionally execute this code block on inserts only.
     if (e.StatementType == StatementType.Insert)
     {
         MySqlCommand cmdNewID = new MySqlCommand("SELECT @@IDENTITY", this.tientcsTableAdapter.Connection);
         e.Row["TienTCSId"] = cmdNewID.ExecuteScalar();
         e.Status           = UpdateStatus.SkipCurrentRow;
     }
 }
Beispiel #7
0
 void appointmentDataAdapter_RowUpdated(object sender, MySqlRowUpdatedEventArgs e)
 {
     if (e.Status == UpdateStatus.Continue && e.StatementType == StatementType.Insert)
     {
         int          id  = 0;
         MySqlCommand cmd = new MySqlCommand("SELECT LAST_INSERT_ID()", dbconnection);
         id          = Convert.ToInt32(cmd.ExecuteScalar());
         e.Row["ID"] = id;
     }
 }
Beispiel #8
0
 protected void onRowUpdated(object sender, MySqlRowUpdatedEventArgs e)
 {
     // Conditionally execute this code block on inserts only.
     if (e.StatementType == StatementType.Insert)
     {
         MySqlCommand cmdNewID = new MySqlCommand("SELECT @@IDENTITY", this.DataAdapter.SelectCommand.Connection);
         e.Row[this.TablePrimaryKey] = cmdNewID.ExecuteScalar();
         e.Status = UpdateStatus.SkipCurrentRow;
     }
 }
Beispiel #9
0
 /// <summary>
 /// Called when [my SQL row updated].
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="rowThatCouldNotBeWritten">The <see cref="MySqlRowUpdatedEventArgs"/> instance containing the event data.</param>
 /// <devdoc>
 /// Listens for the RowUpdate event on a data adapter to support
 /// UpdateBehavior.Continue
 /// </devdoc>
 private void OnMySqlRowUpdated(object sender, MySqlRowUpdatedEventArgs rowThatCouldNotBeWritten)
 {
     if (rowThatCouldNotBeWritten.RecordsAffected == 0)
     {
         if (rowThatCouldNotBeWritten.Errors != null)
         {
             rowThatCouldNotBeWritten.Row.RowError = "행을 갱신하는데 실패했습니다.";
             rowThatCouldNotBeWritten.Status       = UpdateStatus.SkipCurrentRow;
         }
     }
 }
Beispiel #10
0
 /// <devdoc>
 /// Listens for the RowUpdate event on a dataadapter to support UpdateBehavior.Continue
 /// </devdoc>
 private void OnMySqlRowUpdated(object sender, MySqlRowUpdatedEventArgs rowThatCouldNotBeWritten)
 {
     if (rowThatCouldNotBeWritten.RecordsAffected == 0)
     {
         if (rowThatCouldNotBeWritten.Errors != null)
         {
             rowThatCouldNotBeWritten.Row.RowError = SR.ExceptionMessageUpdateDataSetRowFailure;
             rowThatCouldNotBeWritten.Status       = UpdateStatus.SkipCurrentRow;
         }
     }
 }
Beispiel #11
0
 private void onCTTMRowUpdated(object sender, MySqlRowUpdatedEventArgs e)
 {
     // Conditionally execute this code block on inserts only.
     if (e.StatementType == StatementType.Insert)
     {
         MySqlCommand cmdNewID = new MySqlCommand("SELECT @@IDENTITY", this.chungtutienmatTableAdapter.Connection);
         // Retrieve the Autonumber and store it in the CategoryID column.
         e.Row["ChungTuTienMatId"] = cmdNewID.ExecuteScalar();
         e.Status = UpdateStatus.SkipCurrentRow;
     }
 }
 private void MySqlDatabase_RowUpdated(object sender, MySqlRowUpdatedEventArgs e)
 {
     if (e.RecordsAffected == 0)
     {
         if (e.Errors != null)
         {
             e.Row.RowError = "更新数据行时出错。";
             e.Status       = UpdateStatus.SkipCurrentRow;
         }
     }
 }
Beispiel #13
0
 static void OnRowUpdating(object sender, MySqlRowUpdatedEventArgs e)
 {
     if (e.Command != null)
     {
         System.Windows.Forms.TextBox cmdDebugBox = DataGridView.Instance.cmdDebugBox;
         cmdDebugBox.Text  = "Row Updating...";
         cmdDebugBox.Text += "Command type: -> ";
         cmdDebugBox.Text += e.StatementType.ToString();
         cmdDebugBox.Text += "\r\nCommand text:\r\n";
         cmdDebugBox.Text += e.Command.CommandText.ToString();
         cmdDebugBox.Text += "\r\nParameters:";
         foreach (MySqlParameter p in e.Command.Parameters)
         {
             cmdDebugBox.Text += "\r\n" + p.ParameterName + " - " + p.Value;
         }
     }
 }
        /// /////////////////////////////////////////////////////////////////
        void m_adapter_RowUpdated(object sender, MySqlRowUpdatedEventArgs e)
        {
            switch (e.StatementType)
            {
            case StatementType.Delete:                                                      break;

            case StatementType.Insert:      MAJApresInsert(e.Row);  break;

            case StatementType.Update:      MAJApresUpdate(e.Row);  break;

            case StatementType.Select:
            case StatementType.Batch:
            default:                                        MAJApresSelect(e.Row);  break;
            }
            if (RowUpdated != null)
            {
                RowUpdated(this, e);
            }
        }
Beispiel #15
0
        /// <devdoc>
        /// Listens for the RowUpdate event on a dataadapter to support UpdateBehavior.Continue
        /// </devdoc>
        private void OnSqlRowUpdated(object sender, MySqlRowUpdatedEventArgs e)
        {
            DataColumn _autoKeyField = null;

            if (e.RecordsAffected == 0)
            {
                if (e.Errors != null)
                {
                    //e.Row.RowError = Resources.ExceptionMessageUpdateDataSetRowFailure;
                    e.Row.RowError = e.Errors.Message;
                    e.Status       = UpdateStatus.SkipCurrentRow;
                }
            }

            foreach (DataColumn col in e.Row.Table.Columns)
            {
                if (col.AutoIncrement)
                {
                    _autoKeyField = col;
                    break;
                }
            }

            // Include a variable and a command to retrieve the identity value from the Access database.
            if (_autoKeyField != null)
            {
                if (e.Status == UpdateStatus.Continue && e.StatementType == StatementType.Insert)
                {
                    MySqlCommand idCMD = new MySqlCommand("SELECT LAST_INSERT_ID();", e.Command.Connection, e.Command.Transaction);

                    // Retrieve the identity value and store it in the autokey column.
                    object newID = idCMD.ExecuteScalar();
                    if (newID != null)
                    {
                        e.Row[_autoKeyField.ColumnName] = newID;
                    }
                }
            }
        }
Beispiel #16
0
 protected void OnRowUpdated(object sender, MySqlRowUpdatedEventArgs e)
 {
     try
     {
         if (e.Status == UpdateStatus.Continue && e.StatementType == StatementType.Insert)
         {
             TransactionMgr txMgr       = TransactionMgr.ThreadTransactionMgr();
             string         identityCol = this.GetAutoKeyColumns();
             MySqlCommand   cmd         = new MySqlCommand();
             cmd.CommandText = "SELECT LAST_INSERT_ID();";
             txMgr.Enlist(cmd, this);
             object o = cmd.ExecuteScalar();
             txMgr.DeEnlist(cmd, this);
             if (o != null)
             {
                 e.Row[identityCol] = o;
             }
             e.Row.AcceptChanges();
         }
     }
     catch {}
 }
Beispiel #17
0
 public void rowUpdatedEvent(object sender, MySqlRowUpdatedEventArgs e)
 {
     SR2DLogger.log(e.StatementType.ToString(), false);
 }
Beispiel #18
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, MySqlRowUpdatedEventArgs e)
 {
     base.RowUpdated(obj, e);
 }
 private static void Adapter_RowUpdated(object sender, MySqlRowUpdatedEventArgs e)
 {
     rowInsertedCount += e.RecordsAffected;
     Console.WriteLine(currentVariable + " - " + rowInsertedCount.ToString() + " filas insertadas");
 }