2
0
Эх сурвалжийг харах

ChangeLog: Updated.
SqlDataSource.cs: Corrected method calls.
SqlDataSourceView.cs: Partial implementation of few methods.

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

Sanja Gupta 21 жил өмнө
parent
commit
37c863887a

+ 5 - 0
mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog

@@ -1,3 +1,8 @@
+2004-11-05 Sanjay Gupta <[email protected]>
+	
+	* SqlDataSource.cs: Corrected method calls.
+	* SqlDataSourceView.cs: Partial implementation of few methods.
+
 2004-10-25 Gonzalo Paniagua Javier <[email protected]>
 
 	* ListItemCollection.cs: fixed bug when indexing changed elements in

+ 6 - 4
mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSource.cs

@@ -3,8 +3,10 @@
 //
 // Authors:
 //	Ben Maurer ([email protected])
+//	Sanjay Gupta ([email protected])
 //
 // (C) 2003 Ben Maurer
+// (C) 2004 Novell, Inc. (http://www.novell.com)
 //
 
 //
@@ -68,22 +70,22 @@ namespace System.Web.UI.WebControls {
 			
 		public int Insert ()
 		{
-			return View.Insert ();
+			return View.Insert (null);
 		}
 		
 		public int Delete ()
 		{
-			return View.Delete ();
+			return View.Delete (null, null);
 		}
 		
 		public IEnumerable Select ()
 		{
-			return View.Select ();
+			return View.Select (null);
 		}
 		
 		public int Update ()
 		{
-			return View.Update ();
+			return View.Update (null, null, null);
 		}
 			
 		protected override void LoadViewState (object savedState)

+ 61 - 29
mcs/class/System.Web/System.Web.UI.WebControls/SqlDataSourceView.cs

@@ -3,8 +3,10 @@
 //
 // Authors:
 //	Ben Maurer ([email protected])
+//	Sanjay Gupta ([email protected])
 //
 // (C) 2003 Ben Maurer
+// (C) Novell, Inc. (http://www.novell.com)
 //
 
 //
@@ -34,55 +36,91 @@ using System.Collections.Specialized;
 using System.Text;
 using System.Data;
 using System.ComponentModel;
+using System.Data.SqlClient;
 
 namespace System.Web.UI.WebControls {
 	public class SqlDataSourceView : DataSourceView, IStateManager {
 
+		SqlCommand command;
+		SqlConnection connection;
+
 		public SqlDataSourceView (SqlDataSource owner, string name)
 		{
 			this.owner = owner;
 			this.name = name;
+			connection = new SqlConnection (owner.ConnectionString);
 		}
-	
-		public int Delete ()
+
+		public int Delete (IDictionary keys, IDictionary oldValues)
 		{
-			return Delete (null);
+			return ExecuteDelete (keys, oldValues);
 		}
 		
-		[MonoTODO]
-		public int Delete (IDictionary parameters)
+		[MonoTODO ("Handle keys and oldValues and parameters")]
+		protected override int ExecuteDelete(IDictionary keys, IDictionary oldValues)
 		{
-			throw new NotImplementedException ();
+			command = new SqlCommand (this.DeleteCommand, connection);
+			connection.Open ();
+			int result = command.ExecuteNonQuery ();
+			connection.Close ();
+			return result;			
 		}
 		
-		public int Insert ()
+		public int Insert (IDictionary values)
 		{
-			return Insert (null);
+			return Insert (values);
 		}
 		
-		[MonoTODO]
-		public int Insert (IDictionary values)
+		[MonoTODO ("Handle values and parameters")]
+		protected override int ExecuteInsert (IDictionary values)
 		{
-			throw new NotImplementedException ();
+			command = new SqlCommand (this.InsertCommand, connection);
+			connection.Open ();
+			int result = command.ExecuteNonQuery ();
+			connection.Close ();
+			return result;
 		}
-		
-		[MonoTODO]
-		public IEnumerable Select ()
+				
+		public IEnumerable Select (DataSourceSelectArguments arguments)
 		{
-			throw new NotImplementedException ();
+			return ExecuteSelect (arguments);
 		}
-		
-		public int Update ()
+
+		[MonoTODO("Extra method to keep things compiling, need to remove later")]
+		public IEnumerable Select()
 		{
-			return Update (null, null);
+			throw new NotImplementedException ("Not required");
 		}
-		
-		[MonoTODO]
-		public int Update (IDictionary parameters, IDictionary values)
+
+		[MonoTODO ("Handle arguments")]
+		protected internal override IEnumerable ExecuteSelect (
+						DataSourceSelectArguments arguments)
 		{
-			throw new NotImplementedException ();
+			command = new SqlCommand (this.SelectCommand, connection);
+			connection.Open ();
+			SqlDataReader reader = command.ExecuteReader ();
+			//return reader.GetEnumerator ();
+			throw new NotImplementedException ("SqlDataReader doesnt implements GetEnumerator method yet");
 		}
 
+		public int Update(IDictionary keys, IDictionary values,
+			IDictionary oldValues)
+		{
+			return ExecuteUpdate (keys, values, oldValues);
+		}
+
+		[MonoTODO ("Handle keys, values and oldValues")]
+		protected override int ExecuteUpdate (IDictionary keys,
+					IDictionary values, IDictionary oldValues)
+		{
+			command = new SqlCommand (this.UpdateCommand, connection);
+			connection.Open ();
+			int result = command.ExecuteNonQuery();
+			connection.Close();
+			return result;
+		}
+
+
 		void IStateManager.LoadViewState (object savedState)
 		{
 			LoadViewState (savedState);
@@ -425,13 +463,7 @@ namespace System.Web.UI.WebControls {
 			remove { Events.RemoveHandler (EventUpdating, value); }
 		}
 		#endregion
-
-		[MonoTODO]
-		protected internal override IEnumerable ExecuteSelect (
-						DataSourceSelectArguments arguments)
-		{
-			throw new NotImplementedException ();
-		}		
+				
 	}
 	
 }