Example #1
0
        //[Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Delete(ClientCriteria criteria)
        {
            bool cancel = false;

            OnDeleting(criteria, ref cancel);
            if (cancel)
            {
                return;
            }

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[spCFM_Client_Delete]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));

                    //result: The number of rows changed, inserted, or deleted. -1 for select statements; 0 if no rows were affected, or the statement failed.
                    int result = command.ExecuteNonQuery();
                    if (result == 0)
                    {
                        throw new DBConcurrencyException("The entity is out of date on the client. Please update the entity and try again. This could also be thrown if the sql statement failed to execute.");
                    }
                }
            }

            OnDeleted();
        }
Example #2
0
        public static void DeleteClient(System.Int32 clientID)
        {
            var criteria = new ClientCriteria {
                ClientID = clientID
            };


            new Client().DataPortal_Delete(criteria);
        }
Example #3
0
        /// <summary>
        /// Returns a <see cref="Client"/> object of the specified criteria.
        /// </summary>
        /// <param name="gLEntityID">No additional detail available.</param>
        /// <returns>A <see cref="Client"/> object of the specified criteria.</returns>
        public static Client GetByGLEntityID(System.Int32 gLEntityID)
        {
            var criteria = new ClientCriteria {
                GLEntityID = gLEntityID
            };


            return(new Client().DataPortal_Fetch(criteria));
        }
Example #4
0
        /// <summary>
        /// Returns a <see cref="Client"/> object of the specified criteria.
        /// </summary>
        /// <param name="statementDelOptID">No additional detail available.</param>
        /// <returns>A <see cref="Client"/> object of the specified criteria.</returns>
        public static Client GetByStatementDelOptID(System.Int32 statementDelOptID)
        {
            var criteria = new ClientCriteria {
                StatementDelOptID = statementDelOptID
            };


            return(new Client().DataPortal_Fetch(criteria));
        }
Example #5
0
        /// <summary>
        /// Returns a <see cref="Client"/> object of the specified criteria.
        /// </summary>
        /// <param name="createdBy">No additional detail available.</param>
        /// <returns>A <see cref="Client"/> object of the specified criteria.</returns>
        public static Client GetByCreatedBy(System.Int32 createdBy)
        {
            var criteria = new ClientCriteria {
                CreatedBy = createdBy
            };


            return(new Client().DataPortal_Fetch(criteria));
        }
Example #6
0
        /// <summary>
        /// Returns a <see cref="Client"/> object of the specified criteria.
        /// </summary>
        /// <param name="clientID">No additional detail available.</param>
        /// <returns>A <see cref="Client"/> object of the specified criteria.</returns>
        public static Client GetByClientID(System.Int32 clientID)
        {
            var criteria = new ClientCriteria {
                ClientID = clientID
            };


            return(new Client().DataPortal_Fetch(criteria));
        }
Example #7
0
        /// <summary>
        /// CodeSmith generated stub method that is called after the child <see cref="Client"/> object with the specified criteria has been deleted.
        /// </summary>
        //partial void OnDeleted();
        //partial void OnChildLoading(Csla.Core.IPropertyInfo childProperty, ref bool cancel);

        #endregion


        #region Exists Command

        /// <summary>
        /// Determines if a record exists in the Client table in the database for the specified criteria.
        /// </summary>
        /// <param name="criteria">The criteria parameter is an <see cref="Client"/> object.</param>
        /// <returns>A boolean value of true is returned if a record is found.</returns>
        public static Client Exists(ClientCriteria criteria)
        {
            try
            {
                return(new Client().DataPortal_Fetch(criteria));
            }
            catch (Exception ex)
            {
            }
            return(null);
        }
Example #8
0
        /// <summary>
        /// Returns a <see cref="Client"/> object of the specified criteria.
        /// </summary>
        /// <param name="updatedBy">No additional detail available.</param>
        /// <returns>A <see cref="Client"/> object of the specified criteria.</returns>
        public static Client GetByUpdatedBy(System.Int32?updatedBy)
        {
            var criteria = new ClientCriteria {
            };

            if (updatedBy.HasValue)
            {
                criteria.UpdatedBy = updatedBy.Value;
            }

            return(new Client().DataPortal_Fetch(criteria));
        }
