// [Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Insert()
        {
            bool cancel = false;

            OnInserting(ref cancel);
            if (cancel)
            {
                return;
            }
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                SqlTransaction trans = connection.BeginTransaction();
                try
                {
                    using (var command = new SqlCommand("[dbo].[spCFM_ApplicationPermission_Insert]", connection, trans))
                    {
                        command.CommandType = CommandType.StoredProcedure;

                        command.Parameters.AddWithValue("@p_ApplicationPermissionID", this.ApplicationPermissionID);
                        command.Parameters["@p_ApplicationPermissionID"].Direction = ParameterDirection.Output;
                        command.Parameters.AddWithValue("@p_ApplicationRoleID", ADOHelper.NullCheck(this.ApplicationRoleID));
                        command.Parameters.AddWithValue("@p_ApplicationUserID", ADOHelper.NullCheck(this.ApplicationUserID));
                        command.Parameters.AddWithValue("@p_BusinessAreaID", ADOHelper.NullCheck(this.BusinessAreaID));
                        command.Parameters.AddWithValue("@p_BusinessDivisionID", ADOHelper.NullCheck(this.BusinessDivisionID));
                        command.Parameters.AddWithValue("@p_BusinessEntityID", ADOHelper.NullCheck(this.BusinessEntityID));
                        command.Parameters.AddWithValue("@p_HomeID", ADOHelper.NullCheck(this.HomeID));
                        command.Parameters.AddWithValue("@p_ClientID", ADOHelper.NullCheck(this.ClientID));
                        command.Parameters.AddWithValue("@p_IsActive", this.IsActive);
                        command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy);
                        command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                        command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy));
                        command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn));
                        command.ExecuteNonQuery();
                        _applicationPermissionIDProperty = (System.Int32)command.Parameters["@p_ApplicationPermissionID"].Value;
                    }

                    UpdateChildren(this, connection, trans);

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw;
                }
            }


            OnInserted();
        }
Esempio n. 2
0
        // [Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Update()
        {
            bool cancel = false;

            OnUpdating(ref cancel);
            if (cancel)
            {
                return;
            }
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                SqlTransaction trans = connection.BeginTransaction();
                try
                {
                    using (var command = new SqlCommand("[dbo].[spCFM_BudgetApproval_Update]", connection, trans))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.AddWithValue("@p_BudgetApprovalID", this.BudgetApprovalID);
                        command.Parameters.AddWithValue("@p_BudgetID", this.BudgetID);
                        command.Parameters.AddWithValue("@p_AdministratorUserID", ADOHelper.NullCheck(this.AdministratorUserID));
                        command.Parameters.AddWithValue("@p_OperationsUserID", ADOHelper.NullCheck(this.OperationsUserID));
                        command.Parameters.AddWithValue("@p_ApprovalDate", ADOHelper.NullCheck(this.ApprovalDate));
                        command.Parameters.AddWithValue("@p_Status", this.Status);
                        command.Parameters.AddWithValue("@p_ReminderDate", ADOHelper.NullCheck(this.ReminderDate));
                        command.Parameters.AddWithValue("@p_ApprovalFileID", ADOHelper.NullCheck(this.ApprovalFileID));
                        command.Parameters.AddWithValue("@p_IsActive", this.IsActive);
                        command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy);
                        command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                        command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy));
                        command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn));
                        //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.");
                        }
                    }
                    UpdateChildren(this, connection, trans);
                    //FieldManager.UpdateChildren(this, connection);
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw;
                }
            }

            OnUpdated();
        }
        private BankTransaction DataPortal_Fetch(BankTransactionCriteria 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_BankTransaction_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_BankAccountIDHasValue", criteria.BankAccountIDHasValue);
                    command.Parameters.AddWithValue("@p_NarrativeHasValue", criteria.NarrativeHasValue);
                    command.Parameters.AddWithValue("@p_SerialNumberHasValue", criteria.SerialNumberHasValue);
                    command.Parameters.AddWithValue("@p_SegmentAccountNumberHasValue", criteria.SegmentAccountNumberHasValue);
                    command.Parameters.AddWithValue("@p_PaymentTransactionIDHasValue", criteria.PaymentTransactionIDHasValue);
                    command.Parameters.AddWithValue("@p_InstructionIDHasValue", criteria.InstructionIDHasValue);
                    command.Parameters.AddWithValue("@p_ValueDateHasValue", criteria.ValueDateHasValue);
                    command.Parameters.AddWithValue("@p_TransactionDateTimeUTCHasValue", criteria.TransactionDateTimeUTCHasValue);
                    command.Parameters.AddWithValue("@p_DebtorNameHasValue", criteria.DebtorNameHasValue);
                    command.Parameters.AddWithValue("@p_CreditorNameHasValue", criteria.CreditorNameHasValue);
                    command.Parameters.AddWithValue("@p_EndToEndIDHasValue", criteria.EndToEndIDHasValue);
                    command.Parameters.AddWithValue("@p_RemittanceInformation1HasValue", criteria.RemittanceInformation1HasValue);
                    command.Parameters.AddWithValue("@p_RemittanceInfoformation2HasValue", criteria.RemittanceInfoformation2HasValue);
                    command.Parameters.AddWithValue("@p_PayiDTypeHasValue", criteria.PayiDTypeHasValue);
                    command.Parameters.AddWithValue("@p_PayIDHasValue", criteria.PayIDHasValue);
                    command.Parameters.AddWithValue("@p_ReversalreasonCodeHasValue", criteria.ReversalreasonCodeHasValue);
                    command.Parameters.AddWithValue("@p_OriginalTransactionIDHasValue", criteria.OriginalTransactionIDHasValue);
                    command.Parameters.AddWithValue("@p_UpdatedByHasValue", criteria.UpdatedByHasValue);
                    command.Parameters.AddWithValue("@p_UpdatedOnHasValue", criteria.UpdatedOnHasValue);
                    using (var reader = command.ExecuteReader())
                    {
                        var rowParser = reader.GetRowParser <BankTransaction>();
                        if (reader.Read())
                        {
                            return(GetBankTransaction(rowParser, reader));
                        }
                        else
                        {
                            throw new Exception(String.Format("The record was not found in 'dbo.BankTransaction' using the following criteria: {0}.", criteria));
                        }
                    }
                }
            }
            OnFetched();
        }
        private GlList DataPortal_Fetch(GlCriteria 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_Gl_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_PostingDateHasValue", criteria.PostingDateHasValue);
                    command.Parameters.AddWithValue("@p_GLCostCentreEntityIDHasValue", criteria.GLCostCentreEntityIDHasValue);
                    command.Parameters.AddWithValue("@p_BankTransactionIDHasValue", criteria.BankTransactionIDHasValue);
                    command.Parameters.AddWithValue("@p_CategoryIDHasValue", criteria.CategoryIDHasValue);
                    command.Parameters.AddWithValue("@p_ExGstAMountHasValue", criteria.ExGstAMountHasValue);
                    command.Parameters.AddWithValue("@p_GSTAmountHasValue", criteria.GSTAmountHasValue);
                    command.Parameters.AddWithValue("@p_DRAmountHasValue", criteria.DRAmountHasValue);
                    command.Parameters.AddWithValue("@p_CRAmountHasValue", criteria.CRAmountHasValue);
                    command.Parameters.AddWithValue("@p_HouseBudgetIDHasValue", criteria.HouseBudgetIDHasValue);
                    command.Parameters.AddWithValue("@p_ClientBudgetIDHasValue", criteria.ClientBudgetIDHasValue);
                    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.Gl>();
                            do
                            {
                                this.Add(CFMData.Gl.GetGl(rowParser, reader));
                            }while(reader.Read());
                        }
                        OnFetched();
                        return(this);
                    }
                }
            }

            //RaiseListChangedEvents = true;
        }
        // [Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Insert()
        {
            bool cancel = false;

            OnInserting(ref cancel);
            if (cancel)
            {
                return;
            }
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                SqlTransaction trans = connection.BeginTransaction();
                try
                {
                    using (var command = new SqlCommand("[dbo].[spCFM_FinAdministrator_Insert]", connection, trans))
                    {
                        command.CommandType = CommandType.StoredProcedure;

                        command.Parameters.AddWithValue("@p_FinAdministratorID", this.FinAdministratorID);
                        command.Parameters["@p_FinAdministratorID"].Direction = ParameterDirection.Output;
                        command.Parameters.AddWithValue("@p_GLEntityID", this.GLEntityID);
                        command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(this.Name));
                        command.Parameters.AddWithValue("@p_isOrganisation", this.IsOrganisation);
                        command.Parameters.AddWithValue("@p_Email", ADOHelper.NullCheck(this.Email));
                        command.Parameters.AddWithValue("@p_AddressID", ADOHelper.NullCheck(this.AddressID));
                        command.Parameters.AddWithValue("@p_HasDirectDebit", this.HasDirectDebit);
                        command.Parameters.AddWithValue("@p_BankAccountID", ADOHelper.NullCheck(this.BankAccountID));
                        command.Parameters.AddWithValue("@p_IsActive", this.IsActive);
                        command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy);
                        command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                        command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy));
                        command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn));
                        command.ExecuteNonQuery();
                        _finAdministratorIDProperty = (System.Int32)command.Parameters["@p_FinAdministratorID"].Value;
                    }

                    UpdateChildren(this, connection, trans);

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw;
                }
            }


            OnInserted();
        }
