2002-12-04 Ville Palo <vi64pa@koti.soon.fi>
authorVille Palo <ville@mono-cvs.ximian.com>
Wed, 4 Dec 2002 18:54:18 +0000 (18:54 -0000)
committerVille Palo <ville@mono-cvs.ximian.com>
Wed, 4 Dec 2002 18:54:18 +0000 (18:54 -0000)
* DataRow.cs:
* DataRowCollection.cs: Added some event handlins stuff.
* DataSet.cs: Some fixes.
* DataTable.cs: Added event handlers.

svn path=/trunk/mcs/; revision=9381

mcs/class/System.Data/System.Data/ChangeLog
mcs/class/System.Data/System.Data/DataRow.cs
mcs/class/System.Data/System.Data/DataRowCollection.cs
mcs/class/System.Data/System.Data/DataSet.cs
mcs/class/System.Data/System.Data/DataTable.cs

index 4165fafe511374a5074ef64d67135006e1e67c6a..09c00c63faa05954619917aa52fe5f69b83d51dc 100644 (file)
@@ -1,3 +1,10 @@
+2002-12-04  Ville Palo <vi64pa@koti.soon.fi>\r
+\r
+       * DataRow.cs: \r
+       * DataRowCollection.cs: Added some event handlins stuff.\r
+       * DataSet.cs: Some fixes.\r
+       * DataTable.cs: Added event handlers.\r
+       \r
 2002-11-30  Ville Palo <vi64pa@koti.soon.fi>\r
 \r
        * DataRowChangeEventArgs.cs: Implemented Action and Row properties \r
