Esempio n. 1
0
 // OneToMany
 public void LoadGLAccounts(GLAccountType obj)
 {
     if (obj.GLAccounts != null)
     {
         _gLAccountsProperty = obj.GLAccounts.CurrentDTO;
     }
 }
Esempio n. 2
0
 public void LoadUpdatedByApplicationUser(GLAccountType obj)
 {
     if (obj.UpdatedByApplicationUser != null)
     {
         _updatedByApplicationUserProperty = obj.UpdatedByApplicationUser.CurrentDTO;
     }
 }
Esempio n. 3
0
 public void LoadGLEntityType(GLAccountType obj)
 {
     if (obj.GLEntityType != null)
     {
         _gLEntityTypeProperty = obj.GLEntityType.CurrentDTO;
     }
 }
Esempio n. 4
0
        public static GLAccountType GetGLAccountType(Func <IDataReader, GLAccountType> rowParser, SqlDataReader reader)
        {
            GLAccountType obj = rowParser(reader);

            obj.InitDTO();
            obj.IsDirty = false;
            obj.IsNew   = false;
            return(obj);
        }
Esempio n. 5
0
 public GLAccountType CopyDTO(GLAccountType obj)
 {
     obj.GLAccountTypeID    = this.GLAccountTypeID;
     obj.Code               = this.Code;
     obj.Name               = this.Name;
     obj.GLEntityTypeID     = this.GLEntityTypeID;
     obj.IsActive           = this.IsActive;
     obj.CanHaveBankAccount = this.CanHaveBankAccount;
     obj.CanHaveBankCards   = this.CanHaveBankCards;
     obj.IsMandatory        = this.IsMandatory;
     return(obj);
 }
Esempio n. 6
0
 protected void UpdateChildren(GLAccountType parent, SqlConnection connection, SqlTransaction trans)
 {
     if (_gLAccountsPropertyChecked)
     {
         if (_gLAccountsProperty != null)
         {
             foreach (GLAccount obj in _gLAccountsProperty)
             {
                 if (obj.IsNew)
                 {
                     obj.Child_Insert(parent, connection, trans);
                 }
                 else
                 {
                     if (obj.IsDirty || obj.IsChildDirty())
                     {
                         obj.Child_Update(parent, connection, trans);
                     }
                 }
             }
         }
     }
 }
Esempio n. 7
0
        // [Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Update()
        {
            bool cancel = false;

            OnUpdating(ref cancel);
            if (cancel)
            {
                return;
            }
            if (OriginalGLAccountTypeID != GLAccountTypeID)
            {
                // Insert new child.
                GLAccountType item = new GLAccountType {
                    GLAccountTypeID = GLAccountTypeID, Code = Code, Name = Name, IsActive = IsActive, CreatedBy = CreatedBy, CreatedOn = CreatedOn, CanHaveBankAccount = CanHaveBankAccount, CanHaveBankCards = CanHaveBankCards, IsMandatory = IsMandatory
                };
                if (GLEntityTypeID.HasValue)
                {
                    item.GLEntityTypeID = GLEntityTypeID.Value;
                }
                if (UpdatedBy.HasValue)
                {
                    item.UpdatedBy = UpdatedBy.Value;
                }
                if (UpdatedOn.HasValue)
                {
                    item.UpdatedOn = UpdatedOn.Value;
                }
                item.DataPortal_Update();

                // Mark editable child lists as dirty. This code may need to be updated to one-to-one relationships.
                foreach (GLAccount itemToUpdate in GLAccounts)
                {
                    itemToUpdate.GLAccountTypeID = GLAccountTypeID;
                }

                // Create a new connection.
                using (var connection = new SqlConnection(ADOHelper.ConnectionString))
                {
                    connection.Open();
                    SqlTransaction trans = connection.BeginTransaction();
                    try
                    {
                        UpdateChildren(this, connection, trans);
                        trans.Commit();
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw;
                    }

                    //FieldManager.UpdateChildren(this, connection);
                }
                // Delete the old.
                var criteria = new GLAccountTypeCriteria {
                    GLAccountTypeID = OriginalGLAccountTypeID
                };

                DataPortal_Delete(criteria);

                // Mark the original as the new one.
                OriginalGLAccountTypeID = GLAccountTypeID;
                OnUpdated();

                return;
            }

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                SqlTransaction trans = connection.BeginTransaction();
                try
                {
                    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.");
                        }

                        _originalGLAccountTypeIDProperty = this.GLAccountTypeID;
                    }
                    UpdateChildren(this, connection, trans);
                    //FieldManager.UpdateChildren(this, connection);
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw;
                }
            }

            OnUpdated();
        }