Esempio n. 6
0
        // [Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Insert()
        {
            bool cancel = false;

            OnInserting(ref cancel);
            if (cancel)
            {
                return;
            }
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                SqlTransaction trans = connection.BeginTransaction();
                try
                {
                    using (var command = new SqlCommand("[dbo].[spCFM_BudgetApproval_Insert]", connection, trans))
                    {
                        command.CommandType = CommandType.StoredProcedure;

                        command.Parameters.AddWithValue("@p_BudgetApprovalID", this.BudgetApprovalID);
                        command.Parameters["@p_BudgetApprovalID"].Direction = ParameterDirection.Output;
                        command.Parameters.AddWithValue("@p_BudgetID", this.BudgetID);
                        command.Parameters.AddWithValue("@p_AdministratorUserID", ADOHelper.NullCheck(this.AdministratorUserID));
                        command.Parameters.AddWithValue("@p_OperationsUserID", ADOHelper.NullCheck(this.OperationsUserID));
                        command.Parameters.AddWithValue("@p_ApprovalDate", ADOHelper.NullCheck(this.ApprovalDate));
                        command.Parameters.AddWithValue("@p_Status", this.Status);
                        command.Parameters.AddWithValue("@p_ReminderDate", ADOHelper.NullCheck(this.ReminderDate));
                        command.Parameters.AddWithValue("@p_ApprovalFileID", ADOHelper.NullCheck(this.ApprovalFileID));
                        command.Parameters.AddWithValue("@p_IsActive", this.IsActive);
                        command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy);
                        command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                        command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy));
                        command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn));
                        command.ExecuteNonQuery();
                        _budgetApprovalIDProperty = (System.Int32)command.Parameters["@p_BudgetApprovalID"].Value;
                    }

                    UpdateChildren(this, connection, trans);

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw;
                }
            }


            OnInserted();
        }
