By Andria Jensen - 10/25/2007				
            
                      
            I have several controls on a form, all with BindingField properties set on them.  When one changes, it affects the value of several others.  For example, I may have a Days field which affects the calculation of a Date2 field.  This would be something like Date2=Date1+Days.  When I type a value into the Days field I want it to update Date2 with whatever is in Date1 plus whatever I just typed into Days.My question is how to best do this when binding to a BO field.  There seems to be some odd behavior in which it is struggling to know whether to use the data in the BO or the data in the field.  How do I make this work correctly?? 
           
		 | 			
		
	
		
				      		    
		
		
            
            
            By Paul Chase - 10/26/2007				
            
                      
            Andria,I am doing this type of thing by having the BO raise a field changed or changing event and then handling that event and setting the values. It works out great except if with a business binding source, then you will run into some issues with this appoach.   
 You can also just add the code to the set method of the field to change the values of the other fields as well.  ''' <summary> ''' cki_Amount''' </summary>''' <remarks></remarks><Browsable( False), _BusinessFieldDisplayInEditor(), _ Description("cki_Amount"), _ DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _ Public Property [cki_Amount]() As System.DecimalGetReturn CType(Me.CurrentRow.Item("cki_Amount"), System.Decimal)End GetSet(ByVal value As System.Decimal)'Set the Value 's of whtever elseme.someproperty  = somevalue'Set the Value Me.CurrentRow.Item("cki_Amount") = valueEnd Set
           
		 | 			
		
	
		
				      		    
		
		
            
            
            By Trent L. Taylor - 10/26/2007				
            
                      
            Andria,Pauls example is very good and it will keep the logic within the BO using this approach and it is probably the cleanest solution.  There are also times that this may be more of a "one-time-thing" and I might handle a SelectedIndexChanged event or a TextChanged event, something of that nature, to add the logic.  However, this does break encapsulation and if the same logic is required in another location then you are asking for a bug.  The best and safest approach is Pauls example. 
           
		 | 			
		
	
		
				      		    
		
		
            
            
            By Andria Jensen - 10/26/2007				
            
                      
            Great thanks, that's just what I was looking for.   
           
		 | 			
		
	
		
				      		    
		
		
            
            
            By Andria Jensen - 10/26/2007				
            
                      
            Okay, I think maybe I found a bug with this.  When I went in and added the FieldPropertyChanged event, the code generated an extra 'End If' in 4 of my properties.  Turns out these are the only properties set to  'Return Alternate on Null/Set Null on Alternate (value type)' in this business object.  The code it generated looks like the following.  The extra 'End If' is bolded.''' <summary> ''' NextRunDate ''' </summary> ''' <remarks></remarks> <Browsable(False), _ BusinessFieldDisplayInEditor(), _ Description("NextRunDate"), _ DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _ Public Property [NextRunDate]() As System.DateTime   Get     Dim loValue As Object     loValue = Me.CurrentRow.Item("NextRunDate")     If loValue Is DBNull.Value Then       Return #1/1/1800#     Else       Return CType(loValue, System.DateTime)     End If   End Get   Set(ByVal value As System.DateTime)     Dim llRaiseEvent As Boolean = False     Dim loRow As DataRow = Me.CurrentRow     If value <> #1/1/1800# Then       If Not loRow.Item("NextRunDate").Equals(value) Then llRaiseEvent = True     Else       If Not loRow.Item("NextRunDate").Equals(DBNull.Value) Then llRaiseEvent = True     End If End If     If value <> #1/1/1800# Then       loRow.Item("NextRunDate") = value     Else       loRow.Item("NextRunDate") = DBNull.Value     End If     If llRaiseEvent Then Me.OnFieldPropertyChanged(Me, New   ABLFacilityBOFieldChangedEventArgs(ABLFacilityBOFieldNames.NextRunDate))   End SetEnd Property
           
		 | 			
		
	
		
				      		    
		
		
            
            
            By Trent L. Taylor - 10/26/2007				
            
                      
            This has already been fixed...and talked about a lot lately  Get the fix here: http://forum.strataframe.net/Topic11831-10-1.aspx#bm11844  
           
		 | 			
		
	
		
				      		    
		
		
            
            
            By Greg McGuffey - 10/26/2007				
            
                      
            So this is were all those missing end ifs went!    
           
		 | 			
		
	
		
				      		    
		
		
            
            
            By Andria Jensen - 10/26/2007				
            
                      
            Ah, I must have missed the big conversation.  Thanks for the fix.
           
		 | 			
		
	
		
				      		    
		
		
            
            
            By Andria Jensen - 10/26/2007				
            
                      
            Wait a second....you linked me back to my post.  And since that's my post, I already have those files which means they didn't fix that issue for me.   
           
		 | 			
		
	
		
				      		    
		
		
            
            
            By Greg McGuffey - 10/26/2007				
            
                      
            I was making a joke  
 
 
  The problem reported about a hundred times in the forms is missing end ifs in a BO designer when the field has alternate values on null.
 
 
  Then you discover that when you add events to the properties, there are extra end ifs (different bug for sure), so, I was like, you know, er...just saying that we found all those missing end ifs from the first bug  
           
		 | 			
		
	
		
				      		    
		
		
            
            
            By Greg McGuffey - 10/26/2007				
            
                      
            Oops, Trent slipped a post in while I was writing my post...you weren't responding to me...  Oh, the embarrassment  
           
		 | 			
		
	
		
				      		    
		
		
            
            
            By Andria Jensen - 10/29/2007				
            
                      
            I just wanted to make sure you guys know that this is a DIFFERENT issue than the one you linked me to.  That issue is about missing 'End If' statements and this one is about extra 'End If' statements.  The fix that I have does not fix this problem, so it does still need to be addressed.  I just didn't want that to get lost in translation somehow. 
           
		 | 			
		
	
		
				      		    
		
		
            
            
            By StrataFrame Team - 10/30/2007				
            
                      
            Nope, it hasn't been lost in translation, and I'm in the process of fixing it right now, stay tuned  
           
		 | 			
		
	
		
				      		    
		
		
            
            
            By StrataFrame Team - 10/30/2007				
            
                      
            Ok, here's the posted fix, Andria:http://forum.strataframe.net/FindPost12258.aspx And to everyone: I'm doing my best to take your advice and post the updates in the update thread at the top of the forum home page   
           
		 |