コード例 #1
0
		/// <summary>
		/// 	Update an existing row in the datasource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">PetShop.Business.Orders object to update.</param>
		/// <remarks>
		///		After updating the datasource, the PetShop.Business.Orders object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Update(TransactionManager transactionManager, PetShop.Business.Orders entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Orders_Update", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@OrderId", DbType.Int32, entity.OrderId );
			database.AddInParameter(commandWrapper, "@UserId", DbType.AnsiString, entity.UserId );
			database.AddInParameter(commandWrapper, "@OrderDate", DbType.DateTime, entity.OrderDate );
			database.AddInParameter(commandWrapper, "@ShipAddr1", DbType.AnsiString, entity.ShipAddr1 );
			database.AddInParameter(commandWrapper, "@ShipAddr2", DbType.AnsiString, entity.ShipAddr2 );
			database.AddInParameter(commandWrapper, "@ShipCity", DbType.AnsiString, entity.ShipCity );
			database.AddInParameter(commandWrapper, "@ShipState", DbType.AnsiString, entity.ShipState );
			database.AddInParameter(commandWrapper, "@ShipZip", DbType.AnsiString, entity.ShipZip );
			database.AddInParameter(commandWrapper, "@ShipCountry", DbType.AnsiString, entity.ShipCountry );
			database.AddInParameter(commandWrapper, "@BillAddr1", DbType.AnsiString, entity.BillAddr1 );
			database.AddInParameter(commandWrapper, "@BillAddr2", DbType.AnsiString, entity.BillAddr2 );
			database.AddInParameter(commandWrapper, "@BillCity", DbType.AnsiString, entity.BillCity );
			database.AddInParameter(commandWrapper, "@BillState", DbType.AnsiString, entity.BillState );
			database.AddInParameter(commandWrapper, "@BillZip", DbType.AnsiString, entity.BillZip );
			database.AddInParameter(commandWrapper, "@BillCountry", DbType.AnsiString, entity.BillCountry );
			database.AddInParameter(commandWrapper, "@Courier", DbType.AnsiString, entity.Courier );
			database.AddInParameter(commandWrapper, "@TotalPrice", DbType.Decimal, entity.TotalPrice );
			database.AddInParameter(commandWrapper, "@BillToFirstName", DbType.AnsiString, entity.BillToFirstName );
			database.AddInParameter(commandWrapper, "@BillToLastName", DbType.AnsiString, entity.BillToLastName );
			database.AddInParameter(commandWrapper, "@ShipToFirstName", DbType.AnsiString, entity.ShipToFirstName );
			database.AddInParameter(commandWrapper, "@ShipToLastName", DbType.AnsiString, entity.ShipToLastName );
			database.AddInParameter(commandWrapper, "@AuthorizationNumber", DbType.Int32, entity.AuthorizationNumber );
			database.AddInParameter(commandWrapper, "@Locale", DbType.AnsiString, entity.Locale );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Update", entity));

			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
			
			//Stop Tracking Now that it has been updated and persisted.
			if (DataRepository.Provider.EnableEntityTracking)
				EntityManager.StopTracking(entity.EntityTrackingKey);
			
			
			entity.AcceptChanges();
			
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Update", entity));

			return Convert.ToBoolean(results);
		}