Esempio n. 7
0
        /// <summary>
        /// Updates the corresponding record in the data base with the information in the current
        ///    CSLA editable child business object of type <see cref="GLAccountType"/>
        /// </summary>
        /// <returns></returns>
        public void Child_Update(SqlConnection connection, SqlTransaction trans)
        {
            bool cancel = false;

            OnChildUpdating(connection, ref cancel, trans);
            if (cancel)
            {
                return;
            }

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            using (var command = new SqlCommand("[dbo].[spCFM_GLAccountType_Update]", connection, trans))
            {
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@p_OriginalGLAccountTypeID", this.OriginalGLAccountTypeID);
                command.Parameters.AddWithValue("@p_GLAccountTypeID", this.GLAccountTypeID);
                command.Parameters.AddWithValue("@p_Code", ADOHelper.NullCheck(this.Code));
                command.Parameters.AddWithValue("@p_Name", this.Name);
                command.Parameters.AddWithValue("@p_GLEntityTypeID", ADOHelper.NullCheck(this.GLEntityTypeID));
                command.Parameters.AddWithValue("@p_IsActive", this.IsActive);
                command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy);
                command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy));
                command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn));
                command.Parameters.AddWithValue("@p_CanHaveBankAccount", this.CanHaveBankAccount);
                command.Parameters.AddWithValue("@p_CanHaveBankCards", this.CanHaveBankCards);
                command.Parameters.AddWithValue("@p_IsMandatory", this.IsMandatory);

                //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.");
                }

                // Update non-identity primary key value.
                _gLAccountTypeIDProperty = (System.Int32)command.Parameters["@p_GLAccountTypeID"].Value;

                // Update non-identity primary key value.
                _originalGLAccountTypeIDProperty = this.GLAccountTypeID;
            }

            UpdateChildren(this, connection, trans);

            OnChildUpdated();
        }
Esempio n. 8
0
        // [Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Insert()
        {
            bool cancel = false;

            OnInserting(ref cancel);
            if (cancel)
            {
                return;
            }
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                SqlTransaction trans = connection.BeginTransaction();
                try
                {
                    using (var command = new SqlCommand("[dbo].[spCFM_BankAccountCard_Insert]", connection, trans))
                    {
                        command.CommandType = CommandType.StoredProcedure;

                        command.Parameters.AddWithValue("@p_BankAccountCardID", this.BankAccountCardID);
                        command.Parameters["@p_BankAccountCardID"].Direction = ParameterDirection.Output;
                        command.Parameters.AddWithValue("@p_BankAccountID", this.BankAccountID);
                        command.Parameters.AddWithValue("@p_CardNumber", this.CardNumber);
                        command.Parameters.AddWithValue("@p_ExpDate", this.ExpDate);
                        command.Parameters.AddWithValue("@p_HeldByStaffID", ADOHelper.NullCheck(this.HeldByStaffID));
                        command.Parameters.AddWithValue("@p_HeldFrom", ADOHelper.NullCheck(this.HeldFrom));
                        command.Parameters.AddWithValue("@p_HeldTo", ADOHelper.NullCheck(this.HeldTo));
                        command.Parameters.AddWithValue("@p_IsActive", this.IsActive);
                        command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy);
                        command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                        command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy));
                        command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn));
                        command.ExecuteNonQuery();
                        _bankAccountCardIDProperty = (System.Int32)command.Parameters["@p_BankAccountCardID"].Value;
                    }

                    UpdateChildren(this, connection, trans);

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw;
                }
            }


            OnInserted();
        }
Esempio n. 9
0
        // [Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Insert()
        {
            bool cancel = false;

            OnInserting(ref cancel);
            if (cancel)
            {
                return;
            }
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                SqlTransaction trans = connection.BeginTransaction();
                try
                {
                    using (var command = new SqlCommand("[dbo].[spCFM_DataOptionType_Insert]", connection, trans))
                    {
                        command.CommandType = CommandType.StoredProcedure;

                        command.Parameters.AddWithValue("@p_DataOptionTypeID", this.DataOptionTypeID);
                        command.Parameters["@p_DataOptionTypeID"].Direction = ParameterDirection.Output;
                        command.Parameters.AddWithValue("@p_DataOptionTypeSortID", ADOHelper.NullCheck(this.DataOptionTypeSortID));
                        command.Parameters.AddWithValue("@p_Code", this.Code);
                        command.Parameters.AddWithValue("@p_Name", this.Name);
                        command.Parameters.AddWithValue("@p_AllowChildNodes", this.AllowChildNodes);
                        command.Parameters.AddWithValue("@p_MaxChildLevels", this.MaxChildLevels);
                        command.Parameters.AddWithValue("@p_IsSystem", this.IsSystem);
                        command.Parameters.AddWithValue("@p_DefaultValue", ADOHelper.NullCheck(this.DefaultValue));
                        command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                        command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy);
                        command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn));
                        command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy));
                        command.ExecuteNonQuery();
                        _dataOptionTypeIDProperty = (System.Int32)command.Parameters["@p_DataOptionTypeID"].Value;
                    }

                    UpdateChildren(this, connection, trans);

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw;
                }
            }


            OnInserted();
        }
Esempio n. 10
0
        // [Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Update()
        {
            bool cancel = false;

            OnUpdating(ref cancel);
            if (cancel)
            {
                return;
            }
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                SqlTransaction trans = connection.BeginTransaction();
                try
                {
                    using (var command = new SqlCommand("[dbo].[spCFM_DataOptionType_Update]", connection, trans))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.AddWithValue("@p_DataOptionTypeID", this.DataOptionTypeID);
                        command.Parameters.AddWithValue("@p_DataOptionTypeSortID", ADOHelper.NullCheck(this.DataOptionTypeSortID));
                        command.Parameters.AddWithValue("@p_Code", this.Code);
                        command.Parameters.AddWithValue("@p_Name", this.Name);
                        command.Parameters.AddWithValue("@p_AllowChildNodes", this.AllowChildNodes);
                        command.Parameters.AddWithValue("@p_MaxChildLevels", this.MaxChildLevels);
                        command.Parameters.AddWithValue("@p_IsSystem", this.IsSystem);
                        command.Parameters.AddWithValue("@p_DefaultValue", ADOHelper.NullCheck(this.DefaultValue));
                        command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                        command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy);
                        command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn));
                        command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy));
                        //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.");
                        }
                    }
                    UpdateChildren(this, connection, trans);
                    //FieldManager.UpdateChildren(this, connection);
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw;
                }
            }

            OnUpdated();
        }
