Author: suresh
Date: 2005-05-04 06:53:00 -0400 (Wed, 04 May 2005)
New Revision: 44016

Modified:
   trunk/mcs/class/System.Data/System.Data/ChangeLog
   trunk/mcs/class/System.Data/System.Data/DataRow.cs
   trunk/mcs/class/System.Data/Test/System.Data/ChangeLog
   trunk/mcs/class/System.Data/Test/System.Data/DataTableTest.cs
Log:
System.Data/DataRow.cs: AcceptChanges: raise row changing & row changed events.
Test/System.Data/DataTableTest.cs: Added a test to check whether Commit 
RowChanging & RowChanged event is fired.



Modified: trunk/mcs/class/System.Data/System.Data/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/System.Data/ChangeLog   2005-05-04 10:25:29 UTC 
(rev 44015)
+++ trunk/mcs/class/System.Data/System.Data/ChangeLog   2005-05-04 10:53:00 UTC 
(rev 44016)
@@ -1,5 +1,8 @@
 2005-05-04  Sureshkumar T  <[EMAIL PROTECTED]>
 
+       * DataRow.cs: AcceptChanges: raise row changing & row changed
+       events.
+
        * DataRowCollection.cs: Clear : remove rows from indexes
 
 2005-05-02  Atsushi Enomoto  <[EMAIL PROTECTED]>

Modified: trunk/mcs/class/System.Data/System.Data/DataRow.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data/DataRow.cs  2005-05-04 10:25:29 UTC 
(rev 44015)
+++ trunk/mcs/class/System.Data/System.Data/DataRow.cs  2005-05-04 10:53:00 UTC 
(rev 44016)
@@ -590,6 +590,8 @@
                public void AcceptChanges () 
                {
                        EndEdit(); // in case it hasn't been called
+
+                        _table.ChangingDataRow (this, DataRowAction.Commit);
                        switch (rowState) {
                                case DataRowState.Unchanged:
                                        return;
@@ -607,6 +609,8 @@
                        // Accept from detached
                        if (_original != _current)
                                Original = Current;
+
+                        _table.ChangedDataRow (this, DataRowAction.Commit);
                }
 
                /// <summary>

Modified: trunk/mcs/class/System.Data/Test/System.Data/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/Test/System.Data/ChangeLog      2005-05-04 
10:25:29 UTC (rev 44015)
+++ trunk/mcs/class/System.Data/Test/System.Data/ChangeLog      2005-05-04 
10:53:00 UTC (rev 44016)
@@ -1,8 +1,10 @@
 2005-05-04  Sureshkumar T  <[EMAIL PROTECTED]>
 
-       * DataTableTest.cs: Added a test for DataTable. Should clear rows
-       from indexes as well. Simplified table creation for ClearReset
-       test.
+       * DataTableTest.cs: 
+       - Added a test for DataTable. Should clear rows from indexes as
+       well. Simplified table creation for ClearReset test.
+       - Added a test to check whether Commit RowChanging & RowChanged
+       event is fired.
 
 2005-04-29  Sureshkumar T  <[EMAIL PROTECTED]>
 

Modified: trunk/mcs/class/System.Data/Test/System.Data/DataTableTest.cs
===================================================================
--- trunk/mcs/class/System.Data/Test/System.Data/DataTableTest.cs       
2005-05-04 10:25:29 UTC (rev 44015)
+++ trunk/mcs/class/System.Data/Test/System.Data/DataTableTest.cs       
2005-05-04 10:53:00 UTC (rev 44016)
@@ -1341,6 +1341,47 @@
                         MyDataTable dt = (MyDataTable)(dt1.Clone());
                         AssertEquals("A#01",2,MyDataTable.count);
                 }
+
+                DataRowAction rowActionChanging = DataRowAction.Nothing;
+                DataRowAction rowActionChanged  = DataRowAction.Nothing;
+                [Test]
+                public void AcceptChangesTest ()
+                {
+                        DataTable dt = new DataTable ("test");
+                        dt.Columns.Add ("id", typeof (int));
+                        dt.Columns.Add ("name", typeof (string));
+                        
+                        dt.Rows.Add (new object [] { 1, "mono 1" });
+
+                        dt.RowChanged  += new DataRowChangeEventHandler 
(OnRowChanged);
+                        dt.RowChanging += new DataRowChangeEventHandler 
(OnRowChanging);
+
+                        try {
+                                rowActionChanged = rowActionChanging = 
DataRowAction.Nothing;
+                                dt.AcceptChanges ();
+
+                                AssertEquals ("#1 should have fired event and 
set action to commit",
+                                              DataRowAction.Commit, 
rowActionChanging);
+                                AssertEquals ("#2 should have fired event and 
set action to commit",
+                                              DataRowAction.Commit, 
rowActionChanged);
+
+                        } finally {
+                                dt.RowChanged  -= new 
DataRowChangeEventHandler (OnRowChanged);
+                                dt.RowChanging -= new 
DataRowChangeEventHandler (OnRowChanging);
+
+                        }
+                }
+
+                public void OnRowChanging (object src, DataRowChangeEventArgs 
args)
+                {
+                        rowActionChanging = args.Action;
+                }
+                
+                public void OnRowChanged (object src, DataRowChangeEventArgs 
args)
+                {
+                        rowActionChanged = args.Action;
+                }
+                
                                                                                
                     
         }
                                                                                
                     

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to