/// <summary>
    /// Handles the RowCommand event of the theGrid control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewCommandEventArgs"/> instance containing the event data.</param>
    protected void theGrid_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        switch (e.CommandName)
        {
        case "EditExisting":
        case "ViewExisting":
            break;

        default:
            // apparently another command, return
            return;
        }
        int index = Convert.ToInt32(e.CommandArgument);
        CustomerCustomerDemoEntity selectedEntity = (CustomerCustomerDemoEntity)_CustomerCustomerDemoDS.EntityCollection[index];

        StringBuilder pkFieldsAndValues = new StringBuilder();

        pkFieldsAndValues.AppendFormat("&CustomerId={0}", selectedEntity.CustomerId);           pkFieldsAndValues.AppendFormat("&CustomerTypeId={0}", selectedEntity.CustomerTypeId);
        switch (e.CommandName)
        {
        case "EditExisting":
            Response.Redirect("~/EditExisting.aspx?EntityType=" + (int)EntityType.CustomerCustomerDemoEntity + pkFieldsAndValues.ToString());
            break;

        case "ViewExisting":
            Response.Redirect("~/ViewExisting.aspx?EntityType=" + (int)EntityType.CustomerCustomerDemoEntity + pkFieldsAndValues.ToString());
            break;
        }
    }
        public static CustomerCustomerDemoEntity FromDto(this CustomerCustomerDemo dto)
        {
            OnBeforeDtoToEntity(dto);
            var entity = new CustomerCustomerDemoEntity();

            // Map entity properties
            entity.CustomerId     = dto.CustomerId;
            entity.CustomerTypeId = dto.CustomerTypeId;


            // Map entity associations
            // n:1 Customer association
            if (dto.Customer != null)
            {
                entity.Customer = dto.Customer.FromDto();
            }
            // n:1 CustomerDemographic association
            if (dto.CustomerDemographic != null)
            {
                entity.CustomerDemographic = dto.CustomerDemographic.FromDto();
            }

            OnAfterDtoToEntity(dto, entity);
            return(entity);
        }
Ejemplo n.º 3
0
        /// <summary>Creates a new, empty CustomerCustomerDemoEntity object.</summary>
        /// <returns>A new, empty CustomerCustomerDemoEntity object.</returns>
        public override IEntity Create()
        {
            IEntity toReturn = new CustomerCustomerDemoEntity();

            // __LLBLGENPRO_USER_CODE_REGION_START CreateNewCustomerCustomerDemo
            // __LLBLGENPRO_USER_CODE_REGION_END
            return(toReturn);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (_filterToUse != null)
     {
         using (DataAccessAdapter adapter = new DataAccessAdapter())
         {
             CustomerCustomerDemoEntity instance = (CustomerCustomerDemoEntity)adapter.FetchNewEntity(new CustomerCustomerDemoEntityFactory(), new RelationPredicateBucket(_filterToUse));
             if (instance != null)
             {
             }
         }
     }
 }
    /// <summary>
    /// Eventhandler for the PerformWork event on the _CustomerCustomerDemoDS datasourcecontrol
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void _CustomerCustomerDemoDS_PerformWork(object sender, PerformWorkEventArgs2 e)
    {
        // as we're using a formview, there's just 1 entity in the UoW.
        CustomerCustomerDemoEntity entityToProcess  = null;
        List <UnitOfWorkElement2>  elementsToInsert = e.Uow.GetEntityElementsToInsert();

        if (elementsToInsert.Count > 0)
        {
            // it's an insert operation. grab the entity so we can determine the PK later on.
            entityToProcess = (CustomerCustomerDemoEntity)elementsToInsert[0].Entity;
        }
        using (DataAccessAdapter adapter = new DataAccessAdapter())
        {
            e.Uow.Commit(adapter, true);
        }
        if (entityToProcess != null)
        {
            // store the PK values so a redirect can use these.
            _pkValuesAfterInsert = "&CustomerId=" + entityToProcess.CustomerId + "&CustomerTypeId=" + entityToProcess.CustomerTypeId;
        }
    }
        public static CustomerCustomerDemo RelatedObject(this CustomerCustomerDemoEntity entity, Hashtable seenObjects, Hashtable parents)
        {
            if (null == entity)
            {
                return(null);
            }

            if (seenObjects.Contains(entity))
            {
                if (parents.Contains(entity))
                {
                    // avoid cyclic references
                    return(null);
                }
                else
                {
                    return(seenObjects[entity] as CustomerCustomerDemo);
                }
            }

            return(entity.ToDto(seenObjects, parents));
        }
        public static CustomerCustomerDemo ToDto(this CustomerCustomerDemoEntity entity, Hashtable seenObjects, Hashtable parents)
        {
            OnBeforeEntityToDto(entity, seenObjects, parents);
            var dto = new CustomerCustomerDemo();

            if (entity != null)
            {
                if (seenObjects == null)
                {
                    seenObjects = new Hashtable();
                }
                seenObjects[entity] = dto;

                parents = new Hashtable(parents)
                {
                    { entity, null }
                };

                // Map dto properties
                dto.CustomerId     = entity.CustomerId;
                dto.CustomerTypeId = entity.CustomerTypeId;


                // Map dto associations
                // n:1 Customer association
                if (entity.Customer != null)
                {
                    dto.Customer = entity.Customer.RelatedObject(seenObjects, parents);
                }
                // n:1 CustomerDemographic association
                if (entity.CustomerDemographic != null)
                {
                    dto.CustomerDemographic = entity.CustomerDemographic.RelatedObject(seenObjects, parents);
                }
            }

            OnAfterEntityToDto(entity, seenObjects, parents, dto);
            return(dto);
        }
 public static CustomerCustomerDemo ToDto(this CustomerCustomerDemoEntity entity)
 {
     return(entity.ToDto(new Hashtable(), new Hashtable()));
 }
 static partial void OnAfterDtoToEntity(CustomerCustomerDemo dto, CustomerCustomerDemoEntity entity);
 static partial void OnAfterEntityToDto(CustomerCustomerDemoEntity entity, Hashtable seenObjects, Hashtable parents, CustomerCustomerDemo dto);
 static partial void OnBeforeEntityToDto(CustomerCustomerDemoEntity entity, Hashtable seenObjects, Hashtable parents);