Esempio n. 11
0
        // [Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Insert()
        {
            bool cancel = false;

            OnInserting(ref cancel);
            if (cancel)
            {
                return;
            }
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                SqlTransaction trans = connection.BeginTransaction();
                try
                {
                    using (var command = new SqlCommand("[dbo].[spCFM_BudgetLine_Insert]", connection, trans))
                    {
                        command.CommandType = CommandType.StoredProcedure;

                        command.Parameters.AddWithValue("@p_BudgetLineID", this.BudgetLineID);
                        command.Parameters["@p_BudgetLineID"].Direction = ParameterDirection.Output;
                        command.Parameters.AddWithValue("@p_BudgetID", this.BudgetID);
                        command.Parameters.AddWithValue("@p_LineID", this.LineID);
                        command.Parameters.AddWithValue("@p_OrderNo", this.OrderNo);
                        command.Parameters.AddWithValue("@p_CategoryID", this.CategoryID);
                        command.Parameters.AddWithValue("@p_FortnightAmount", ADOHelper.NullCheck(this.FortnightAmount));
                        command.Parameters.AddWithValue("@p_RequiresReceipt", this.RequiresReceipt);
                        command.Parameters.AddWithValue("@p_IsActive", this.IsActive);
                        command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy);
                        command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                        command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy));
                        command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn));
                        command.ExecuteNonQuery();
                        _budgetLineIDProperty = (System.Int32)command.Parameters["@p_BudgetLineID"].Value;
                    }

                    UpdateChildren(this, connection, trans);

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw;
                }
            }


            OnInserted();
        }
Esempio n. 12
0
        // [Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Insert()
        {
            bool cancel = false;

            OnInserting(ref cancel);
            if (cancel)
            {
                return;
            }
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                SqlTransaction trans = connection.BeginTransaction();
                try
                {
                    using (var command = new SqlCommand("[dbo].[spCFM_GLAccountType_Insert]", connection, trans))
                    {
                        command.CommandType = CommandType.StoredProcedure;

                        command.Parameters.AddWithValue("@p_GLAccountTypeID", this.GLAccountTypeID);
                        command.Parameters.AddWithValue("@p_Code", ADOHelper.NullCheck(this.Code));
                        command.Parameters.AddWithValue("@p_Name", this.Name);
                        command.Parameters.AddWithValue("@p_GLEntityTypeID", ADOHelper.NullCheck(this.GLEntityTypeID));
                        command.Parameters.AddWithValue("@p_IsActive", this.IsActive);
                        command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy);
                        command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                        command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy));
                        command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn));
                        command.Parameters.AddWithValue("@p_CanHaveBankAccount", this.CanHaveBankAccount);
                        command.Parameters.AddWithValue("@p_CanHaveBankCards", this.CanHaveBankCards);
                        command.Parameters.AddWithValue("@p_IsMandatory", this.IsMandatory);
                        command.ExecuteNonQuery();
                    }

                    _originalGLAccountTypeIDProperty = this.GLAccountTypeID;
                    UpdateChildren(this, connection, trans);

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw;
                }
            }


            OnInserted();
        }
Esempio n. 13
0
        // [Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Insert()
        {
            bool cancel = false;

            OnInserting(ref cancel);
            if (cancel)
            {
                return;
            }
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                SqlTransaction trans = connection.BeginTransaction();
                try
                {
                    using (var command = new SqlCommand("[dbo].[spCFM_Address_Insert]", connection, trans))
                    {
                        command.CommandType = CommandType.StoredProcedure;

                        command.Parameters.AddWithValue("@p_AddressID", this.AddressID);
                        command.Parameters["@p_AddressID"].Direction = ParameterDirection.Output;
                        command.Parameters.AddWithValue("@p_Street", ADOHelper.NullCheck(this.Street));
                        command.Parameters.AddWithValue("@p_Suburb", ADOHelper.NullCheck(this.Suburb));
                        command.Parameters.AddWithValue("@p_StateID", ADOHelper.NullCheck(this.StateID));
                        command.Parameters.AddWithValue("@p_CountryID", ADOHelper.NullCheck(this.CountryID));
                        command.Parameters.AddWithValue("@p_PostCode", ADOHelper.NullCheck(this.PostCode));
                        command.Parameters.AddWithValue("@p_IsActive", this.IsActive);
                        command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy);
                        command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                        command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy));
                        command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn));
                        command.ExecuteNonQuery();
                        _addressIDProperty = (System.Int32)command.Parameters["@p_AddressID"].Value;
                    }

                    UpdateChildren(this, connection, trans);

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw;
                }
            }


            OnInserted();
        }
        private void AddAddressParams(SqlCommand command, AddressDTO address, string prefix)
        {
            bool    hasPhysicalAddress = HasAddress(address);
            Address physicalAddress    = null;

            if (hasPhysicalAddress)
            {
                command.Parameters.AddWithValue("@p_" + prefix + "Street", ADOHelper.NullCheck(address.Street));
                command.Parameters.AddWithValue("@p_" + prefix + "Suburb", ADOHelper.NullCheck(address.Suburb));
                command.Parameters.AddWithValue("@p_" + prefix + "StateID", ADOHelper.NullCheck(address.StateID));
                command.Parameters.AddWithValue("@p_" + prefix + "CountryID", ADOHelper.NullCheck(address.CountryID));
                command.Parameters.AddWithValue("@p_" + prefix + "PostCode", ADOHelper.NullCheck(address.PostCode));
                command.Parameters.AddWithValue("@p_" + prefix + "AddressID", ADOHelper.NullCheck(address.AddressID));
            }
        }