コード例 #2
0
		/// <summary>
		/// 	Inserts a PetShop.Business.Profiles object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">PetShop.Business.Profiles object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the PetShop.Business.Profiles object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Insert(TransactionManager transactionManager, PetShop.Business.Profiles entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Profiles_Insert", _useStoredProcedure);
			
			database.AddOutParameter(commandWrapper, "@UniqueId", DbType.Int32, 4);
			database.AddInParameter(commandWrapper, "@Username", DbType.AnsiString, entity.Username );
			database.AddInParameter(commandWrapper, "@ApplicationName", DbType.AnsiString, entity.ApplicationName );
			database.AddInParameter(commandWrapper, "@IsAnonymous", DbType.Boolean, (entity.IsAnonymous.HasValue ? (object) entity.IsAnonymous  : System.DBNull.Value));
			database.AddInParameter(commandWrapper, "@LastActivityDate", DbType.DateTime, (entity.LastActivityDate.HasValue ? (object) entity.LastActivityDate  : System.DBNull.Value));
			database.AddInParameter(commandWrapper, "@LastUpdatedDate", DbType.DateTime, (entity.LastUpdatedDate.HasValue ? (object) entity.LastUpdatedDate  : System.DBNull.Value));
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
				
			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
					
			object _uniqueId = database.GetParameterValue(commandWrapper, "@UniqueId");
			entity.UniqueId = (System.Int32)_uniqueId;
			
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}	
コード例 #3
0
		/// <summary>
		/// 	Update an existing row in the datasource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">PetShop.Business.Profiles object to update.</param>
		/// <remarks>
		///		After updating the datasource, the PetShop.Business.Profiles object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Update(TransactionManager transactionManager, PetShop.Business.Profiles entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Profiles_Update", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@UniqueId", DbType.Int32, entity.UniqueId );
			database.AddInParameter(commandWrapper, "@Username", DbType.AnsiString, entity.Username );
			database.AddInParameter(commandWrapper, "@ApplicationName", DbType.AnsiString, entity.ApplicationName );
			database.AddInParameter(commandWrapper, "@IsAnonymous", DbType.Boolean, (entity.IsAnonymous.HasValue ? (object) entity.IsAnonymous : System.DBNull.Value) );
			database.AddInParameter(commandWrapper, "@LastActivityDate", DbType.DateTime, (entity.LastActivityDate.HasValue ? (object) entity.LastActivityDate : System.DBNull.Value) );
			database.AddInParameter(commandWrapper, "@LastUpdatedDate", DbType.DateTime, (entity.LastUpdatedDate.HasValue ? (object) entity.LastUpdatedDate : System.DBNull.Value) );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Update", entity));

			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
			
			//Stop Tracking Now that it has been updated and persisted.
			if (DataRepository.Provider.EnableEntityTracking)
				EntityManager.StopTracking(entity.EntityTrackingKey);
			
			
			entity.AcceptChanges();
			
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Update", entity));

			return Convert.ToBoolean(results);
		}
