Exemple #1
0
        //[Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Delete(BudgetApprovalCriteria 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_BudgetApproval_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();
        }
        public static void DeleteBudgetApproval(System.Int32 budgetApprovalID)
        {
            var criteria = new BudgetApprovalCriteria {
                BudgetApprovalID = budgetApprovalID
            };


            new BudgetApproval().DataPortal_Delete(criteria);
        }
        /// <summary>
        /// Returns a <see cref="BudgetApproval"/> object of the specified criteria.
        /// </summary>
        /// <param name="budgetID">No additional detail available.</param>
        /// <returns>A <see cref="BudgetApproval"/> object of the specified criteria.</returns>
        public static BudgetApproval GetByBudgetID(System.Int32 budgetID)
        {
            var criteria = new BudgetApprovalCriteria {
                BudgetID = budgetID
            };


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


            return(new BudgetApproval().DataPortal_Fetch(criteria));
        }
        /// <summary>
        /// CodeSmith generated stub method that is called after the child <see cref="BudgetApproval"/> 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 BudgetApproval table in the database for the specified criteria.
        /// </summary>
        /// <param name="criteria">The criteria parameter is an <see cref="BudgetApproval"/> object.</param>
        /// <returns>A boolean value of true is returned if a record is found.</returns>
        public static BudgetApproval Exists(BudgetApprovalCriteria criteria)
        {
            try
            {
                return(new BudgetApproval().DataPortal_Fetch(criteria));
            }
            catch (Exception ex)
            {
            }
            return(null);
        }
        /// <summary>
        /// Returns a <see cref="BudgetApproval"/> object of the specified criteria.
        /// </summary>
        /// <param name="updatedBy">No additional detail available.</param>
        /// <returns>A <see cref="BudgetApproval"/> object of the specified criteria.</returns>
        public static BudgetApproval GetByUpdatedBy(System.Int32?updatedBy)
        {
            var criteria = new BudgetApprovalCriteria {
            };

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

            return(new BudgetApproval().DataPortal_Fetch(criteria));
        }
        /// <summary>
        /// Returns a <see cref="BudgetApproval"/> object of the specified criteria.
        /// </summary>
        /// <param name="operationsUserID">No additional detail available.</param>
        /// <returns>A <see cref="BudgetApproval"/> object of the specified criteria.</returns>
        public static BudgetApproval GetByOperationsUserID(System.Int32?operationsUserID)
        {
            var criteria = new BudgetApprovalCriteria {
            };

            if (operationsUserID.HasValue)
            {
                criteria.OperationsUserID = operationsUserID.Value;
            }

            return(new BudgetApproval().DataPortal_Fetch(criteria));
        }
        /// <summary>
        /// Returns a <see cref="BudgetApproval"/> object of the specified criteria.
        /// </summary>
        /// <param name="administratorUserID">No additional detail available.</param>
        /// <returns>A <see cref="BudgetApproval"/> object of the specified criteria.</returns>
        public static BudgetApproval GetByAdministratorUserID(System.Int32?administratorUserID)
        {
            var criteria = new BudgetApprovalCriteria {
            };

            if (administratorUserID.HasValue)
            {
                criteria.AdministratorUserID = administratorUserID.Value;
            }

            return(new BudgetApproval().DataPortal_Fetch(criteria));
        }
Exemple #9
0
        private BudgetApprovalList DataPortal_Fetch(BudgetApprovalCriteria 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_BudgetApproval_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_AdministratorUserIDHasValue", criteria.AdministratorUserIDHasValue);
                    command.Parameters.AddWithValue("@p_OperationsUserIDHasValue", criteria.OperationsUserIDHasValue);
                    command.Parameters.AddWithValue("@p_ApprovalDateHasValue", criteria.ApprovalDateHasValue);
                    command.Parameters.AddWithValue("@p_ReminderDateHasValue", criteria.ReminderDateHasValue);
                    command.Parameters.AddWithValue("@p_ApprovalFileIDHasValue", criteria.ApprovalFileIDHasValue);
                    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.BudgetApproval>();
                            do
                            {
                                this.Add(CFMData.BudgetApproval.GetBudgetApproval(rowParser, reader));
                            }while(reader.Read());
                        }
                        OnFetched();
                        return(this);
                    }
                }
            }

            //RaiseListChangedEvents = true;
        }
Exemple #10
0
        private BudgetApproval DataPortal_Fetch(BudgetApprovalCriteria 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_BudgetApproval_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_AdministratorUserIDHasValue", criteria.AdministratorUserIDHasValue);
                    command.Parameters.AddWithValue("@p_OperationsUserIDHasValue", criteria.OperationsUserIDHasValue);
                    command.Parameters.AddWithValue("@p_ApprovalDateHasValue", criteria.ApprovalDateHasValue);
                    command.Parameters.AddWithValue("@p_ReminderDateHasValue", criteria.ReminderDateHasValue);
                    command.Parameters.AddWithValue("@p_ApprovalFileIDHasValue", criteria.ApprovalFileIDHasValue);
                    command.Parameters.AddWithValue("@p_UpdatedByHasValue", criteria.UpdatedByHasValue);
                    command.Parameters.AddWithValue("@p_UpdatedOnHasValue", criteria.UpdatedOnHasValue);
                    using (var reader = command.ExecuteReader())
                    {
                        var rowParser = reader.GetRowParser <BudgetApproval>();
                        if (reader.Read())
                        {
                            return(GetBudgetApproval(rowParser, reader));
                        }
                        else
                        {
                            throw new Exception(String.Format("The record was not found in 'dbo.BudgetApproval' using the following criteria: {0}.", criteria));
                        }
                    }
                }
            }
            OnFetched();
        }
 /// <summary>
 /// CodeSmith generated stub method that is called when deleting the child <see cref="BudgetApproval"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="BudgetApprovalCriteria"/> 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(BudgetApprovalCriteria criteria, ref bool cancel);
 /// <summary>
 /// CodeSmith generated stub method that is called when deleting the child <see cref="BudgetApproval"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="BudgetApprovalCriteria"/> 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(BudgetApprovalCriteria criteria, SqlConnection connection, ref bool cancel);
 /// <summary>
 /// CodeSmith generated stub method that is called when fetching the child <see cref="BudgetApproval"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="BudgetApprovalCriteria"/> 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(BudgetApprovalCriteria criteria, ref bool cancel);
 /// <summary>
 /// CodeSmith generated stub method that is called when deleting the <see cref="BudgetApproval"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="BudgetApprovalCriteria"/> 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(BudgetApprovalCriteria criteria, ref bool cancel);
Exemple #14
0
        public static BudgetApprovalList GetByCriteria(BudgetApprovalCriteria criteria)
        {
            return(new BudgetApprovalList().DataPortal_Fetch(criteria));
//            return DataPortal.Fetch<BudgetApprovalList>(criteria);
        }