Esempio n. 15
0
        // [Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Insert()
        {
            bool cancel = false;

            OnInserting(ref cancel);
            if (cancel)
            {
                return;
            }
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                SqlTransaction trans = connection.BeginTransaction();
                try
                {
                    using (var command = new SqlCommand("[dbo].[spCFM_FinAdministratorClient_Insert]", connection, trans))
                    {
                        command.CommandType = CommandType.StoredProcedure;

                        command.Parameters.AddWithValue("@p_FinAdministratorClientID", this.FinAdministratorClientID);
                        command.Parameters["@p_FinAdministratorClientID"].Direction = ParameterDirection.Output;
                        command.Parameters.AddWithValue("@p_FinAdministratorID", this.FinAdministratorID);
                        command.Parameters.AddWithValue("@p_ClientId", this.ClientId);
                        command.Parameters.AddWithValue("@p_StartDate", this.StartDate);
                        command.Parameters.AddWithValue("@p_EndDate", ADOHelper.NullCheck(this.EndDate));
                        command.Parameters.AddWithValue("@p_IsActive", this.IsActive);
                        command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy);
                        command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                        command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy));
                        command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn));
                        command.ExecuteNonQuery();
                    }

                    _originalFinAdministratorIDProperty = this.FinAdministratorID;
                    UpdateChildren(this, connection, trans);

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw;
                }
            }


            OnInserted();
        }
