Exemplo n.º 1
0
        /// <summary>
        /// Raises the System.Web.UI.Control.Load event.
        /// </summary>
        /// <param name="e">The System.EventArgs object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            // add child controls
            if (PrimaryMember != null)
            {
                this.Controls.Add(PrimaryMember);
            }
            if (LinkMember != null)
            {
                this.Controls.Add(LinkMember);
            }
            if (ReferenceMember != null)
            {
                this.Controls.Add(ReferenceMember);
            }

            ILinkedDataSource PrimaryDataSource = PrimaryMember.GetLinkedDataSource();

            if (PrimaryDataSource != null)
            {
                PrimaryDataSource.AfterSelected  += new LinkedDataSourceEventHandler(OnAfterSelected);
                PrimaryDataSource.AfterInserting += new LinkedDataSourceEventHandler(OnAfterInserting);
                PrimaryDataSource.AfterInserted  += new LinkedDataSourceEventHandler(OnAfterInserted);
                PrimaryDataSource.AfterUpdating  += new LinkedDataSourceEventHandler(OnAfterUpdating);
                PrimaryDataSource.AfterUpdated   += new LinkedDataSourceEventHandler(OnAfterUpdated);
            }
        }
Exemplo n.º 2
0
 private void OnAfterSelected(object sender, LinkedDataSourceEventArgs e)
 {
     if (e.Index == PrimaryMember.EntityIndex)
     {
         PrimaryMember.CurrentEntity = e.Entity;
         PrimaryMember.DeepLoad();
         UpdateControl(e.Entity);
     }
 }
Exemplo n.º 3
0
        private void OnAfterUpdating(object sender, LinkedDataSourceEventArgs e)
        {
            if (e.Index == PrimaryMember.EntityIndex)
            {
                PrimaryMember.CurrentEntity = e.Entity;
                PrimaryMember.DeepLoad();

                if (PrimaryMember.EnableDeepSave)
                {
                    UpdateRelationships(e.Entity);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Inserts the specified name/value pairs into the
        /// relationship defined by the <cref name="ReferenceMember"/> property.
        /// </summary>
        /// <param name="links">A collection of business objects.</param>
        /// <param name="values">A collection of name/value pairs to insert.</param>
        protected void InsertReference(IList links, IDictionary values)
        {
            Object entityKeyValue = PrimaryMember.GetEntityId();

            // delayed insert
            if (ReferenceMember.HasDataSource && entityKeyValue == null)
            {
                ReferenceMember.Inserts.Add(values);
            }
            else
            {
                Insert(ReferenceMember, links, values, true);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Inserts any previously cached business object references.
        /// </summary>
        /// <param name="member">The relationship member.</param>
        private void Insert(EntityRelationshipMember member)
        {
            if (member != null && member.HasDataSource)
            {
                Object entityKeyValue = PrimaryMember.GetEntityId();

                foreach (IDictionary values in member.Inserts)
                {
                    values[member.EntityKeyName] = entityKeyValue;
                    member.GetLinkedDataSource().Insert(values);
                }

                member.Inserts.Clear();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Inserts the specified <paramref name="foreignKeyValue"/> into the
        /// collection of business objects.
        /// </summary>
        /// <param name="links">A collection of business objects.</param>
        /// <param name="foreignKeyValue">The value to insert.</param>
        protected void InsertLink(IList links, Object foreignKeyValue)
        {
            // make sure link doesn't exist
            Object link = EntityUtil.GetEntity(links, LinkMember.ForeignKeyName, foreignKeyValue);

            if (link == null)
            {
                Object entityKeyValue = PrimaryMember.GetEntityId();

                IDictionary values = new Hashtable();
                values.Add(LinkMember.EntityKeyName, entityKeyValue);
                values.Add(LinkMember.ForeignKeyName, foreignKeyValue);

                // delayed insert
                if (LinkMember.HasDataSource && entityKeyValue == null)
                {
                    LinkMember.Inserts.Add(values);
                }
                else
                {
                    Insert(LinkMember, links, values);
                }
            }
        }