/// <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);
        ShipperEntity selectedEntity = (ShipperEntity)_ShipperDS.EntityCollection[index];

        StringBuilder pkFieldsAndValues = new StringBuilder();

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

        case "ViewExisting":
            Response.Redirect("~/ViewExisting.aspx?EntityType=" + (int)EntityType.ShipperEntity + pkFieldsAndValues.ToString());
            break;
        }
    }
        public static Shipper ToDto(this ShipperEntity entity, Hashtable seenObjects, Hashtable parents)
        {
            OnBeforeEntityToDto(entity, seenObjects, parents);
            var dto = new Shipper();

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

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

                // Map dto properties
                dto.ShipperId   = entity.ShipperId;
                dto.CompanyName = entity.CompanyName;
                dto.Phone       = entity.Phone;


                // Map dto associations
                // 1:n Orders association of Order entities
                if (entity.Orders != null && entity.Orders.Any())
                {
                    dto.Orders = new OrderCollection(entity.Orders.RelatedArray(seenObjects, parents));
                }
            }

            OnAfterEntityToDto(entity, seenObjects, parents, dto);
            return(dto);
        }
Пример #3
0
        /// <summary>Creates a new, empty ShipperEntity object.</summary>
        /// <returns>A new, empty ShipperEntity object.</returns>
        public override IEntity Create()
        {
            IEntity toReturn = new ShipperEntity();

            // __LLBLGENPRO_USER_CODE_REGION_START CreateNewShipper
            // __LLBLGENPRO_USER_CODE_REGION_END
            return(toReturn);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (_filterToUse != null)
     {
         using (DataAccessAdapter adapter = new DataAccessAdapter())
         {
             ShipperEntity instance = (ShipperEntity)adapter.FetchNewEntity(new ShipperEntityFactory(), new RelationPredicateBucket(_filterToUse));
             if (instance != null)
             {
                 laOrders.SetContainingEntity(instance, "Orders");
                 laCustomersCollectionViaOrders.SetContainingEntity(instance, "CustomersCollectionViaOrders");
                 laEmployeesCollectionViaOrders.SetContainingEntity(instance, "EmployeesCollectionViaOrders");
             }
         }
     }
 }
Пример #5
0
    /// <summary>
    /// Eventhandler for the PerformWork event on the _ShipperDS datasourcecontrol
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void _ShipperDS_PerformWork(object sender, PerformWorkEventArgs2 e)
    {
        // as we're using a formview, there's just 1 entity in the UoW.
        ShipperEntity             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 = (ShipperEntity)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 = "&ShipperId=" + entityToProcess.ShipperId;
        }
    }
        public static Shipper RelatedObject(this ShipperEntity 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 Shipper);
                }
            }

            return(entity.ToDto(seenObjects, parents));
        }
        public static ShipperEntity FromDto(this Shipper dto)
        {
            OnBeforeDtoToEntity(dto);
            var entity = new ShipperEntity();

            // Map entity properties
            entity.CompanyName = dto.CompanyName;
            entity.Phone       = dto.Phone;


            // Map entity associations
            // 1:n Orders association
            if (dto.Orders != null && dto.Orders.Any())
            {
                foreach (var relatedDto in dto.Orders)
                {
                    entity.Orders.Add(relatedDto.FromDto());
                }
            }

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