Esempio n. 16
0
        private ApplicationPermissionList DataPortal_Fetch(ApplicationPermissionCriteria 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_ApplicationPermission_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_ApplicationRoleIDHasValue", criteria.ApplicationRoleIDHasValue);
                    command.Parameters.AddWithValue("@p_ApplicationUserIDHasValue", criteria.ApplicationUserIDHasValue);
                    command.Parameters.AddWithValue("@p_BusinessAreaIDHasValue", criteria.BusinessAreaIDHasValue);
                    command.Parameters.AddWithValue("@p_BusinessDivisionIDHasValue", criteria.BusinessDivisionIDHasValue);
                    command.Parameters.AddWithValue("@p_BusinessEntityIDHasValue", criteria.BusinessEntityIDHasValue);
                    command.Parameters.AddWithValue("@p_HomeIDHasValue", criteria.HomeIDHasValue);
                    command.Parameters.AddWithValue("@p_ClientIDHasValue", criteria.ClientIDHasValue);
                    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.ApplicationPermission>();
                            do
                            {
                                this.Add(CFMData.ApplicationPermission.GetApplicationPermission(rowParser, reader));
                            }while(reader.Read());
                        }
                        OnFetched();
                        return(this);
                    }
                }
            }

            //RaiseListChangedEvents = true;
        }
        public void Child_Update(MailingTemplate mailingTemplate, SqlConnection connection, SqlTransaction trans)
        {
            bool cancel = false;

            OnChildUpdating(mailingTemplate, connection, ref cancel, trans);
            if (cancel)
            {
                return;
            }

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            using (var command = new SqlCommand("[dbo].[spCFM_EmailQueue_Update]", connection, trans))
            {
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@p_EmailQueueID", this.EmailQueueID);
                command.Parameters.AddWithValue("@p_MailingTemplateID", ADOHelper.NullCheck(mailingTemplate != null ? mailingTemplate.MailingTemplateID : this.MailingTemplateID));
                command.Parameters.AddWithValue("@p_SendTo", ADOHelper.NullCheck(this.SendTo));
                command.Parameters.AddWithValue("@p_MailingText", ADOHelper.NullCheck(this.MailingText));
                command.Parameters.AddWithValue("@p_MailingSubject", ADOHelper.NullCheck(this.MailingSubject));
                command.Parameters.AddWithValue("@p_MailingFrom", ADOHelper.NullCheck(this.MailingFrom));
                command.Parameters.AddWithValue("@p_RequestedDate", this.RequestedDate);
                command.Parameters.AddWithValue("@p_ProcessedDate", ADOHelper.NullCheck(this.ProcessedDate));
                command.Parameters.AddWithValue("@p_ProcessResult", ADOHelper.NullCheck(this.ProcessResult));

                //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.");
                }

                // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query.
                if (mailingTemplate != null && mailingTemplate.MailingTemplateID != this.MailingTemplateID)
                {
                    _mailingTemplateIDProperty = mailingTemplate.MailingTemplateID;
                }
            }

            // A child relationship exists on this Business Object but its type is not a child type (E.G. EditableChild).
            // TODO: Please override OnChildUpdated() and update this child manually.
            // UpdateChildren(this, connection);

            OnChildUpdated();
        }
        // [Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Insert()
        {
            bool cancel = false;

            OnInserting(ref cancel);
            if (cancel)
            {
                return;
            }
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                SqlTransaction trans = connection.BeginTransaction();
                try
                {
                    using (var command = new SqlCommand("[dbo].[spCFM_EmailQueue_Insert]", connection, trans))
                    {
                        command.CommandType = CommandType.StoredProcedure;

                        command.Parameters.AddWithValue("@p_EmailQueueID", this.EmailQueueID);
                        command.Parameters["@p_EmailQueueID"].Direction = ParameterDirection.Output;
                        command.Parameters.AddWithValue("@p_MailingTemplateID", ADOHelper.NullCheck(this.MailingTemplateID));
                        command.Parameters.AddWithValue("@p_SendTo", ADOHelper.NullCheck(this.SendTo));
                        command.Parameters.AddWithValue("@p_MailingText", ADOHelper.NullCheck(this.MailingText));
                        command.Parameters.AddWithValue("@p_MailingSubject", ADOHelper.NullCheck(this.MailingSubject));
                        command.Parameters.AddWithValue("@p_MailingFrom", ADOHelper.NullCheck(this.MailingFrom));
                        command.Parameters.AddWithValue("@p_RequestedDate", this.RequestedDate);
                        command.Parameters.AddWithValue("@p_ProcessedDate", ADOHelper.NullCheck(this.ProcessedDate));
                        command.Parameters.AddWithValue("@p_ProcessResult", ADOHelper.NullCheck(this.ProcessResult));
                        command.ExecuteNonQuery();
                        _emailQueueIDProperty = (System.Int32)command.Parameters["@p_EmailQueueID"].Value;
                    }

                    UpdateChildren(this, connection, trans);

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw;
                }
            }


            OnInserted();
        }
        public void Child_Insert(MailingTemplate mailingTemplate, SqlConnection connection, SqlTransaction trans)
        {
            bool cancel = false;

            OnChildInserting(mailingTemplate, connection, ref cancel, trans);
            if (cancel)
            {
                return;
            }

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            using (var command = new SqlCommand("[dbo].[spCFM_EmailQueue_Insert]", connection, trans))
            {
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@p_EmailQueueID", this.EmailQueueID);
                command.Parameters["@p_EmailQueueID"].Direction = ParameterDirection.Output;
                command.Parameters.AddWithValue("@p_MailingTemplateID", ADOHelper.NullCheck(mailingTemplate != null ? mailingTemplate.MailingTemplateID : this.MailingTemplateID));
                command.Parameters.AddWithValue("@p_SendTo", ADOHelper.NullCheck(this.SendTo));
                command.Parameters.AddWithValue("@p_MailingText", ADOHelper.NullCheck(this.MailingText));
                command.Parameters.AddWithValue("@p_MailingSubject", ADOHelper.NullCheck(this.MailingSubject));
                command.Parameters.AddWithValue("@p_MailingFrom", ADOHelper.NullCheck(this.MailingFrom));
                command.Parameters.AddWithValue("@p_RequestedDate", this.RequestedDate);
                command.Parameters.AddWithValue("@p_ProcessedDate", ADOHelper.NullCheck(this.ProcessedDate));
                command.Parameters.AddWithValue("@p_ProcessResult", ADOHelper.NullCheck(this.ProcessResult));

                command.ExecuteNonQuery();

                // Update identity primary key value.
                _emailQueueIDProperty = (System.Int32)command.Parameters["@p_EmailQueueID"].Value;

                // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query.
                if (mailingTemplate != null && mailingTemplate.MailingTemplateID != this.MailingTemplateID)
                {
                    _mailingTemplateIDProperty = mailingTemplate.MailingTemplateID;
                }
            }

            // A child relationship exists on this Business Object but its type is not a child type (E.G. EditableChild).
            // TODO: Please override OnChildInserted() and insert this child manually.
            // UpdateChildren(this, connection);

            OnChildInserted();
        }
        // [Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Update()
        {
            bool cancel = false;

            OnUpdating(ref cancel);
            if (cancel)
            {
                return;
            }
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                SqlTransaction trans = connection.BeginTransaction();
                try
                {
                    using (var command = new SqlCommand("[dbo].[spCFM_EmailQueue_Update]", connection, trans))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.AddWithValue("@p_EmailQueueID", this.EmailQueueID);
                        command.Parameters.AddWithValue("@p_MailingTemplateID", ADOHelper.NullCheck(this.MailingTemplateID));
                        command.Parameters.AddWithValue("@p_SendTo", ADOHelper.NullCheck(this.SendTo));
                        command.Parameters.AddWithValue("@p_MailingText", ADOHelper.NullCheck(this.MailingText));
                        command.Parameters.AddWithValue("@p_MailingSubject", ADOHelper.NullCheck(this.MailingSubject));
                        command.Parameters.AddWithValue("@p_MailingFrom", ADOHelper.NullCheck(this.MailingFrom));
                        command.Parameters.AddWithValue("@p_RequestedDate", this.RequestedDate);
                        command.Parameters.AddWithValue("@p_ProcessedDate", ADOHelper.NullCheck(this.ProcessedDate));
                        command.Parameters.AddWithValue("@p_ProcessResult", ADOHelper.NullCheck(this.ProcessResult));
                        //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.");
                        }
                    }
                    UpdateChildren(this, connection, trans);
                    //FieldManager.UpdateChildren(this, connection);
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw;
                }
            }

            OnUpdated();
        }
        // [Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Update()
        {
            bool cancel = false;

            OnUpdating(ref cancel);
            if (cancel)
            {
                return;
            }
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                SqlTransaction trans = connection.BeginTransaction();
                try
                {
                    using (var command = new SqlCommand("[dbo].[spCFM_BSBDetail_Update]", connection, trans))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.AddWithValue("@p_BSBDetailID", this.BSBDetailID);
                        command.Parameters.AddWithValue("@p_BSB", ADOHelper.NullCheck(this.Bsb));
                        command.Parameters.AddWithValue("@p_BankCode", ADOHelper.NullCheck(this.BankCode));
                        command.Parameters.AddWithValue("@p_BSBName", ADOHelper.NullCheck(this.BSBName));
                        command.Parameters.AddWithValue("@p_Address", ADOHelper.NullCheck(this.Address));
                        command.Parameters.AddWithValue("@p_Suburb", ADOHelper.NullCheck(this.Suburb));
                        command.Parameters.AddWithValue("@p_State", ADOHelper.NullCheck(this.State));
                        command.Parameters.AddWithValue("@p_PostCode", ADOHelper.NullCheck(this.PostCode));
                        command.Parameters.AddWithValue("@p_PaymentSystems", ADOHelper.NullCheck(this.PaymentSystems));
                        //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.");
                        }
                    }
                    UpdateChildren(this, connection, trans);
                    //FieldManager.UpdateChildren(this, connection);
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw;
                }
            }

            OnUpdated();
        }
        /// <summary>
        /// Updates the corresponding record in the data base with the information in the current
        ///    CSLA editable child business object of type <see cref="Home"/>
        /// </summary>
        /// <returns></returns>
        public void Child_Update(SqlConnection connection, SqlTransaction trans)
        {
            bool cancel = false;

            OnChildUpdating(connection, ref cancel, trans);
            if (cancel)
            {
                return;
            }

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            using (var command = new SqlCommand("[dbo].[spCFM_Home_Update]", connection, trans))
            {
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@p_HomeID", this.HomeID);
                command.Parameters.AddWithValue("@p_GLEntityID", this.GLEntityID);
                command.Parameters.AddWithValue("@p_BusinessAreaID", this.BusinessAreaID);
                command.Parameters.AddWithValue("@p_HomeCostCentreCode", this.HomeCostCentreCode);
                command.Parameters.AddWithValue("@p_HomeName", this.HomeName);
                command.Parameters.AddWithValue("@p_Parcel", this.Parcel);
                command.Parameters.AddWithValue("@p_SILTarget", this.SILTarget);
                command.Parameters.AddWithValue("@p_NoofBeds", this.NoofBeds);
                command.Parameters.AddWithValue("@p_AccommodationTypeId", this.AccommodationTypeId);
                command.Parameters.AddWithValue("@p_isGST", this.IsGST);
                command.Parameters.AddWithValue("@p_AddressID", ADOHelper.NullCheck(this.AddressID));
                command.Parameters.AddWithValue("@p_IsActive", this.IsActive);
                command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy);
                command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy));
                command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn));

                //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.");
                }
            }

            UpdateChildren(this, connection, trans);

            OnChildUpdated();
        }