Esempio n. 8
0
        public void Child_Update(ApplicationUser applicationUser, BankAccount bankAccount, GLAccountType gLAccountType, GLEntity gLEntity, SqlConnection connection, SqlTransaction trans)
        {
            bool cancel = false;

            OnChildUpdating(applicationUser, bankAccount, gLAccountType, gLEntity, connection, ref cancel, trans);
            if (cancel)
            {
                return;
            }

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

                command.Parameters.AddWithValue("@p_GLAccountID", this.GLAccountID);
                command.Parameters.AddWithValue("@p_AccountCode", this.AccountCode);
                command.Parameters.AddWithValue("@p_AccountName", this.AccountName);
                command.Parameters.AddWithValue("@p_GLEntityID", gLEntity != null ? gLEntity.GLEntityID : this.GLEntityID);
                command.Parameters.AddWithValue("@p_BankAccountID", ADOHelper.NullCheck(bankAccount != null ? bankAccount.BankAccountID : this.BankAccountID));
                command.Parameters.AddWithValue("@p_GLAccountTypeID", gLAccountType != null ? gLAccountType.GLAccountTypeID : this.GLAccountTypeID);
                command.Parameters.AddWithValue("@p_IsActive", this.IsActive);
                command.Parameters.AddWithValue("@p_CreatedBy", applicationUser != null ? applicationUser.ApplicationUserID : this.CreatedBy);
                command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(applicationUser != null ? applicationUser.ApplicationUserID : 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.");
                }

                // 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 (gLEntity != null && gLEntity.GLEntityID != this.GLEntityID)
                {
                    _gLEntityIDProperty = gLEntity.GLEntityID;
                }

                // 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 (bankAccount != null && bankAccount.BankAccountID != this.BankAccountID)
                {
                    _bankAccountIDProperty = bankAccount.BankAccountID;
                }

                // 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 (gLAccountType != null && gLAccountType.GLAccountTypeID != this.GLAccountTypeID)
                {
                    _gLAccountTypeIDProperty = gLAccountType.GLAccountTypeID;
                }

                // 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 (applicationUser != null && applicationUser.ApplicationUserID != this.CreatedBy)
                {
                    _createdByProperty = applicationUser.ApplicationUserID;
                }

                // 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 (applicationUser != null && applicationUser.ApplicationUserID != this.UpdatedBy)
                {
                    _updatedByProperty = applicationUser.ApplicationUserID;
                }
            }

            // 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();
        }
Esempio n. 9
0
 public void Child_Update(GLAccountType gLAccountType, SqlConnection connection, SqlTransaction trans)
 {
     Child_Update(null, null, gLAccountType, null, connection, trans);
 }
Esempio n. 10
0
        public void Child_Insert(ApplicationUser applicationUser, BankAccount bankAccount, GLAccountType gLAccountType, GLEntity gLEntity, SqlConnection connection, SqlTransaction trans)
        {
            bool cancel = false;

            OnChildInserting(applicationUser, bankAccount, gLAccountType, gLEntity, connection, ref cancel, trans);
            if (cancel)
            {
                return;
            }

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

                command.Parameters.AddWithValue("@p_GLAccountID", this.GLAccountID);
                command.Parameters["@p_GLAccountID"].Direction = ParameterDirection.Output;
                command.Parameters.AddWithValue("@p_AccountCode", this.AccountCode);
                command.Parameters.AddWithValue("@p_AccountName", this.AccountName);
                command.Parameters.AddWithValue("@p_GLEntityID", gLEntity != null ? gLEntity.GLEntityID : this.GLEntityID);
                command.Parameters.AddWithValue("@p_BankAccountID", ADOHelper.NullCheck(bankAccount != null ? bankAccount.BankAccountID : this.BankAccountID));
                command.Parameters.AddWithValue("@p_GLAccountTypeID", gLAccountType != null ? gLAccountType.GLAccountTypeID : this.GLAccountTypeID);
                command.Parameters.AddWithValue("@p_IsActive", this.IsActive);
                command.Parameters.AddWithValue("@p_CreatedBy", applicationUser != null ? applicationUser.ApplicationUserID : this.CreatedBy);
                command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(applicationUser != null ? applicationUser.ApplicationUserID : this.UpdatedBy));
                command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn));

                command.ExecuteNonQuery();

                // Update identity primary key value.
                _gLAccountIDProperty = (System.Int32)command.Parameters["@p_GLAccountID"].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 (gLEntity != null && gLEntity.GLEntityID != this.GLEntityID)
                {
                    _gLEntityIDProperty = gLEntity.GLEntityID;
                }

                // 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 (bankAccount != null && bankAccount.BankAccountID != this.BankAccountID)
                {
                    _bankAccountIDProperty = bankAccount.BankAccountID;
                }

                // 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 (gLAccountType != null && gLAccountType.GLAccountTypeID != this.GLAccountTypeID)
                {
                    _gLAccountTypeIDProperty = gLAccountType.GLAccountTypeID;
                }

                // 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 (applicationUser != null && applicationUser.ApplicationUserID != this.CreatedBy)
                {
                    _createdByProperty = applicationUser.ApplicationUserID;
                }

                // 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 (applicationUser != null && applicationUser.ApplicationUserID != this.UpdatedBy)
                {
                    _updatedByProperty = applicationUser.ApplicationUserID;
                }
            }

            // 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();
        }
 partial void OnChildInserting(ApplicationUser applicationUser, BankAccount bankAccount, GLAccountType gLAccountType, GLEntity gLEntity, SqlConnection connection, ref bool cancel, SqlTransaction trans)
 {
     InsertUpdateBankAccount(connection, trans);
 }
Esempio n. 12
0
        /// <summary>
        /// Creates a new object of type <see cref="GLAccountType"/>.
        /// </summary>
        /// <returns>Returns a newly instantiated collection of type <see cref="GLAccountType"/>.</returns>
        public static GLAccountType NewGLAccountType()
        {
            GLAccountType obj = new GLAccountType();

            return(obj);
        }