コード例 #4
0
		/// <summary>
		/// 	Inserts a PetShop.Business.Order object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">PetShop.Business.Order object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the PetShop.Business.Order object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Insert(TransactionManager transactionManager, PetShop.Business.Order entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Orders_Insert", _useStoredProcedure);
			
			database.AddOutParameter(commandWrapper, "@OrderId", DbType.Int32, 4);
			database.AddInParameter(commandWrapper, "@UserId", DbType.AnsiString, entity.UserId );
			database.AddInParameter(commandWrapper, "@OrderDate", DbType.DateTime, entity.OrderDate );
			database.AddInParameter(commandWrapper, "@ShipAddr1", DbType.AnsiString, entity.ShipAddr1 );
			database.AddInParameter(commandWrapper, "@ShipAddr2", DbType.AnsiString, entity.ShipAddr2 );
			database.AddInParameter(commandWrapper, "@ShipCity", DbType.AnsiString, entity.ShipCity );
			database.AddInParameter(commandWrapper, "@ShipState", DbType.AnsiString, entity.ShipState );
			database.AddInParameter(commandWrapper, "@ShipZip", DbType.AnsiString, entity.ShipZip );
			database.AddInParameter(commandWrapper, "@ShipCountry", DbType.AnsiString, entity.ShipCountry );
			database.AddInParameter(commandWrapper, "@BillAddr1", DbType.AnsiString, entity.BillAddr1 );
			database.AddInParameter(commandWrapper, "@BillAddr2", DbType.AnsiString, entity.BillAddr2 );
			database.AddInParameter(commandWrapper, "@BillCity", DbType.AnsiString, entity.BillCity );
			database.AddInParameter(commandWrapper, "@BillState", DbType.AnsiString, entity.BillState );
			database.AddInParameter(commandWrapper, "@BillZip", DbType.AnsiString, entity.BillZip );
			database.AddInParameter(commandWrapper, "@BillCountry", DbType.AnsiString, entity.BillCountry );
			database.AddInParameter(commandWrapper, "@Courier", DbType.AnsiString, entity.Courier );
			database.AddInParameter(commandWrapper, "@TotalPrice", DbType.Decimal, entity.TotalPrice );
			database.AddInParameter(commandWrapper, "@BillToFirstName", DbType.AnsiString, entity.BillToFirstName );
			database.AddInParameter(commandWrapper, "@BillToLastName", DbType.AnsiString, entity.BillToLastName );
			database.AddInParameter(commandWrapper, "@ShipToFirstName", DbType.AnsiString, entity.ShipToFirstName );
			database.AddInParameter(commandWrapper, "@ShipToLastName", DbType.AnsiString, entity.ShipToLastName );
			database.AddInParameter(commandWrapper, "@AuthorizationNumber", DbType.Int32, entity.AuthorizationNumber );
			database.AddInParameter(commandWrapper, "@Locale", DbType.AnsiString, entity.Locale );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
				
			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
					
			object _orderId = database.GetParameterValue(commandWrapper, "@OrderId");
			entity.OrderId = (int)_orderId;
			
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}	
コード例 #5
0
		/// <summary>
		/// 	Update an existing row in the datasource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">PetShop.Business.Category object to update.</param>
		/// <remarks>
		///		After updating the datasource, the PetShop.Business.Category object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Update(TransactionManager transactionManager, PetShop.Business.Category entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Category_Update", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@CategoryId", DbType.AnsiString, entity.CategoryId );
			database.AddInParameter(commandWrapper, "@OriginalCategoryId", DbType.AnsiString, entity.OriginalCategoryId);
			database.AddInParameter(commandWrapper, "@Name", DbType.AnsiString, entity.Name );
			database.AddInParameter(commandWrapper, "@Descn", DbType.AnsiString, entity.Descn );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Update", entity));

			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
			
			//Stop Tracking Now that it has been updated and persisted.
			if (DataRepository.Provider.EnableEntityTracking)
				EntityManager.StopTracking(entity.EntityTrackingKey);
			
			entity.OriginalCategoryId = entity.CategoryId;
			
			entity.AcceptChanges();
			
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Update", entity));

			return Convert.ToBoolean(results);
		}