Esempio n. 23
0
        /// <summary>
        /// Updates the corresponding record in the data base with the information in the current
        ///    CSLA editable child business object of type <see cref="Budget"/>
        /// </summary>
        /// <returns></returns>
        public void Child_Update(SqlConnection connection, SqlTransaction trans)
        {
            bool cancel = false;

            OnChildUpdating(connection, ref cancel, trans);
            if (cancel)
            {
                return;
            }

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            using (var command = new SqlCommand("[dbo].[spCFM_Budget_Update]", connection, trans))
            {
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@p_BudgetID", this.BudgetID);
                command.Parameters.AddWithValue("@p_BudgetTypeID", this.BudgetTypeID);
                command.Parameters.AddWithValue("@p_ClientID", ADOHelper.NullCheck(this.ClientID));
                command.Parameters.AddWithValue("@p_HomeID", ADOHelper.NullCheck(this.HomeID));
                command.Parameters.AddWithValue("@p_BudgetCode", this.BudgetCode);
                command.Parameters.AddWithValue("@p_EffectiveDate", this.EffectiveDate);
                command.Parameters.AddWithValue("@p_TemplateName", ADOHelper.NullCheck(this.TemplateName));
                command.Parameters.AddWithValue("@p_IsActive", this.IsActive);
                command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy);
                command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy));
                command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn));
                command.Parameters.AddWithValue("@p_EnteredMonthly", this.EnteredMonthly);
                command.Parameters.AddWithValue("@p_ScopeContribution", this.ScopeContribution);
                command.Parameters.AddWithValue("@p_NumberOfBeds", this.NumberOfBeds);
                command.Parameters.AddWithValue("@p_Vacancies", this.Vacancies);

                //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.");
                }
            }

            UpdateChildren(this, connection, trans);

            OnChildUpdated();
        }
        private BSBDetailList DataPortal_Fetch(BSBDetailCriteria 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_BSBDetail_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_BSBHasValue", criteria.BsbHasValue);
                    command.Parameters.AddWithValue("@p_BankCodeHasValue", criteria.BankCodeHasValue);
                    command.Parameters.AddWithValue("@p_BSBNameHasValue", criteria.BSBNameHasValue);
                    command.Parameters.AddWithValue("@p_AddressHasValue", criteria.AddressHasValue);
                    command.Parameters.AddWithValue("@p_SuburbHasValue", criteria.SuburbHasValue);
                    command.Parameters.AddWithValue("@p_StateHasValue", criteria.StateHasValue);
                    command.Parameters.AddWithValue("@p_PostCodeHasValue", criteria.PostCodeHasValue);
                    command.Parameters.AddWithValue("@p_PaymentSystemsHasValue", criteria.PaymentSystemsHasValue);
                    using (var reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            var rowParser = reader.GetRowParser <CFMData.BSBDetail>();
                            do
                            {
                                this.Add(CFMData.BSBDetail.GetBSBDetail(rowParser, reader));
                            }while(reader.Read());
                        }
                        OnFetched();
                        return(this);
                    }
                }
            }

            //RaiseListChangedEvents = true;
        }
