Rules not being checked on save?


Author
Message
Andria Jensen
Andria Jensen
Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)
Group: Forum Members
Posts: 336, Visits: 497
This is more complicated than a couple of files, but I will try to get something together to put on here.
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Actually, the ParentContainer property is the only one that needs to be set... weird.  Are you setting the property before, or after the call to InitializeComponent?  I tried this, and it works:

Public Class Form1

Public Sub New()

' This call is required by the Windows Form Designer.

InitializeComponent()

' Add any initialization after the InitializeComponent() call.

Me.BusinessObject2.ParentContainer = Me

End Sub

Friend WithEvents BusinessObject2 As New BusinessObject1()

Private Sub BusinessObject2_ParentFormLoading() Handles BusinessObject2.ParentFormLoading

End Sub

End Class

Putting a breakpoint on the ParentFormLoading event handler gets it to stop there, so I'm not sure what's wrong.  Are you re-intantiating the business object anywhere?

Maybe you could attach a .zip of a couple of the files so that I can reproduce the problem.

Andria Jensen
Andria Jensen
Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)
Group: Forum Members
Posts: 336, Visits: 497
I added the ParentFormLoading handler and it is not hitting that either.  It must be something going wrong in initialization as you said.  I am actually using an instance of a BO created at runtime, so i'm not dropping it on at design time.  This may be the issue since I could have missed some settings I needed, which also explains why I had to explicitly set the ParentContainer.  If I create a BO this way, what properties need to be set?
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
I don't think you need the "Handles Me.CheckRulesOnCurrentRow" on the end of that because we're explicitly adding a handler to the event in the AddHandlers method.  It's most likely an initialization problem... if you add a handler to the ParentFormLoading event of the business object, does it reach that method?  Are you dropping the HdrBO on the form, or are you dropping it on the user control?  The ParentContainer property on the business object should be set within the InitializeComponent() method, so you shouldn't have to set it twice...
Andria Jensen
Andria Jensen
Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)
Group: Forum Members
Posts: 336, Visits: 497
I have not changed the constructors or the AddHandlers method.  They are as follows:

Public Sub New()
  MyBase.New()
  'This call is required by the Component Designer.
  Me.InitializeComponent()
  '-- Add the necessary handlers
  Me.AddHandlers()
End Sub

Private Sub AddHandlers()
 
AddHandler Me.CheckRulesOnCurrentRow, AddressOf BizTypeBO_CheckRulesOnCurrentRow
 
AddHandler Me.SetDefaultValues, AddressOf BizTypeBO_SetDefaultValues
End Sub

Private Sub BizTypeBO_CheckRulesOnCurrentRow(ByVal e As MicroFour.StrataFrame.Business.CheckRulesEventArgs)
Handles Me.CheckRulesOnCurrentRow

  If Me.ExecuteScalar(sqlCount) > 0 Then
   
Me.AddBrokenRule(Me.BizType, "This value already exists in the table.")
 
End If

End Sub

 

 

When I was trying to get the RequiredFields to pop the error icons on the form, I had to set the BO's ParentContainer to the form I am using it on.  Is there something like this that needs to be done in order for the other BusinessRules to be checked.  I have to be missing something, I just can't seem to figure out what.

 


StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
There is a method within the constructor of the business objects called AddHandlers that adds the handlers for the SetDefaultValues and CheckRulesOnCurrentRow events... Make sure that your business object is using a constructor that is actually calling those methods.  (If you're creating your own constructor, you'll need to base it off of one of the other constructors that is created by the business object template.)

As for the list, there are not any properties for selecting specific rows after the list is populated... you'll have to create a local or private variable and save off the row index of the list and set it back after the requery.

Andria Jensen
Andria Jensen
Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)
Group: Forum Members
Posts: 336, Visits: 497
I  have created a user control which does maintenance on a business object.  It's like the maintenance strip where you can set a BO to it, and on button clicks it will call Save, Delete, Undo, etc.  I have the following code in the form's New where MaintStrip is the user control I have created and HdrBO is the BO to perform actions on.

HdrBO.ParentContainer = Me
Me.BusinessObject = HdrBO
Me.BusinessObjects.Add(HdrBO)
Me.PrimaryBusinessObject = HdrBO
MaintStrip.BusinessObject = HdrBO

Most everything works except a couple of things: 

When I save, the rules don't seem to be getting checked.  I put a break in CheckRulesOnCurrentRow in the BO and it's not getting hit.  What determines when this is called and why might I not be hitting it?  It is checking the RequiredFields collection because I am getting the Errors popping if I leave something blank.  Just not checking the business rules.

Also, I have an enhanced list on the form that is linked to the same business object.  Is there an easy way to keep up with the FocusedRow on this list?  Right now, I am having to call Requery after editing the BO, and then the focus jumps to the first row no matter what.  I would like for the focus to go to whatever row was just added, or if there was a delete to the row after the one which was deleted.  Any properties I can set or methods I can use to accomplish this easily?

 

 


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search