I do some calculation when user remove a related child entity from interface, the same coding works fine with v1, it threw the following exception in v2.
QuotationDetails.EntityRemoved += new EventHandler<CollectionChangedEventArgs>(QuotationDetails_EntityRemoved);
void QuotationDetails_EntityRemoved(object sender, CollectionChangedEventArgs e)
{
QuotationDetailEntity detail = (QuotationDetailEntity)e.InvolvedEntity;
if (detail.PriceAmt.HasValue) TotPriceAmt -= detail.PriceAmt.Value;
if (detail.ExtPrice.HasValue) TotExtPrice -= detail.ExtPrice.Value;
if (detail.LdiscAmt.HasValue) TotLdiscAmt -= detail.LdiscAmt.Value;
if (detail.NetItemAmt.HasValue) TotItemAmt -= detail.NetItemAmt.Value;
SummarizeOrderTotal();
}
public override bool SetNewFieldValue(int fieldIndex, object value)
{
bool toReturn = base.SetNewFieldValue (fieldIndex, value, false);
if(toReturn && Enum.IsDefined(typeof(QuotationFieldIndex), fieldIndex))
{
switch((QuotationFieldIndex)fieldIndex)
{
default:
break;
}
base.PostFieldValueSetAction(toReturn, this.Fields[fieldIndex].Name);
}
return toReturn;
}
Index was out of range. Must be non-negative and less than the size of the collection.
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore`1.get_Item(Int32 index)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase`1.GetEntityAtIndex(Int32 index)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase`1.System.Collections.IList.get_Item(Int32 index)
at System.Windows.Forms.BindingSource.get_Item(Int32 index)
at System.Windows.Forms.CurrencyManager.OnCurrentChanged(EventArgs e)
at System.Windows.Forms.CurrencyManager.ChangeRecordState(Int32 newPosition, Boolean validating, Boolean endCurrentEdit, Boolean firePositionChange, Boolean pullData)
at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
at System.ComponentModel.ListChangedEventHandler.Invoke(Object sender, ListChangedEventArgs e)
at System.Windows.Forms.BindingSource.OnListChanged(ListChangedEventArgs e)
at System.Windows.Forms.BindingSource.SetList(IList list, Boolean metaDataChanged, Boolean applySortAndFilter)
at System.Windows.Forms.BindingSource.ParentCurrencyManager_CurrentItemChanged(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.CurrencyManager.OnCurrentItemChanged(EventArgs e)
at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
at System.Windows.Forms.BindingSource.OnListChanged(ListChangedEventArgs e)
at System.Windows.Forms.BindingSource.InnerList_ListChanged(Object sender, ListChangedEventArgs e)
at System.ComponentModel.BindingList`1.OnListChanged(ListChangedEventArgs e)
at System.ComponentModel.BindingList`1.Child_PropertyChanged(Object sender, PropertyChangedEventArgs e)
at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.OnPropertyChanged(String propertyName)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.PostFieldValueSetAction(Boolean fieldValueSet, String propertyName)
at Test.EntityClasses.QuotationEntity.SetNewFieldValue(Int32 fieldIndex, Object value)
at Test.EntityClasses.QuotationEntity.set_TotPriceAmt(Nullable`1 value)
at Test.EntityClasses.QuotationEntity.QuotationDetails_EntityRemoved(Object sender, CollectionChangedEventArgs e)
at SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore`1.OnEntityRemoved(T entityToRemove)
at SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore`1.RemoveAt(Int32 index)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase`1.RemoveAt(Int32 index)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase`1.System.Collections.IList.RemoveAt(Int32 index)
at System.Windows.Forms.BindingSource.RemoveAt(Int32 index)
at System.Windows.Forms.CurrencyManager.RemoveAt(Int32 index)
at Infragistics.Win.UltraWinGrid.UltraGridRow.DeleteHelper()
at Infragistics.Win.UltraWinGrid.UltraGridLayout.InternalDeleteRowsHelper(SelectedRowsCollection Rows, Boolean displayPrompt)
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore`1.get_Item(Int32 index)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase`1.GetEntityAtIndex(Int32 index)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase`1.System.Collections.IList.get_Item(Int32 index)
at System.Windows.Forms.BindingSource.get_Item(Int32 index)
at System.Windows.Forms.CurrencyManager.OnCurrentChanged(EventArgs e)
at System.Windows.Forms.CurrencyManager.ChangeRecordState(Int32 newPosition, Boolean validating, Boolean endCurrentEdit, Boolean firePositionChange, Boolean pullData)
at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
at System.ComponentModel.ListChangedEventHandler.Invoke(Object sender, ListChangedEventArgs e)
at System.Windows.Forms.BindingSource.OnListChanged(ListChangedEventArgs e)
at System.Windows.Forms.BindingSource.SetList(IList list, Boolean metaDataChanged, Boolean applySortAndFilter)
at System.Windows.Forms.BindingSource.ParentCurrencyManager_CurrentItemChanged(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.CurrencyManager.OnCurrentItemChanged(EventArgs e)
at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
at System.Windows.Forms.BindingSource.OnListChanged(ListChangedEventArgs e)
at System.Windows.Forms.BindingSource.InnerList_ListChanged(Object sender, ListChangedEventArgs e)
at System.ComponentModel.BindingList`1.OnListChanged(ListChangedEventArgs e)
at System.ComponentModel.BindingList`1.Child_PropertyChanged(Object sender, PropertyChangedEventArgs e)
at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.OnPropertyChanged(String propertyName)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.PostFieldValueSetAction(Boolean fieldValueSet, String propertyName)
at Test.EntityClasses.QuotationEntity.SetNewFieldValue(Int32 fieldIndex, Object value)
at Test.EntityClasses.QuotationEntity.set_TotPriceAmt(Nullable`1 value)
at Test.EntityClasses.QuotationEntity.QuotationDetails_EntityRemoved(Object sender, CollectionChangedEventArgs e)
at SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore`1.OnEntityRemoved(T entityToRemove)
at SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore`1.RemoveAt(Int32 index)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase`1.RemoveAt(Int32 index)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase`1.System.Collections.IList.RemoveAt(Int32 index)
at System.Windows.Forms.BindingSource.RemoveAt(Int32 index)
at System.Windows.Forms.CurrencyManager.RemoveAt(Int32 index)
at Infragistics.Win.UltraWinGrid.UltraGridRow.DeleteHelper()
at Infragistics.Win.UltraWinGrid.UltraGridLayout.InternalDeleteRowsHelper(SelectedRowsCollection Rows, Boolean displayPrompt)