コード例 #6
0
		/// <summary>
		/// 	Inserts a PetShop.Business.OrderStatus object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">PetShop.Business.OrderStatus object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the PetShop.Business.OrderStatus object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Insert(TransactionManager transactionManager, PetShop.Business.OrderStatus entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.OrderStatus_Insert", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@OrderId", DbType.Int32, entity.OrderId );
			database.AddInParameter(commandWrapper, "@LineNum", DbType.Int32, entity.LineNum );
			database.AddInParameter(commandWrapper, "@Timestamp", DbType.DateTime, entity.Timestamp );
			database.AddInParameter(commandWrapper, "@Status", DbType.AnsiString, entity.Status );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
				
			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
					
			
			entity.OriginalOrderId = entity.OrderId;
			entity.OriginalLineNum = entity.LineNum;
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}	
コード例 #7
0
		/// <summary>
		/// 	Inserts a PetShop.Business.Supplier object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">PetShop.Business.Supplier object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the PetShop.Business.Supplier object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Insert(TransactionManager transactionManager, PetShop.Business.Supplier entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Supplier_Insert", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@SuppId", DbType.Int32, entity.SuppId );
			database.AddInParameter(commandWrapper, "@Name", DbType.AnsiString, entity.Name );
			database.AddInParameter(commandWrapper, "@Status", DbType.AnsiString, entity.Status );
			database.AddInParameter(commandWrapper, "@Addr1", DbType.AnsiString, entity.Addr1 );
			database.AddInParameter(commandWrapper, "@Addr2", DbType.AnsiString, entity.Addr2 );
			database.AddInParameter(commandWrapper, "@City", DbType.AnsiString, entity.City );
			database.AddInParameter(commandWrapper, "@State", DbType.AnsiString, entity.State );
			database.AddInParameter(commandWrapper, "@Zip", DbType.AnsiString, entity.Zip );
			database.AddInParameter(commandWrapper, "@Phone", DbType.AnsiString, entity.Phone );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
				
			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
					
			
			entity.OriginalSuppId = entity.SuppId;
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}	
コード例 #8
0
		/// <summary>
		/// 	Update an existing row in the datasource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">PetShop.Business.Account object to update.</param>
		/// <remarks>
		///		After updating the datasource, the PetShop.Business.Account object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Update(TransactionManager transactionManager, PetShop.Business.Account entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Account_Update", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@AccountId", DbType.Int32, entity.AccountId );
			database.AddInParameter(commandWrapper, "@UniqueId", DbType.Int32, entity.UniqueId );
			database.AddInParameter(commandWrapper, "@Email", DbType.AnsiString, entity.Email );
			database.AddInParameter(commandWrapper, "@FirstName", DbType.AnsiString, entity.FirstName );
			database.AddInParameter(commandWrapper, "@LastName", DbType.AnsiString, entity.LastName );
			database.AddInParameter(commandWrapper, "@Address1", DbType.AnsiString, entity.Address1 );
			database.AddInParameter(commandWrapper, "@Address2", DbType.AnsiString, entity.Address2 );
			database.AddInParameter(commandWrapper, "@City", DbType.AnsiString, entity.City );
			database.AddInParameter(commandWrapper, "@State", DbType.AnsiString, entity.State );
			database.AddInParameter(commandWrapper, "@Zip", DbType.AnsiString, entity.Zip );
			database.AddInParameter(commandWrapper, "@Country", DbType.AnsiString, entity.Country );
			database.AddInParameter(commandWrapper, "@Phone", DbType.AnsiString, entity.Phone );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Update", entity));

			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
			
			//Stop Tracking Now that it has been updated and persisted.
			if (DataRepository.Provider.EnableEntityTracking)
				EntityManager.StopTracking(entity.EntityTrackingKey);
			
			
			entity.AcceptChanges();
			
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Update", entity));

			return Convert.ToBoolean(results);
		}
