// OneToMany
 public void LoadDataOptions(DataOptionType obj)
 {
     if (obj.DataOptions != null)
     {
         _dataOptionsProperty = obj.DataOptions.CurrentDTO;
     }
 }
 public void LoadDataOptionTypeSort(DataOptionType obj)
 {
     if (obj.DataOptionTypeSort != null)
     {
         _dataOptionTypeSortProperty = obj.DataOptionTypeSort.CurrentDTO;
     }
 }
 public void LoadUpdatedByApplicationUser(DataOptionType obj)
 {
     if (obj.UpdatedByApplicationUser != null)
     {
         _updatedByApplicationUserProperty = obj.UpdatedByApplicationUser.CurrentDTO;
     }
 }
        public static DataOptionType GetDataOptionType(Func <IDataReader, DataOptionType> rowParser, SqlDataReader reader)
        {
            DataOptionType obj = rowParser(reader);

            obj.InitDTO();
            obj.IsDirty = false;
            obj.IsNew   = false;
            return(obj);
        }
 public DataOptionType CopyDTO(DataOptionType obj)
 {
     obj.DataOptionTypeSortID = this.DataOptionTypeSortID;
     obj.Code            = this.Code;
     obj.Name            = this.Name;
     obj.AllowChildNodes = this.AllowChildNodes;
     obj.MaxChildLevels  = this.MaxChildLevels;
     obj.IsSystem        = this.IsSystem;
     obj.DefaultValue    = this.DefaultValue;
     return(obj);
 }
示例#6
0
 protected void UpdateChildren(DataOptionType parent, SqlConnection connection, SqlTransaction trans)
 {
     if (_dataOptionsPropertyChecked)
     {
         if (_dataOptionsProperty != null)
         {
             foreach (DataOption obj in _dataOptionsProperty)
             {
                 if (obj.IsNew)
                 {
                     obj.Child_Insert(parent, connection, trans);
                 }
                 else
                 {
                     if (obj.IsDirty || obj.IsChildDirty())
                     {
                         obj.Child_Update(parent, connection, trans);
                     }
                 }
             }
         }
     }
 }
 /// <summary>
 /// CodeSmith generated stub method that is called when updating the child <see cref="DataOption"/> object.
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="cancel">Value returned from the method indicating whether the object insertion should proceed.</param>
 partial void OnChildUpdating(ApplicationUser applicationUser, DataOptionType dataOptionType, SqlConnection connection, ref bool cancel, SqlTransaction trans);
        /// <summary>
        /// Creates a new object of type <see cref="DataOptionType"/>.
        /// </summary>
        /// <returns>Returns a newly instantiated collection of type <see cref="DataOptionType"/>.</returns>
        public static DataOptionType NewDataOptionType()
        {
            DataOptionType obj = new DataOptionType();

            return(obj);
        }
        public void Child_Update(ApplicationUser applicationUser, DataOptionType dataOptionType, SqlConnection connection, SqlTransaction trans)
        {
            bool cancel = false;

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

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

                command.Parameters.AddWithValue("@p_DataOptionID", this.DataOptionID);
                command.Parameters.AddWithValue("@p_DataOptionTypeID", dataOptionType != null ? dataOptionType.DataOptionTypeID : this.DataOptionTypeID);
                command.Parameters.AddWithValue("@p_Code", ADOHelper.NullCheck(this.Code));
                command.Parameters.AddWithValue("@p_DisplayValue", ADOHelper.NullCheck(this.DisplayValue));
                command.Parameters.AddWithValue("@p_ParentID", ADOHelper.NullCheck(this.ParentID));
                command.Parameters.AddWithValue("@p_SortID", this.SortID);
                command.Parameters.AddWithValue("@p_IsSystem", this.IsSystem);
                command.Parameters.AddWithValue("@p_AdditionalConfigData", ADOHelper.NullCheck(this.AdditionalConfigData));
                command.Parameters.AddWithValue("@p_ActiveFrom", this.ActiveFrom);
                command.Parameters.AddWithValue("@p_ActiveTo", ADOHelper.NullCheck(this.ActiveTo));
                command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                command.Parameters.AddWithValue("@p_CreatedBy", applicationUser != null ? applicationUser.ApplicationUserID : this.CreatedBy);
                command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn));
                command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(applicationUser != null ? applicationUser.ApplicationUserID : 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.");
                }

                // 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 (dataOptionType != null && dataOptionType.DataOptionTypeID != this.DataOptionTypeID)
                {
                    _dataOptionTypeIDProperty = dataOptionType.DataOptionTypeID;
                }

                // 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, null, null, null, null, null, null, null, null, null, connection);

            OnChildUpdated();
        }
 public void Child_Update(DataOptionType dataOptionType, SqlConnection connection, SqlTransaction trans)
 {
     Child_Update(null, dataOptionType, connection, trans);
 }
        public void Child_Insert(ApplicationUser applicationUser, DataOptionType dataOptionType, SqlConnection connection, SqlTransaction trans)
        {
            bool cancel = false;

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

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

                command.Parameters.AddWithValue("@p_DataOptionID", this.DataOptionID);
                command.Parameters["@p_DataOptionID"].Direction = ParameterDirection.Output;
                command.Parameters.AddWithValue("@p_DataOptionTypeID", dataOptionType != null ? dataOptionType.DataOptionTypeID : this.DataOptionTypeID);
                command.Parameters.AddWithValue("@p_Code", ADOHelper.NullCheck(this.Code));
                command.Parameters.AddWithValue("@p_DisplayValue", ADOHelper.NullCheck(this.DisplayValue));
                command.Parameters.AddWithValue("@p_ParentID", ADOHelper.NullCheck(this.ParentID));
                command.Parameters.AddWithValue("@p_SortID", this.SortID);
                command.Parameters.AddWithValue("@p_IsSystem", this.IsSystem);
                command.Parameters.AddWithValue("@p_AdditionalConfigData", ADOHelper.NullCheck(this.AdditionalConfigData));
                command.Parameters.AddWithValue("@p_ActiveFrom", this.ActiveFrom);
                command.Parameters.AddWithValue("@p_ActiveTo", ADOHelper.NullCheck(this.ActiveTo));
                command.Parameters.AddWithValue("@p_CreatedOn", this.CreatedOn);
                command.Parameters.AddWithValue("@p_CreatedBy", applicationUser != null ? applicationUser.ApplicationUserID : this.CreatedBy);
                command.Parameters.AddWithValue("@p_UpdatedOn", ADOHelper.NullCheck(this.UpdatedOn));
                command.Parameters.AddWithValue("@p_UpdatedBy", ADOHelper.NullCheck(applicationUser != null ? applicationUser.ApplicationUserID : this.UpdatedBy));

                command.ExecuteNonQuery();

                // Update identity primary key value.
                _dataOptionIDProperty = (System.Int32)command.Parameters["@p_DataOptionID"].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 (dataOptionType != null && dataOptionType.DataOptionTypeID != this.DataOptionTypeID)
                {
                    _dataOptionTypeIDProperty = dataOptionType.DataOptionTypeID;
                }

                // 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, null, null, null, null, null, null, null, null, null, connection);

            OnChildInserted();
        }