/// <summary> setups the sync logic for member _serviceLocationAssetType</summary> /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param> private void SetupSyncServiceLocationAssetType(IEntity2 relatedEntity) { if (_serviceLocationAssetType != relatedEntity) { DesetupSyncServiceLocationAssetType(true, true); _serviceLocationAssetType = (ServiceLocationAssetTypeEntity)relatedEntity; base.PerformSetupSyncRelatedEntity(_serviceLocationAssetType, new PropertyChangedEventHandler(OnServiceLocationAssetTypePropertyChanged), "ServiceLocationAssetType", ServiceLocationAssetTypeChangeLogEntity.Relations.ServiceLocationAssetTypeEntityUsingServiceLocationAssetTypeId, true, new string[] { }); } }
/// <summary> Initializes the class members</summary> protected virtual void InitClassMembers() { _changeLog = null; _serviceLocationAssetType = null; PerformDependencyInjection(); // __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers // __LLBLGENPRO_USER_CODE_REGION_END OnInitClassMembersComplete(); }
protected void rdAssetTypeGrid_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e) { if (_assetReclamationServiceLocation != null) { GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem; Hashtable values = new Hashtable(); dataItem.ExtractValues(values); int assetCategoryId = Convert.ToInt32(values["AssetCategoryId"].ToString()); AssetCategoryEntity assetCategory = new AssetCategoryEntity(assetCategoryId); var assetTypes = from at in _db.AssetType where at.AssetCategoryId == assetCategory.AssetCategoryId orderby at.Name select at; var serviceLocationAssetTypes = from slat in _db.ServiceLocationAssetType join at in _db.AssetType on slat.AssetTypeId equals at.AssetTypeId join ac in _db.AssetCategory on at.AssetCategoryId equals ac.AssetCategoryId where at.AssetCategoryId == assetCategory.AssetCategoryId && slat.ServiceLocationId == _assetReclamationServiceLocation.ServiceLocationId select slat; List <ServiceLocationAssetTypeEntity> slats = new List <ServiceLocationAssetTypeEntity>(); foreach (AssetTypeEntity ate in assetTypes) { if (serviceLocationAssetTypes.Where(x => x.AssetTypeId == ate.AssetTypeId).Count() > 0) { slats.Add(serviceLocationAssetTypes.Where(x => x.AssetTypeId == ate.AssetTypeId).First()); } else { ServiceLocationAssetTypeEntity slat = new ServiceLocationAssetTypeEntity(); slat.ServiceLocationId = _assetReclamationServiceLocation.ServiceLocationId; slat.AssetTypeId = ate.AssetTypeId; slat.PricePerUnit = 0; slat.Save(); slats.Add(slat); } } e.DetailTableView.DataSource = slats.OrderBy(x => x.AssetType.Name); } else { e.DetailTableView.DataSource = null; } }
protected void btnSaveAssetTypePrices_Click(object sender, EventArgs e) { foreach (GridDataItem assetCategoryItem in rdAssetTypeGrid.Items) { GridNestedViewItem detailView = (GridNestedViewItem)assetCategoryItem.ChildItem; if (detailView != null) { GridTableView tableView = detailView.NestedTableViews.First(); foreach (GridDataItem assetTypeItem in tableView.Items) { Hashtable assetTypeValues = new Hashtable(); assetTypeItem.ExtractValues(assetTypeValues); int serviceLocationAssetTypeId = Convert.ToInt32(assetTypeValues["ServiceLocationAssetTypeId"].ToString()); ServiceLocationAssetTypeEntity serviceLocationAssetType = new ServiceLocationAssetTypeEntity(serviceLocationAssetTypeId); TextBox txtPricePerUnit = assetTypeItem.FindControl("txtPricePerUnit") as TextBox; HiddenField hdnOrigPrice = assetTypeItem.FindControl("hdnOrigPrice") as HiddenField; decimal price = 0; decimal origPrice = Convert.ToDecimal(hdnOrigPrice.Value.Trim().Replace("$", "")); if (txtPricePerUnit.Text.Trim().Length > 0) { price = Convert.ToDecimal(txtPricePerUnit.Text.Trim().Replace("$", "")); } serviceLocationAssetType.PricePerUnit = price; serviceLocationAssetType.Save(); if (price != origPrice) { ChangeLogEntity cle = new ChangeLogEntity(); cle.UserId = sm.AuthenticatedUser.UserId; cle.ChangeDate = DateTime.Now; cle.ChangeTypeId = (int)ChangeTypeEntity.ChangeTypes.AssetTypePriceChange; cle.Save(); ServiceLocationAssetTypeChangeLogEntity slatcle = new ServiceLocationAssetTypeChangeLogEntity(); slatcle.ServiceLocationAssetTypeId = serviceLocationAssetType.ServiceLocationAssetTypeId; slatcle.ChangeLog = cle; slatcle.Save(); } } } } messages.AddSuccessDiv("Asset types successfully saved"); }
protected void rdAssetTypeGrid_OnItemDataBound(object sender, GridItemEventArgs e) { if (_assetReclamationServiceLocation != null) { if (e.Item is GridDataItem && !_assetReclamationServiceLocation.IsNew) { if (e.Item.OwnerTableView.Name == "AssetTypeView" && _assetReclamationServiceLocation.ServiceTypeId == (int)ServiceTypeEntity.ServiceTypes.AssetReclamationOnly) { ServiceLocationAssetTypeEntity assetType = e.Item.DataItem as ServiceLocationAssetTypeEntity; TextBox txtPricePerUnit = e.Item.FindControl("txtPricePerUnit") as TextBox; HiddenField hdnOrigPrice = e.Item.FindControl("hdnOrigPrice") as HiddenField; if (txtPricePerUnit != null) { var serviceLocationAssetType = (from slat in _db.ServiceLocationAssetType where slat.AssetTypeId == assetType.AssetTypeId && slat.ServiceLocationId == _assetReclamationServiceLocation.ServiceLocationId select slat).ToList(); if (serviceLocationAssetType.Count() == 0) { ServiceLocationAssetTypeEntity slat = new ServiceLocationAssetTypeEntity(); slat.ServiceLocationId = _assetReclamationServiceLocation.ServiceLocationId; slat.AssetTypeId = assetType.AssetTypeId; slat.PricePerUnit = 0; slat.Save(); txtPricePerUnit.Text = slat.PricePerUnit.ToString("C"); } else { ServiceLocationAssetTypeEntity slat = serviceLocationAssetType.First(); txtPricePerUnit.Text = slat.PricePerUnit.ToString("C"); } hdnOrigPrice.Value = txtPricePerUnit.Text; } } } } else { rdAssetTypeGrid.DataSource = null; } }
protected ServiceLocationAssetTypeChangeLogEntity(SerializationInfo info, StreamingContext context) : base(info, context) { if (SerializationHelper.Optimization != SerializationOptimization.Fast) { _changeLog = (ChangeLogEntity)info.GetValue("_changeLog", typeof(ChangeLogEntity)); if (_changeLog != null) { _changeLog.AfterSave += new EventHandler(OnEntityAfterSave); } _serviceLocationAssetType = (ServiceLocationAssetTypeEntity)info.GetValue("_serviceLocationAssetType", typeof(ServiceLocationAssetTypeEntity)); if (_serviceLocationAssetType != null) { _serviceLocationAssetType.AfterSave += new EventHandler(OnEntityAfterSave); } base.FixupDeserialization(FieldInfoProviderSingleton.GetInstance()); } // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor // __LLBLGENPRO_USER_CODE_REGION_END }
/// <summary> Removes the sync logic for member _serviceLocationAssetType</summary> /// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param> /// <param name="resetFKFields">if set to true it will also reset the FK fields pointing to the related entity</param> private void DesetupSyncServiceLocationAssetType(bool signalRelatedEntity, bool resetFKFields) { base.PerformDesetupSyncRelatedEntity(_serviceLocationAssetType, new PropertyChangedEventHandler(OnServiceLocationAssetTypePropertyChanged), "ServiceLocationAssetType", ServiceLocationAssetTypeChangeLogEntity.Relations.ServiceLocationAssetTypeEntityUsingServiceLocationAssetTypeId, true, signalRelatedEntity, "ServiceLocationAssetTypeChangeLog", resetFKFields, new int[] { (int)ServiceLocationAssetTypeChangeLogFieldIndex.ServiceLocationAssetTypeId }); _serviceLocationAssetType = null; }