Esempio n. 25
0
        /// <summary>
        /// Updates the corresponding record in the data base with the information in the current
        ///    CSLA editable child business object of type <see cref="Client"/>
        /// </summary>
        /// <returns></returns>
        public void Child_Update(SqlConnection connection, SqlTransaction trans)
        {
            bool cancel = false;

            OnChildUpdating(connection, ref cancel, trans);
            if (cancel)
            {
                return;
            }

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            using (var command = new SqlCommand("[dbo].[spCFM_Client_Update]", connection, trans))
            {
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@p_ClientID", this.ClientID);
                command.Parameters.AddWithValue("@p_GLEntityID", this.GLEntityID);
                command.Parameters.AddWithValue("@p_RefCode", this.RefCode);
                command.Parameters.AddWithValue("@p_NDISNumber", ADOHelper.NullCheck(this.NDISNumber));
                command.Parameters.AddWithValue("@p_FirstName", this.FirstName);
                command.Parameters.AddWithValue("@p_LastName", this.LastName);
                command.Parameters.AddWithValue("@p_DOB", this.Dob);
                command.Parameters.AddWithValue("@p_Email", ADOHelper.NullCheck(this.Email));
                command.Parameters.AddWithValue("@p_AddressID", ADOHelper.NullCheck(this.AddressID));
                command.Parameters.AddWithValue("@p_IsHomeAddress", this.IsHomeAddress);
                command.Parameters.AddWithValue("@p_StatementDelOptID", this.StatementDelOptID);
                command.Parameters.AddWithValue("@p_IsActive", this.IsActive);
                command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy);
                command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy));
                command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn));

                //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.");
                }
            }

            UpdateChildren(this, connection, trans);

            OnChildUpdated();
        }
        public void CustomSave(RoleAccessMappingRequest data)
        {
            bool cancel = false;

            OnUpdating(ref cancel);

            data.Role.CustomCopyDTO(this);

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

                    command.Parameters.AddWithValue("@p_ApplicationRoleID", data.Role.ApplicationRoleID);

                    if (data.Role.ApplicationRoleID <= 0)
                    {
                        command.Parameters["@p_ApplicationRoleID"].Direction = ParameterDirection.Output;
                    }

                    command.Parameters.AddWithValue("@p_ApplicationRoleName", data.Role.Name);
                    command.Parameters.AddWithValue("@p_SystemRoleID", data.Role.SystemRoleID);
                    command.Parameters.AddWithValue("@p_IsActive", data.Role.IsActive);
                    command.Parameters.AddWithValue("@p_ActionBy", ADOHelper.NullCheck(data.Role.UpdatedBy));
                    command.Parameters.AddWithValue("@p_BusinessAreaIDs", ADOHelper.NullCheck(data.BusinessAreaIDs));
                    command.Parameters.AddWithValue("@p_BusinessDivisionIDs", ADOHelper.NullCheck(data.BusinessDivisionIDs));
                    command.Parameters.AddWithValue("@p_BusinessEntitieIDs", ADOHelper.NullCheck(data.BusinessEntityIDs));
                    command.Parameters.AddWithValue("@p_HomeIDs", ADOHelper.NullCheck(data.HomeIDs));
                    command.Parameters.AddWithValue("@p_ClientIDs", ADOHelper.NullCheck(data.ClientIDs));


                    //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();
                    _applicationRoleIDProperty = (System.Int32)command.Parameters["@p_ApplicationRoleID"].Value;
                    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.");
                    }
                }
                //UpdateChildren(this, connection);
                //FieldManager.UpdateChildren(this, connection);
            }

            OnUpdated();
        }
        private EmailQueueList DataPortal_Fetch(EmailQueueCriteria 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_EmailQueue_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_MailingTemplateIDHasValue", criteria.MailingTemplateIDHasValue);
                    command.Parameters.AddWithValue("@p_SendToHasValue", criteria.SendToHasValue);
                    command.Parameters.AddWithValue("@p_MailingTextHasValue", criteria.MailingTextHasValue);
                    command.Parameters.AddWithValue("@p_MailingSubjectHasValue", criteria.MailingSubjectHasValue);
                    command.Parameters.AddWithValue("@p_MailingFromHasValue", criteria.MailingFromHasValue);
                    command.Parameters.AddWithValue("@p_ProcessedDateHasValue", criteria.ProcessedDateHasValue);
                    command.Parameters.AddWithValue("@p_ProcessResultHasValue", criteria.ProcessResultHasValue);
                    using (var reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            var rowParser = reader.GetRowParser <CFMData.EmailQueue>();
                            do
                            {
                                this.Add(CFMData.EmailQueue.GetEmailQueue(rowParser, reader));
                            }while(reader.Read());
                        }
                        OnFetched();
                        return(this);
                    }
                }
            }

            //RaiseListChangedEvents = true;
        }
Esempio n. 28
0
        private AddressList DataPortal_Fetch(AddressCriteria 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_Address_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_StreetHasValue", criteria.StreetHasValue);
                    command.Parameters.AddWithValue("@p_SuburbHasValue", criteria.SuburbHasValue);
                    command.Parameters.AddWithValue("@p_StateIDHasValue", criteria.StateIDHasValue);
                    command.Parameters.AddWithValue("@p_CountryIDHasValue", criteria.CountryIDHasValue);
                    command.Parameters.AddWithValue("@p_PostCodeHasValue", criteria.PostCodeHasValue);
                    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.Address>();
                            do
                            {
                                this.Add(CFMData.Address.GetAddress(rowParser, reader));
                            }while(reader.Read());
                        }
                        OnFetched();
                        return(this);
                    }
                }
            }

            //RaiseListChangedEvents = true;
        }
        /// <summary>
        /// Inserts data into the data base using the information in the current
        ///    CSLA editable child business object of type <see cref="Home"/>
        /// </summary>
        /// <returns></returns>
        public void Child_Insert(SqlConnection connection, SqlTransaction trans)
        {
            bool cancel = false;

            OnChildInserting(connection, ref cancel, trans);
            if (cancel)
            {
                return;
            }

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            using (var command = new SqlCommand("[dbo].[spCFM_Home_Insert]", connection, trans))
            {
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@p_HomeID", this.HomeID);
                command.Parameters["@p_HomeID"].Direction = ParameterDirection.Output;
                command.Parameters.AddWithValue("@p_GLEntityID", this.GLEntityID);
                command.Parameters.AddWithValue("@p_BusinessAreaID", this.BusinessAreaID);
                command.Parameters.AddWithValue("@p_HomeCostCentreCode", this.HomeCostCentreCode);
                command.Parameters.AddWithValue("@p_HomeName", this.HomeName);
                command.Parameters.AddWithValue("@p_Parcel", this.Parcel);
                command.Parameters.AddWithValue("@p_SILTarget", this.SILTarget);
                command.Parameters.AddWithValue("@p_NoofBeds", this.NoofBeds);
                command.Parameters.AddWithValue("@p_AccommodationTypeId", this.AccommodationTypeId);
                command.Parameters.AddWithValue("@p_isGST", this.IsGST);
                command.Parameters.AddWithValue("@p_AddressID", ADOHelper.NullCheck(this.AddressID));
                command.Parameters.AddWithValue("@p_IsActive", this.IsActive);
                command.Parameters.AddWithValue("@p_CreatedBy", this.CreatedBy);
                command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(this.UpdatedBy));
                command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn));

                command.ExecuteNonQuery();

                // Update identity primary key value.
                _homeIDProperty = (System.Int32)command.Parameters["@p_HomeID"].Value;
            }

            UpdateChildren(this, connection, trans);

            OnChildInserted();
        }
Esempio n. 30
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;
        }