index 9636e829758d489201e03d00635dedbba8b08a44..638c5c8494de650e9ad70c33b12a3f9399262291 100644 (file)
@@ -32,7 +32,7 @@ namespace System.Data {
                private string[] columnErrors;
                private string rowError;
                private DataRowState rowState;
-               protected internal int xmlRowID = 0;
+               internal int xmlRowID = 0;
 
                #endregion
 
@@ -82,7 +82,7 @@ namespace System.Data {
                        [MonoTODO]
                        set {
                                DataColumn column = _table.Columns[columnName];
-                               if (column == null) 
+                               if (column == null)
                                        throw new IndexOutOfRangeException ();
                                this[column] = value;
                        }
@@ -123,6 +123,7 @@ namespace System.Data {
                                                current[columnIndex] = DBNull.Value;
                                        else
                                                current[columnIndex] = value;
+                                       _table.ChangedDataColumn (this, column, value);
                                }
                                else {
                                        BeginEdit ();  // implicitly called
@@ -133,6 +134,7 @@ namespace System.Data {
                                                proposed[columnIndex] = DBNull.Value;
                                        else
                                                proposed[columnIndex] = value;
+                                       _table.ChangedDataColumn (this, column, value);
                                }
 
                                //Don't know if this is the rigth thing to do,
@@ -395,6 +397,7 @@ namespace System.Data {
                        switch (rowState) {
                        case DataRowState.Added:
                                Table.Rows.Remove (this);
+                               _table.DeletedDataRow (this, DataRowAction.Delete);
                                break;
                        case DataRowState.Deleted:
                                throw new DeletedRowInaccessibleException ();
@@ -666,6 +669,8 @@ namespace System.Data {
                                                rowState = DataRowState.Unchanged;
                                                break;
                                }
+                               
+                               _table.ChangedDataRow (this, DataRowAction.Rollback);
                        }
                }
 
index bc56546976372615d520a8b79298edaf42ceafd0..9a2cd8cf7cc70aa784b025182971bd7768a07dbc 100644 (file)
@@ -57,6 +57,7 @@ namespace System.Data
                        //TODO: validation
                        list.Add (row);
                        row.RowStateInternal = DataRowState.Added;
+                       row.Table.ChangedDataRow (row, DataRowAction.Add);
                }
 
                /// <summary>
index 38b2bfa518ea276c2ee9a3fd18f931d31243d070..711d488eedcab6beacdb6da2de57894a355b66d7 100644 (file)
@@ -7,6 +7,7 @@
 //   Rodrigo Moya <rodrigo@ximian.com>
 //   Stuart Caborn <stuart.caborn@virgin.net>
 //   Tim Coleman (tim@timcoleman.com)
+//   Ville Palo <vi64pa@koti.soon.fi>
 //
 // (C) Ximian, Inc. 2002
 // Copyright (C) Tim Coleman, 2002
@@ -190,9 +191,11 @@ namespace System.Data {
 
                #region Public Methods
 
+               [MonoTODO]
                public void AcceptChanges()
                {
-                       throw new NotImplementedException ();
+                       foreach (DataTable tempTable in tableCollection)
+                               tempTable.AcceptChanges ();
                }
 
                public void Clear()
@@ -717,7 +720,7 @@ namespace System.Data {
 
                                // TODO: other types!
                                if ((e = schema.Items [i] as XmlSchemaElement) != null) {
-                               
+
                                        dataSetName = e.Name;
                                        
                                        if (dataSetName != oldSchemaName) {
@@ -726,7 +729,7 @@ namespace System.Data {
                                        }
 
                                        if ((t = e.SchemaType as XmlSchemaComplexType) != null) {
-                                               
+
                                                if ((c = t.Particle as XmlSchemaChoice) != null) {
                                                        
                                                        for (int j = 0; j < c.Items.Count; j++) {
@@ -750,13 +753,17 @@ namespace System.Data {
                                        }
                                        else {
                                                // If not known type then it's declared after this
-                                               schemaTypeName = e.SchemaTypeName.ToString ();          
+                                               schemaTypeName = e.SchemaTypeName.ToString ();
+                                               
+                                               // FIXME: when xmlschema works correcty this is not needed anymore
+                                               if (schemaTypeName.StartsWith (":"))
+                                                       schemaTypeName = schemaTypeName.Substring (1);
                                        }
                                } // TODO: SimpleType
                                else if ((t = schema.Items [i] as XmlSchemaComplexType) != null) {
                                                                                
                                        if (t.Name == schemaTypeName) {
-                                               
+
                                                if ((s = t.Particle as XmlSchemaSequence) != null) {
                                                        
                                                        for (int j  = 0; j < s.Items.Count; j++) {
@@ -779,13 +786,18 @@ namespace System.Data {
                                                                else {
                                                                        // If table type is not known it's declared after this
                                                                        tableTypeName = e.SchemaTypeName.ToString ();
+
+                                                                       // FIXME: when XmlSchema works correctly this is not 
+                                                                       // needed anymore
+                                                                       if (tableTypeName.StartsWith (":"))
+                                                                               tableTypeName = tableTypeName.Substring (1);
                                                                }
                                                        }                                                                                                                               
                                                }
                                        }
                                        
                                        else if (t.Name == tableTypeName) { // table type declaration
-                                               
+
                                                if ((s = t.Particle as XmlSchemaSequence) != null) {
                                                        
                                                        for (int j  = 0; j < s.Items.Count; j++) {
index 9f03132aeca06b3e417deea3310133aa17e0be37..a88ca899425ed7af80ca6d41b5498cf81aee0822 100644 (file)
@@ -112,6 +112,24 @@ namespace System.Data {
                }
 
 
+               internal void ChangedDataColumn (DataRow dr, DataColumn dc, object pv)
+               {
+                       DataColumnChangeEventArgs e = new DataColumnChangeEventArgs (dr, dc, pv);
+                       OnColumnChanged(e);
+               }
+
+               internal void DeletedDataRow (DataRow dr, DataRowAction action)
+               {
+                       DataRowChangeEventArgs e = new DataRowChangeEventArgs (dr, action);
+                       OnRowDeleted (e);
+               }
+
+               internal void ChangedDataRow (DataRow dr, DataRowAction action)
+               {
+                       DataRowChangeEventArgs e = new DataRowChangeEventArgs (dr, action);
+                       OnRowChanged (e);
+               }
+
                /// <summary>
                /// Gets the collection of child relations for this DataTable.
                /// </summary>
@@ -584,6 +602,11 @@ namespace System.Data {
                [MonoTODO]
                public void RejectChanges()
                {
+                       foreach(DataRow myRow in _rows)
+                       {
+                               if (myRow.RowState != DataRowState.Unchanged)
+                                       myRow.RejectChanges();
+                       }
                }
 
                /// <summary>
@@ -716,6 +739,7 @@ namespace System.Data {
                        }
                }
 
+
                /// <summary>
                /// Raises the RowChanging event.
                /// </summary>