コード例 #9
0
		/// <summary>
		/// 	Inserts a PetShop.Business.Account object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">PetShop.Business.Account object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the PetShop.Business.Account object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Insert(TransactionManager transactionManager, PetShop.Business.Account entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Account_Insert", _useStoredProcedure);
			
			database.AddOutParameter(commandWrapper, "@AccountId", DbType.Int32, 4);
			database.AddInParameter(commandWrapper, "@UniqueId", DbType.Int32, entity.UniqueId );
			database.AddInParameter(commandWrapper, "@Email", DbType.AnsiString, entity.Email );
			database.AddInParameter(commandWrapper, "@FirstName", DbType.AnsiString, entity.FirstName );
			database.AddInParameter(commandWrapper, "@LastName", DbType.AnsiString, entity.LastName );
			database.AddInParameter(commandWrapper, "@Address1", DbType.AnsiString, entity.Address1 );
			database.AddInParameter(commandWrapper, "@Address2", DbType.AnsiString, entity.Address2 );
			database.AddInParameter(commandWrapper, "@City", DbType.AnsiString, entity.City );
			database.AddInParameter(commandWrapper, "@State", DbType.AnsiString, entity.State );
			database.AddInParameter(commandWrapper, "@Zip", DbType.AnsiString, entity.Zip );
			database.AddInParameter(commandWrapper, "@Country", DbType.AnsiString, entity.Country );
			database.AddInParameter(commandWrapper, "@Phone", DbType.AnsiString, entity.Phone );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
				
			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
					
			object _accountId = database.GetParameterValue(commandWrapper, "@AccountId");
			entity.AccountId = (int)_accountId;
			
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}	
コード例 #10
0
		/// <summary>
		/// 	Inserts a PetShop.Business.Product object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">PetShop.Business.Product object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the PetShop.Business.Product object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Insert(TransactionManager transactionManager, PetShop.Business.Product entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Product_Insert", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@ProductId", DbType.AnsiString, entity.ProductId );
			database.AddInParameter(commandWrapper, "@CategoryId", DbType.AnsiString, entity.CategoryId );
			database.AddInParameter(commandWrapper, "@Name", DbType.AnsiString, entity.Name );
			database.AddInParameter(commandWrapper, "@Descn", DbType.AnsiString, entity.Descn );
			database.AddInParameter(commandWrapper, "@Image", DbType.AnsiString, entity.Image );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
				
			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
					
			
			entity.OriginalProductId = entity.ProductId;
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}	
コード例 #11
0
		/// <summary>
		/// 	Inserts a PetShop.Business.Cart object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">PetShop.Business.Cart object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the PetShop.Business.Cart object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Insert(TransactionManager transactionManager, PetShop.Business.Cart entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Cart_Insert", _useStoredProcedure);
			
			database.AddOutParameter(commandWrapper, "@CartId", DbType.Int32, 4);
			database.AddInParameter(commandWrapper, "@UniqueId", DbType.Int32, entity.UniqueId );
			database.AddInParameter(commandWrapper, "@ItemId", DbType.AnsiString, entity.ItemId );
			database.AddInParameter(commandWrapper, "@Name", DbType.AnsiString, entity.Name );
			database.AddInParameter(commandWrapper, "@Type", DbType.AnsiString, entity.Type );
			database.AddInParameter(commandWrapper, "@Price", DbType.Decimal, entity.Price );
			database.AddInParameter(commandWrapper, "@CategoryId", DbType.AnsiString, entity.CategoryId );
			database.AddInParameter(commandWrapper, "@ProductId", DbType.AnsiString, entity.ProductId );
			database.AddInParameter(commandWrapper, "@IsShoppingCart", DbType.Boolean, entity.IsShoppingCart );
			database.AddInParameter(commandWrapper, "@Quantity", DbType.Int32, entity.Quantity );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
				
			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
					
			object _cartId = database.GetParameterValue(commandWrapper, "@CartId");
			entity.CartId = (int)_cartId;
			
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}	
コード例 #12
0
		/// <summary>
		/// 	Update an existing row in the datasource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">PetShop.Business.Item object to update.</param>
		/// <remarks>
		///		After updating the datasource, the PetShop.Business.Item object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>
		/// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
		public override bool Update(TransactionManager transactionManager, PetShop.Business.Item entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Item_Update", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@ItemId", DbType.AnsiString, entity.ItemId );
			database.AddInParameter(commandWrapper, "@OriginalItemId", DbType.AnsiString, entity.OriginalItemId);
			database.AddInParameter(commandWrapper, "@ProductId", DbType.AnsiString, entity.ProductId );
			database.AddInParameter(commandWrapper, "@ListPrice", DbType.Decimal, (entity.ListPrice.HasValue ? (object) entity.ListPrice : System.DBNull.Value) );
			database.AddInParameter(commandWrapper, "@UnitCost", DbType.Decimal, (entity.UnitCost.HasValue ? (object) entity.UnitCost : System.DBNull.Value) );
			database.AddInParameter(commandWrapper, "@Supplier", DbType.Int32, (entity.Supplier.HasValue ? (object) entity.Supplier : System.DBNull.Value) );
			database.AddInParameter(commandWrapper, "@Status", DbType.AnsiString, entity.Status );
			database.AddInParameter(commandWrapper, "@Name", DbType.AnsiString, entity.Name );
			database.AddInParameter(commandWrapper, "@Image", DbType.AnsiString, entity.Image );
			
			int results = 0;
			
			//Provider Data Requesting Command Event
			OnDataRequesting(new CommandEventArgs(commandWrapper, "Update", entity));

			if (transactionManager != null)
			{
				results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
			}
			else
			{
				results = Utility.ExecuteNonQuery(database,commandWrapper);
			}
			
			//Stop Tracking Now that it has been updated and persisted.
			if (DataRepository.Provider.EnableEntityTracking)
				EntityManager.StopTracking(entity.EntityTrackingKey);
			
			entity.OriginalItemId = entity.ItemId;
			
			entity.AcceptChanges();
			
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Update", entity));

			return Convert.ToBoolean(results);
		}