Example #9
0
        /// <summary>
        /// Returns a <see cref="Client"/> object of the specified criteria.
        /// </summary>
        /// <param name="addressID">No additional detail available.</param>
        /// <returns>A <see cref="Client"/> object of the specified criteria.</returns>
        public static Client GetByAddressID(System.Int32?addressID)
        {
            var criteria = new ClientCriteria {
            };

            if (addressID.HasValue)
            {
                criteria.AddressID = addressID.Value;
            }

            return(new Client().DataPortal_Fetch(criteria));
        }
        private ClientList DataPortal_Fetch(ClientCriteria criteria)
        {
            bool cancel = false;

            OnFetching(criteria, ref cancel);
            if (cancel)
            {
                return(null);
            }

            //RaiseListChangedEvents = false;

            // Fetch Child objects.
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[spCFM_Client_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_NDISNumberHasValue", criteria.NDISNumberHasValue);
                    command.Parameters.AddWithValue("@p_EmailHasValue", criteria.EmailHasValue);
                    command.Parameters.AddWithValue("@p_AddressIDHasValue", criteria.AddressIDHasValue);
                    command.Parameters.AddWithValue("@p_UpdatedByHasValue", criteria.UpdatedByHasValue);
                    command.Parameters.AddWithValue("@p_UpdatedOnHasValue", criteria.UpdatedOnHasValue);
                    using (var reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            var rowParser = reader.GetRowParser <CFMData.Client>();
                            do
                            {
                                this.Add(CFMData.Client.GetClient(rowParser, reader));
                            }while(reader.Read());
                        }
                        OnFetched();
                        return(this);
                    }
                }
            }

            //RaiseListChangedEvents = true;
        }
Example #11
0
        private Client DataPortal_Fetch(ClientCriteria criteria)
        {
            bool cancel = false;

            OnFetching(criteria, ref cancel);
            if (cancel)
            {
                return(null);
            }
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[spCFM_Client_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_NDISNumberHasValue", criteria.NDISNumberHasValue);
                    command.Parameters.AddWithValue("@p_EmailHasValue", criteria.EmailHasValue);
                    command.Parameters.AddWithValue("@p_AddressIDHasValue", criteria.AddressIDHasValue);
                    command.Parameters.AddWithValue("@p_UpdatedByHasValue", criteria.UpdatedByHasValue);
                    command.Parameters.AddWithValue("@p_UpdatedOnHasValue", criteria.UpdatedOnHasValue);
                    using (var reader = command.ExecuteReader())
                    {
                        var rowParser = reader.GetRowParser <Client>();
                        if (reader.Read())
                        {
                            return(GetClient(rowParser, reader));
                        }
                        else
                        {
                            throw new Exception(String.Format("The record was not found in 'dbo.Client' using the following criteria: {0}.", criteria));
                        }
                    }
                }
            }
            OnFetched();
        }
Example #12
0
 /// <summary>
 /// CodeSmith generated stub method that is called when deleting the child <see cref="Client"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="ClientCriteria"/> object containing the criteria of the object to delete.</param>
 /// <param name="cancel">Value returned from the method indicating whether the object deletion should proceed.</param>
 //partial void OnDeleting(ClientCriteria criteria, ref bool cancel);
 /// <summary>
 /// CodeSmith generated stub method that is called when deleting the child <see cref="Client"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="ClientCriteria"/> object containing the criteria of the object to delete.</param>
 /// <param name="connection"></param>
 /// <param name="cancel">Value returned from the method indicating whether the object deletion should proceed.</param>
 partial void OnDeleting(ClientCriteria criteria, SqlConnection connection, ref bool cancel);
Example #13
0
 /// <summary>
 /// CodeSmith generated stub method that is called when fetching the child <see cref="Client"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="ClientCriteria"/> object containing the criteria of the object to fetch.</param>
 /// <param name="cancel">Value returned from the method indicating whether the object fetching should proceed.</param>
 partial void OnChildFetching(ClientCriteria criteria, ref bool cancel);
Example #14
0
 /// <summary>
 /// CodeSmith generated stub method that is called when deleting the <see cref="Client"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="ClientCriteria"/> object containing the criteria of the object to delete.</param>
 /// <param name="cancel">Value returned from the method indicating whether the object deletion should proceed.</param>
 partial void OnDeleting(ClientCriteria criteria, ref bool cancel);
Example #15
0
        public static ClientList GetByCriteria(ClientCriteria criteria)
        {
            return(new ClientList().DataPortal_Fetch(criteria));
//            return DataPortal.Fetch<ClientList>(criteria);
        }