/// <summary>
		/// 	Update an existing row in the datasource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">AppointmentSystem.Entities.Screen object to update.</param>
		/// <remarks>
		///		After updating the datasource, the AppointmentSystem.Entities.Screen 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, AppointmentSystem.Entities.Screen entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Screen_Update", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@ScreenCode", DbType.AnsiString, entity.ScreenCode );
			database.AddInParameter(commandWrapper, "@OriginalScreenCode", DbType.AnsiString, entity.OriginalScreenCode);
			database.AddInParameter(commandWrapper, "@ScreenName", DbType.String, entity.ScreenName );
			database.AddInParameter(commandWrapper, "@PriorityIndex", DbType.Int32, entity.PriorityIndex );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			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.OriginalScreenCode = entity.ScreenCode;
			
			entity.AcceptChanges();
			
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Update", entity));

			return Convert.ToBoolean(results);
		}
		/// <summary>
		/// 	Update an existing row in the datasource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">AppointmentSystem.Entities.GroupRole object to update.</param>
		/// <remarks>
		///		After updating the datasource, the AppointmentSystem.Entities.GroupRole 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, AppointmentSystem.Entities.GroupRole entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.GroupRole_Update", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@Id", DbType.Int64, entity.Id );
			database.AddInParameter(commandWrapper, "@GroupId", DbType.String, entity.GroupId );
			database.AddInParameter(commandWrapper, "@RoleId", DbType.Int32, (entity.RoleId.HasValue ? (object) entity.RoleId : System.DBNull.Value) );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			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);
		}
		/// <summary>
		/// 	Inserts a AppointmentSystem.Entities.RosterType object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">AppointmentSystem.Entities.RosterType object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the AppointmentSystem.Entities.RosterType 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, AppointmentSystem.Entities.RosterType entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.RosterType_Insert", _useStoredProcedure);
			
			database.AddOutParameter(commandWrapper, "@Id", DbType.Int32, 4);
			database.AddInParameter(commandWrapper, "@Title", DbType.String, entity.Title );
			database.AddInParameter(commandWrapper, "@IsBooked", DbType.Boolean, entity.IsBooked );
			database.AddInParameter(commandWrapper, "@ColorCode", DbType.AnsiString, entity.ColorCode );
			database.AddInParameter(commandWrapper, "@Note", DbType.String, entity.Note );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			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 _id = database.GetParameterValue(commandWrapper, "@Id");
			entity.Id = (System.Int32)_id;
			
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}	
		/// <summary>
		/// 	Update an existing row in the datasource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">AppointmentSystem.Entities.MessageConfig object to update.</param>
		/// <remarks>
		///		After updating the datasource, the AppointmentSystem.Entities.MessageConfig 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, AppointmentSystem.Entities.MessageConfig entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.MessageConfig_Update", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@MessageKey", DbType.AnsiString, entity.MessageKey );
			database.AddInParameter(commandWrapper, "@OriginalMessageKey", DbType.AnsiString, entity.OriginalMessageKey);
			database.AddInParameter(commandWrapper, "@MessageValue", DbType.String, entity.MessageValue );
			database.AddInParameter(commandWrapper, "@Description", DbType.String, entity.Description );
			
			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.OriginalMessageKey = entity.MessageKey;
			
			entity.AcceptChanges();
			
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Update", entity));

			return Convert.ToBoolean(results);
		}
		/// <summary>
		/// 	Inserts a AppointmentSystem.Entities.Status object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">AppointmentSystem.Entities.Status object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the AppointmentSystem.Entities.Status 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, AppointmentSystem.Entities.Status entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Status_Insert", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@Id", DbType.AnsiString, entity.Id );
			database.AddInParameter(commandWrapper, "@Title", DbType.String, entity.Title );
			database.AddInParameter(commandWrapper, "@ColorCode", DbType.AnsiString, entity.ColorCode );
			database.AddInParameter(commandWrapper, "@PriorityIndex", DbType.Int32, entity.PriorityIndex );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			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.OriginalId = entity.Id;
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}	
		/// <summary>
		/// 	Inserts a AppointmentSystem.Entities.Appointment object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">AppointmentSystem.Entities.Appointment object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the AppointmentSystem.Entities.Appointment 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, AppointmentSystem.Entities.Appointment entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Appointment_Insert", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@Id", DbType.String, entity.Id );
			database.AddInParameter(commandWrapper, "@PatientCode", DbType.StringFixedLength, entity.PatientCode );
			database.AddInParameter(commandWrapper, "@Username", DbType.String, entity.Username );
			database.AddInParameter(commandWrapper, "@RoomId", DbType.Int32, (entity.RoomId.HasValue ? (object) entity.RoomId  : System.DBNull.Value));
			database.AddInParameter(commandWrapper, "@ServicesId", DbType.Int32, (entity.ServicesId.HasValue ? (object) entity.ServicesId  : System.DBNull.Value));
			database.AddInParameter(commandWrapper, "@StatusId", DbType.AnsiString, entity.StatusId );
			database.AddInParameter(commandWrapper, "@AppointmentGroupId", DbType.Int32, (entity.AppointmentGroupId.HasValue ? (object) entity.AppointmentGroupId  : System.DBNull.Value));
			database.AddInParameter(commandWrapper, "@Note", DbType.String, entity.Note );
			database.AddInParameter(commandWrapper, "@StartTime", DbType.DateTime, (entity.StartTime.HasValue ? (object) entity.StartTime  : System.DBNull.Value));
			database.AddInParameter(commandWrapper, "@EndTime", DbType.DateTime, (entity.EndTime.HasValue ? (object) entity.EndTime  : System.DBNull.Value));
			database.AddInParameter(commandWrapper, "@RosterId", DbType.String, entity.RosterId );
			database.AddInParameter(commandWrapper, "@IsComplete", DbType.Boolean, entity.IsComplete );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			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.OriginalId = entity.Id;
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}	
		/// <summary>
		/// 	Update an existing row in the datasource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">AppointmentSystem.Entities.SmsReceiver object to update.</param>
		/// <remarks>
		///		After updating the datasource, the AppointmentSystem.Entities.SmsReceiver 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, AppointmentSystem.Entities.SmsReceiver entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.SmsReceiver_Update", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@Id", DbType.Int64, entity.Id );
			database.AddInParameter(commandWrapper, "@Mobile", DbType.AnsiString, entity.Mobile );
			database.AddInParameter(commandWrapper, "@FirstName", DbType.String, entity.FirstName );
			database.AddInParameter(commandWrapper, "@LastName", DbType.String, entity.LastName );
			database.AddInParameter(commandWrapper, "@UserType", DbType.Byte, entity.UserType );
			database.AddInParameter(commandWrapper, "@SmsId", DbType.Int64, entity.SmsId );
			database.AddInParameter(commandWrapper, "@IsSent", DbType.Boolean, entity.IsSent );
			database.AddInParameter(commandWrapper, "@SendingTimes", DbType.Int32, entity.SendingTimes );
			database.AddInParameter(commandWrapper, "@Note", DbType.String, entity.Note );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			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);
		}
		/// <summary>
		/// 	Inserts a AppointmentSystem.Entities.AppointmentHistory object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">AppointmentSystem.Entities.AppointmentHistory object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the AppointmentSystem.Entities.AppointmentHistory 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, AppointmentSystem.Entities.AppointmentHistory entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.AppointmentHistory_Insert", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@Guid", DbType.Guid, entity.Guid );
			database.AddInParameter(commandWrapper, "@AppointmentId", DbType.String, entity.AppointmentId );
			database.AddInParameter(commandWrapper, "@Note", DbType.String, entity.Note );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			
			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.OriginalGuid = entity.Guid;
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}	
		/// <summary>
		/// 	Inserts a AppointmentSystem.Entities.SmsLog object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">AppointmentSystem.Entities.SmsLog object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the AppointmentSystem.Entities.SmsLog 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, AppointmentSystem.Entities.SmsLog entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.SmsLog_Insert", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@Id", DbType.Guid, entity.Id );
			database.AddInParameter(commandWrapper, "@SmsId", DbType.Int64, entity.SmsId );
			database.AddInParameter(commandWrapper, "@Message", DbType.String, entity.Message );
			database.AddInParameter(commandWrapper, "@Mobile", DbType.AnsiString, entity.Mobile );
			database.AddInParameter(commandWrapper, "@Title", DbType.String, entity.Title );
			database.AddInParameter(commandWrapper, "@SendTime", DbType.DateTime, entity.SendTime );
			database.AddInParameter(commandWrapper, "@RealSendTime", DbType.DateTime, (entity.RealSendTime.HasValue ? (object) entity.RealSendTime  : System.DBNull.Value));
			database.AddInParameter(commandWrapper, "@IsSent", DbType.Boolean, entity.IsSent );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			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.OriginalId = entity.Id;
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}	
		/// <summary>
		/// 	Update an existing row in the datasource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">AppointmentSystem.Entities.Patient object to update.</param>
		/// <remarks>
		///		After updating the datasource, the AppointmentSystem.Entities.Patient 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, AppointmentSystem.Entities.Patient entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Patient_Update", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@PatientCode", DbType.StringFixedLength, entity.PatientCode );
			database.AddInParameter(commandWrapper, "@OriginalPatientCode", DbType.StringFixedLength, entity.OriginalPatientCode);
			database.AddInParameter(commandWrapper, "@FirstName", DbType.String, entity.FirstName );
			database.AddInParameter(commandWrapper, "@LastName", DbType.String, entity.LastName );
			database.AddInParameter(commandWrapper, "@MemberType", DbType.String, entity.MemberType );
			database.AddInParameter(commandWrapper, "@HomePhone", DbType.String, entity.HomePhone );
			database.AddInParameter(commandWrapper, "@WorkPhone", DbType.String, entity.WorkPhone );
			database.AddInParameter(commandWrapper, "@CellPhone", DbType.String, entity.CellPhone );
			database.AddInParameter(commandWrapper, "@Avatar", DbType.String, entity.Avatar );
			database.AddInParameter(commandWrapper, "@CompanyCode", DbType.String, entity.CompanyCode );
			database.AddInParameter(commandWrapper, "@Birthdate", DbType.DateTime, (entity.Birthdate.HasValue ? (object) entity.Birthdate : System.DBNull.Value) );
			database.AddInParameter(commandWrapper, "@IsFemale", DbType.Boolean, entity.IsFemale );
			database.AddInParameter(commandWrapper, "@Title", DbType.String, entity.Title );
			database.AddInParameter(commandWrapper, "@Note", DbType.String, entity.Note );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			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.OriginalPatientCode = entity.PatientCode;
			
			entity.AcceptChanges();
			
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Update", entity));

			return Convert.ToBoolean(results);
		}
		/// <summary>
		/// 	Inserts a AppointmentSystem.Entities.Sms object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">AppointmentSystem.Entities.Sms object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the AppointmentSystem.Entities.Sms 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, AppointmentSystem.Entities.Sms entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Sms_Insert", _useStoredProcedure);
			
			database.AddOutParameter(commandWrapper, "@Id", DbType.Int64, 8);
			database.AddInParameter(commandWrapper, "@Message", DbType.String, entity.Message );
			database.AddInParameter(commandWrapper, "@SmsType", DbType.Byte, entity.SmsType );
			database.AddInParameter(commandWrapper, "@SendTime", DbType.DateTime, entity.SendTime );
			database.AddInParameter(commandWrapper, "@IsSendNow", DbType.Boolean, entity.IsSendNow );
			database.AddInParameter(commandWrapper, "@IsSent", DbType.Boolean, entity.IsSent );
			database.AddInParameter(commandWrapper, "@SendingTimes", DbType.Int32, entity.SendingTimes );
			database.AddInParameter(commandWrapper, "@AppointmentId", DbType.String, entity.AppointmentId );
			database.AddInParameter(commandWrapper, "@Note", DbType.String, entity.Note );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			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 _id = database.GetParameterValue(commandWrapper, "@Id");
			entity.Id = (System.Int64)_id;
			
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}	
		/// <summary>
		/// 	Inserts a AppointmentSystem.Entities.Users object into the datasource using a transaction.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">AppointmentSystem.Entities.Users object to insert.</param>
		/// <remarks>
		///		After inserting into the datasource, the AppointmentSystem.Entities.Users 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, AppointmentSystem.Entities.Users entity)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Users_Insert", _useStoredProcedure);
			
			database.AddInParameter(commandWrapper, "@Username", DbType.String, entity.Username );
			database.AddInParameter(commandWrapper, "@Password", DbType.String, entity.Password );
			database.AddInParameter(commandWrapper, "@Title", DbType.String, entity.Title );
			database.AddInParameter(commandWrapper, "@Firstname", DbType.String, entity.Firstname );
			database.AddInParameter(commandWrapper, "@Lastname", DbType.String, entity.Lastname );
			database.AddInParameter(commandWrapper, "@DisplayName", DbType.String, entity.DisplayName );
			database.AddInParameter(commandWrapper, "@CellPhone", DbType.String, entity.CellPhone );
			database.AddInParameter(commandWrapper, "@Email", DbType.String, entity.Email );
			database.AddInParameter(commandWrapper, "@Avatar", DbType.String, entity.Avatar );
			database.AddInParameter(commandWrapper, "@Note", DbType.String, entity.Note );
			database.AddInParameter(commandWrapper, "@UserGroupId", DbType.String, entity.UserGroupId );
			database.AddInParameter(commandWrapper, "@ServicesId", DbType.Int32, (entity.ServicesId.HasValue ? (object) entity.ServicesId  : System.DBNull.Value));
			database.AddInParameter(commandWrapper, "@IsFemale", DbType.Boolean, entity.IsFemale );
			database.AddInParameter(commandWrapper, "@IsDisabled", DbType.Boolean, entity.IsDisabled );
			database.AddInParameter(commandWrapper, "@CreateUser", DbType.String, entity.CreateUser );
			database.AddInParameter(commandWrapper, "@CreateDate", DbType.DateTime, entity.CreateDate );
			database.AddInParameter(commandWrapper, "@UpdateUser", DbType.String, entity.UpdateUser );
			database.AddInParameter(commandWrapper, "@UpdateDate", DbType.DateTime, entity.UpdateDate );
			
			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.OriginalUsername = entity.Username;
			
			entity.AcceptChanges();
	
			//Provider Data Requested Command Event
			OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

			return Convert.ToBoolean(results);
		}