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

        StringBuilder pkFieldsAndValues = new StringBuilder();

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

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

            // Map entity properties
            entity.EmployeeId  = dto.EmployeeId;
            entity.TerritoryId = dto.TerritoryId;


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

            OnAfterDtoToEntity(dto, entity);
            return(entity);
        }
예제 #3
0
        /// <summary>Creates a new, empty EmployeeTerritoryEntity object.</summary>
        /// <returns>A new, empty EmployeeTerritoryEntity object.</returns>
        public override IEntity Create()
        {
            IEntity toReturn = new EmployeeTerritoryEntity();

            // __LLBLGENPRO_USER_CODE_REGION_START CreateNewEmployeeTerritory
            // __LLBLGENPRO_USER_CODE_REGION_END
            return(toReturn);
        }
예제 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (_filterToUse != null)
     {
         using (DataAccessAdapter adapter = new DataAccessAdapter())
         {
             EmployeeTerritoryEntity instance = (EmployeeTerritoryEntity)adapter.FetchNewEntity(new EmployeeTerritoryEntityFactory(), new RelationPredicateBucket(_filterToUse));
             if (instance != null)
             {
             }
         }
     }
 }
    /// <summary>
    /// Eventhandler for the PerformWork event on the _EmployeeTerritoryDS datasourcecontrol
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void _EmployeeTerritoryDS_PerformWork(object sender, PerformWorkEventArgs2 e)
    {
        // as we're using a formview, there's just 1 entity in the UoW.
        EmployeeTerritoryEntity   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 = (EmployeeTerritoryEntity)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 = "&EmployeeId=" + entityToProcess.EmployeeId + "&TerritoryId=" + entityToProcess.TerritoryId;
        }
    }
        public static EmployeeTerritory RelatedObject(this EmployeeTerritoryEntity 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 EmployeeTerritory);
                }
            }

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

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

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

                // Map dto properties
                dto.EmployeeId  = entity.EmployeeId;
                dto.TerritoryId = entity.TerritoryId;


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

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