/// <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); CustomerDemographyEntity selectedEntity = (CustomerDemographyEntity)_CustomerDemographyDS.EntityCollection[index]; StringBuilder pkFieldsAndValues = new StringBuilder(); pkFieldsAndValues.AppendFormat("&CustomerTypeId={0}", selectedEntity.CustomerTypeId); switch (e.CommandName) { case "EditExisting": Response.Redirect("~/EditExisting.aspx?EntityType=" + (int)EntityType.CustomerDemographyEntity + pkFieldsAndValues.ToString()); break; case "ViewExisting": Response.Redirect("~/ViewExisting.aspx?EntityType=" + (int)EntityType.CustomerDemographyEntity + pkFieldsAndValues.ToString()); break; } }
/// <summary>Creates a new, empty CustomerDemographyEntity object.</summary> /// <returns>A new, empty CustomerDemographyEntity object.</returns> public override IEntity Create() { IEntity toReturn = new CustomerDemographyEntity(); // __LLBLGENPRO_USER_CODE_REGION_START CreateNewCustomerDemography // __LLBLGENPRO_USER_CODE_REGION_END return(toReturn); }
protected void Page_Load(object sender, EventArgs e) { if (_filterToUse != null) { using (DataAccessAdapter adapter = new DataAccessAdapter()) { CustomerDemographyEntity instance = (CustomerDemographyEntity)adapter.FetchNewEntity(new CustomerDemographyEntityFactory(), new RelationPredicateBucket(_filterToUse)); if (instance != null) { laCustomerCustomerDemo.SetContainingEntity(instance, "CustomerCustomerDemo"); laCustomersCollectionViaCustomerCustomerDemo.SetContainingEntity(instance, "CustomersCollectionViaCustomerCustomerDemo"); } } } }
/// <summary> /// Eventhandler for the PerformWork event on the _CustomerDemographyDS datasourcecontrol /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void _CustomerDemographyDS_PerformWork(object sender, PerformWorkEventArgs2 e) { // as we're using a formview, there's just 1 entity in the UoW. CustomerDemographyEntity 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 = (CustomerDemographyEntity)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 = "&CustomerTypeId=" + entityToProcess.CustomerTypeId; } }