Beta 1.6.5.1: ListView enhanced features....


Author
Message
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Trent,

First, thanks for all the enhancements done to the ListView, very impressive Smile

I setup a form to test the ListView and found the following issues:

  • Moving the record pointer in the ToolStrip button does not update/refresh the ListView.
  • Creating a new record or modifying an existing one does not Refresh the ListView with the updated data.

I tested the functionality of the Add/Delete/Edit Objects and they all worked as expected. 

One question, when using the ListView with a child BO, I may need to have buttons for Save/Undo if not using a childform object, would you consider adding a SaveObject/UndoObject as well for this case?

Please take a loot at the video in this link:  http://www.progytech.com/videos/Beta_ListView\Beta_ListView.html

Edhy Rijo

Replies
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Try this assembly.  It also includes the changes I made to the DateTimePicker.  I will do another build later today and post it on the forum for the 1.6.6 beta that will include both of these changes.
Attachments
MicroFourStrataFrameUI.zip (137 views, 743.00 KB)
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Edhy,

This won't work until I make some other changes....this is why I was reluctant to mess with it.  Also, in order for this to work, you will have to define the parent relationship and set the ParentBusinessObject properties...but at this point it still won't work.  I will have to add handlers to the parent BO events.

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Trent L. Taylor (04/30/2008)
Try this assembly.  It also includes the changes I made to the DateTimePicker.  I will do another build later today and post it on the forum for the 1.6.6 beta that will include both of these changes.

Hi Trent,

Sorry, but this assembly did not fix the problem with the ListView Add button.Angry  It did fix the DateTimePicker problem.

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Actually, I just tested it and it DOES fix the problem.  Your program is not setup right.  You need to create a ParentRelationship on the OrdersBO that is CustomersBO.  Then on the form (after you recompile) set the ParentBusinessObject to the CustomersBO1 on the form....then the final, most important step, and this could be why you have had other issues, set the BusinessObject property on the ListView to the OrdersBO1 on the form.  If you do all of this, as it was intended to work, it will work like you want it to.
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Trent L. Taylor (04/30/2008)
Actually, I just tested it and it DOES fix the problem.

Hi again,

Yes IT DOES WORK, sorry but my quick sample project was too quick BigGrin and not setup properly, but after testin in my actual project it did work and then after adding all the missing setp in the quick project it also worked.

If you don't mind, could you tell me what was changed in the source code?

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Sure, I just changed the UpdateObjectStates method to this:

''' <summary>
''' Updates the objects states based on the selected state of the list items and security
''' </summary>
''' <remarks></remarks>
Private Sub UpdateObjectStates()
    '-- Establish Locals
    Dim isSelected As Boolean = Me.SelectedItems.Count > 0
    Dim isAddAllowed As Boolean = HasPermission(_AddObjectSecurityKey)
    '-- Determine if additional logic should be performed to determine the add status
    If (_BusinessObject IsNot Nothing) AndAlso _
       (_BusinessObject.ParentBusinessObject IsNot Nothing) AndAlso _
       isAddAllowed Then
        isAddAllowed = _BusinessObject.ParentBusinessObject.Count > 0
    End If
    If _AddObject IsNot Nothing Then SetObjectEnabledState(_AddObject, isAddAllowed)
    If _EditObject IsNot Nothing Then SetObjectEnabledState(_EditObject, isSelected AndAlso HasPermission(_EditObjectSecurityKey))
    If _DeleteObject IsNot Nothing Then SetObjectEnabledState(_DeleteObject, isSelected AndAlso HasPermission(_DeleteObjectSecurityKey))
End Sub

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Thanks Trent.

Edhy Rijo

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Trent,

The DeleteChildRecord() method of the ListView is marking the records as deleted which then will require a Save() to actually delete the record.

'-- If we are here, then delete the record

_BusinessObject.DeleteCurrentRow(True)

In my form which uses 3 ListViews in the same fashion I have the need to permanently delete the record when the DeleteChildRecord() is being executed.  I tried adding code in the BO_AfterDelete() event to save this child BO but I am getting an error:

Private Sub Child_PolicyBO1_AfterDelete(ByVal e As MicroFour.StrataFrame.Business.AfterDeleteEventArgs) Handles Child_PolicyBO1.AfterDelete

     If e.RowsAffected > 0 Then

          Me.Child_PolicyBO1.Save()

     End If

End Sub

This is the error:

BusinessLayerException
  An error occurred while saving the data to the server.
IndexOutOfRangeException
  Index 0 is either negative or above rows count.

Source     : MicroFour StrataFrame Business

Stack Trace:
   at System.Data.DataView.GetRow(Int32 index)
   at System.Data.DataView.get_Item(Int32 recordIndex)
   at MicroFour.StrataFrame.Business.BusinessLayer.get_CurrentRow()
   at MicroFour.StrataFrame.Business.BusinessLayer.FilterChildRecords(BusinessLayer ChildBusinessObject)
   at MicroFour.StrataFrame.Business.BusinessLayer.Save(Boolean Transactional, String TransactionKey)
   at MicroFour.StrataFrame.Business.BusinessLayer.Save()
   at IBS_UI.frmInsuredCustomer.Child_PolicyBO1_AfterDelete(AfterDeleteEventArgs e) in E:\Visual Studio 2008 Projects\StrataFrame\Insurance Broker System (SF)\UI\Main Forms\frmInsuredCustomer.vb:line 226
   at MicroFour.StrataFrame.Business.BusinessLayer.AfterDeleteEventHandler.Invoke(AfterDeleteEventArgs e)
   at MicroFour.StrataFrame.Business.BusinessLayer.raise_AfterDelete(AfterDeleteEventArgs e)
   at MicroFour.StrataFrame.Business.BusinessLayer.OnAfterDelete(AfterDeleteEventArgs e)
   at MicroFour.StrataFrame.Business.BusinessLayer.DeleteCurrentRow(Boolean CheckSecurity, Boolean OnlyMarkAsDeleted)
   at MicroFour.StrataFrame.Business.BusinessLayer.DeleteCurrentRow(Boolean OnlyMarkAsDeleted)
   at MicroFour.StrataFrame.UI.Windows.Forms.ListView.DeleteChildRecord()
   at MicroFour.StrataFrame.UI.Windows.Forms.ListView.HandleObjectClick(Object sender, EventArgs e)
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
   at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Where should I call the BO.Save() to permanent delete the record?

P.S.

I think that a new property in the ListView to flag the DeleteChildRecord() as OnlyMarkAsDeleted or not, may be an easy way to solve this.



Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Your error has less to do with the delete than it does binding it would appear.  Something is trying to reference the CurrentRow property of the BO, thus the error.

To prove it, and to do this yourself, just set the HandleDeleteAction to false and manually delete the record...it should already be on the correct record, etc.

MyBo.DeleteCurrentRow(False)

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
I did the test as follow and it worked just fine, of course passing the False to the DeleteCurrentRow() method does not requires me to Save() the record :

Private Sub cmdDelete_Policy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete_Policy.Click

     '-- If no business object is attached then there is nothing to do

     If Me.Child_PolicyBO1 Is Nothing Then Exit Sub

     '-- Ensure the the correct record is selected in case it had been moved by the developer

     Me.Child_PolicyBO1.NavigateToPrimaryKey(Me.lvPolicy.SelectedItems(0).Tag)

     '-- If we are here, then delete the record    

     Me.Child_PolicyBO1.DeleteCurrentRow(False)

      '-- Requery this list

     Me.lvPolicy.Requery()

End Sub

Like I said before I think that a new property in the ListView to flag the DeleteChildRecord() as OnlyMarkAsDeleted or not, will take care of this situation and will not require us to add more code to the form whenever the ListView is used and the Delete action needs to be permanent.



Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Edhy,

Let me just point out something when we address a problem...we first try to get to the source of an issue before we add a new feature.   Just because you get an error to go away doesn't mean that the problem is fixed.  Adding a property is not big deal and I have no issue doing this at some point...so just because I don't immediately say, "I will go add this right now!" doesn't mean that it has no merit...it just means that it doesn't get to the crux of the issue.

If you look at your stack trace, something was trying to bind or pull from the CurrentRow...which could be related to the code in the ListView possibly and we may need to setup a test.  Thus I suggested the manual code change to see if something else arose.  I will see if I can reproduce the error, but until I prove the error, I will not add a property.  It is more important for me to understand why there was an error so that something else is not introduced versus just providing a fix that may prevent the error but we don't know why.

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Trent,

Just because you get an error to go away doesn't mean that the problem is fixed.

I do understand what you are saying and respect your policies.  But so we are in the same page here let me clarify the problem a little bit:

  • The ListView enhancement is in beta and I am using this control a lot.
  • When testing the Delete functionality I noticed that the record was only marked as deleted, and could not find a way to change this behavior without disabling the HandleDeleteAction and adding a custom code for all ListView used in this form.
  • Since the mark as deleted will required a call to the BO.Save() to permanently delete the record, then I tried to do that and got the error reported.
  • Based on the test you asked me to do, by calling the BO.DeleteCurrentRow(False) will work fine, then I make the suggestion to add the property to control how the DeleteCurrentRow will behave.

I am trying to move forward with this project and have not problem to take the time to investigate any problem, in fact I spend a lot of time in the forums before posting to try to get answers to my stituations, but I do really need to be ready to show this project to the customer anytime soon.  So for now I will simply add a common DeleteRecord method for my ListViews.Hehe

Edhy Rijo

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Trent,

I have another situation with the ListView, I guess BigGrin

I am using the HandleAddAction = True to let the ListView calling the ChildForm when adding.  I added the code below to cancel the Adding if the Save() of the parent BO is not Success, but even though I am setting the e.Cancel = True, the ChildForm is being shown.  Am I using the correct logic here?

Private Sub Child_PolicyBO1_BeforeAddNew(ByVal e As MicroFour.StrataFrame.Business.BeforeAddNewEventArgs) Handles Child_PolicyBO1.BeforeAddNew

     If Me.InsuredCustomerBO1.IsDirty Then

          If Me.Save() <> MicroFour.StrataFrame.Data.SaveUndoResult.Success Then

               e.Cancel = True

          End If

     End If

End Sub

P.S.

FYI, since the ListView enhancements are still in beta, I keep posting in this thread to keep everything related to this in one place, if you prefer I can post this kind of stuff in a separate thread.

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
That cancel flag doesn't logically tie into the BOs BeforeAddNew...so the cancel will not have any affect in this case.  That Cancel only has to do with adding a new row to the BO...and FYI...saving within that event could come back and slap you at some point...this is generally never a good idea.

However, it might not be a bad idea to have a BeforeShowChildDialog event on the ListView so that you could cancel it if you like.

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Trent L. Taylor (05/21/2008)
...and FYI...saving within that event could come back and slap you at some point...this is generally never a good idea.

Point taken, then where to put the save code then?  In the ChildForm I am making a reference to the ParentBO PK field value which will be -1 if not saved and brake the code.  Any suggestion?

So However, it might not be a bad idea to have a BeforeShowChildDialog event on the ListView so that you could cancel it if you like.

That sounds good. Hehe

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Point taken, then where to put the save code then?  In the ChildForm I am making a reference to the ParentBO PK field value which will be -1 if not saved and brake the code.  Any suggestion?

This is the whole point of a parent relationship.  You SHOULD be able to create a child record on a parent that doesn't yet have a PK yet.  SF will automatically persist the parent's PK to the child once the parent gets a PK.  So you should be saving these records at the same time.  It isn't fair to require the end-user to save a parent record before a child gets created.  All of this should be able to be done at the same time.

In one maintenance form that I recently finished, I have 11 child and grandchild records that could be created on a new record without ever first requiring a parent record to first be saved.  So that is the first thing I would rework versus forcing the save of the parent.

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Trent L. Taylor (05/21/2008)
In one maintenance form that I recently finished, I have 11 child and grandchild records that could be created on a new record without ever first requiring a parent record to first be saved.  So that is the first thing I would rework versus forcing the save of the parent.
  • So basically all child BO should be Saved when clicking the Save button in the Parent Form? 
  • I guess that if I select Undo from the toolbar that all child data will be undoed?

Guess I am still thinking as a VFP developer BigGrin

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
So basically all child BO should be Saved when clicking the Save button in the Parent Form?

Yes.  All Save and Undo logic should occur from a single point (not the child form Smile ) but the most common place would be the Parent form or container.

I guess that if I select Undo from the toolbar that all child data will be undoed?

Yup...you got it Smile

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Trent,

After your post, I when to check the SF Samples and after reviewing the ChildDialogFormSample.sln I think I now have a better understanding of this concept of drilling down child forms and having control of all the savings from a single point. 

I must admit that it still scares me a bit Cool drilling down several child forms without saving and potentially undo some data that the end user may not wanted to undo, but I guess is just a matter of understanding the design purpose of the ChildFormDialog control.

I'll keep you posted Hehe

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Really, we didn't even do that in VFP (bad word, I know BigGrin).  We used table buffering and didn't commit the changes until down stream.  Granted, it was nowhere as clean as using the BOs and disconnected data, but the concept was really the same.
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Trent,

Refactoring my child forms, i have a situation with my current code in the ChildForm Save button:

Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click

     '-- Use the form' Save method to force the Broken Rules to be check and show the Broken Rule InfoBox if needed.

     If Me.Save() <> MicroFour.StrataFrame.Data.SaveUndoResult.Success Then

          Exit Sub

     ElseIf Me.Save() = MicroFour.StrataFrame.Data.SaveUndoResult.Success Then

          Me.DialogResult = Windows.Forms.DialogResult.OK

     Else

          Me.PolicyBO1.Undo(MicroFour.StrataFrame.Business.BusinessUndoType.CurrentRowOnly)

          Me.DialogResult = Windows.Forms.DialogResult.Cancel

     End If

End Sub

As you can see, I am using the Form's Save() to force the Broken Rules check and show the InfoBox.  But intent to refactor it to simply check for broken rules and return a DialogResult.OK as it should be.

In the CustomerNodeEditor form this code is being used for the same reason:

Private Sub cmdSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdSave.Click

     '-- Check the rules on the business object. We are not going to save

     '-- until we get all the way back to the parent form. A save could

     '-- be executed here if necessary, however, since this is a child

     '-- form, the parent form usually controls the saves. The true

     '-- will show the InfoBox error window if the rules are broken.

     If CustomerNotes.CheckRulesOnRow(True) Then

          Me.DialogResult = System.Windows.Forms.DialogResult.OK

     End If

End Sub

The CheckRulesOnRow(True) is not working in a sense that is not showing the required fields nor showing the InfoBox to inform the user that there is a problem with that record, but it is not entering the IF condition which mean that it is partially working.

How can I deal with this situation since in all my ChildForms I need to check for broken rules defined in the BO class?

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Just call the CheckRules method, not the CheckRulesOnRow.  For example:

If MyBo.CheckRules(True) Then
    DialogResult = OK
End If

All of the error providers will then work, however, the InfoBox will not appear and this is by design.  That logic is placed in the Save() of the BaseForm and creates a collection list...however, you can add this yourself very easily in your BaseBO.  Just handle the BusinessRulesChecked event of the BaseBO, and you will probably want to have a property that determines if the InfoBox will be shown when there are broken rules (this too would be on your BaseBo).  The only other property that you may consider adding or testing for is the parent form (or which ever form you may want the InfoBox to show within).  But you would then call the InfoBox like this:

If e.CountOfBrokenRulesAdditionalRows > 0 Then
    InfoBox.ErrorBox(...)
Else
    InfoBox.ErrorBox(...)
End If

You can look at the BaseForm in the Business assembly of the source to see what we do in that dialog.

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Trent,

In the latest update 1.6.6 a new event BeforeChildFormExecuted was added to the ListView control.  I noticed that in the ListViewBeforeChildExecuteEventArgs there is no Cancel property to cancel any action handled by the ListView control.

Would it be necessary to add the e.Cancel property, or is there any other way to abort any of the 3 actions allow in the ListView (Add/Edit/Delete)?



Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Oh, I suppose we could add a cancel parm.  It was created so that there could be a centralized localization for pre-child form initialization code.  Technically the action is already in progress (Delete would actually never hit this event).  So either an Add or Edit will already be in progress.  Adding a cancel shouldn't be too big of a deal, so I will add this to the list.
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Trent,

Trent L. Taylor (06/24/2008)
Oh, I suppose we could add a cancel parm.  It was created so that there could be a centralized localization for pre-child form initialization code.  Technically the action is already in progress (Delete would actually never hit this event).  So either an Add or Edit will already be in progress.  Adding a cancel shouldn't be too big of a deal, so I will add this to the list.

I really have the need to be able to cancel out showing the childform dialog from the listview BeforeChildFormExecuted, I have not find a way to do this in a form without having to have all the listview code in the form to manage it. 

Have you consider adding an e.Cancel parameter?



Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Done, it will be in the next update.  We will post a 1.6.7 beta build in the next week or two, but this will be included.  Here is the update:

The ListView BeforeChildFormExecuted event now has a CancelAction parm on the event argument which allows several options.  None, which would continue as normal, cancel the ChildFormDialog execution only, or cancel the dialog execution and undo any data changes related to the currently executed action (i.e. if adding a new record the new record would not be added).  This gives the best of all worlds in regards to the potential needs to cancelling an automated ChildFormDialog execution.

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Excellent!  this much more than what I asked.

Thanks Tongue

Edhy Rijo

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Edhy Rijo - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Edhy Rijo - 17 Years Ago
Edhy Rijo - 17 Years Ago
                         You probably have a filter applied or something along those lines. Or,...
Trent L. Taylor - 17 Years Ago
                             Trent, The problem was that I was not filling the Child BO and was...
Edhy Rijo - 17 Years Ago
                                 Based on my SF/.NET experience thus far...

[quote]When...
Greg McGuffey - 17 Years Ago
                                     [quote][b]Greg McGuffey (04/25/2008)[/b][hr]Hope that gets you...
Edhy Rijo - 17 Years Ago
                                         Trent, When the ListView shows the ChilForm Dim args As New...
Edhy Rijo - 17 Years Ago
                                             [quote] the form is shown as modal as it should, but it is outside the...
Trent L. Taylor - 17 Years Ago
                                                 [quote][b]Trent L. Taylor (04/27/2008)[/b][hr][quote]Initially we...
Edhy Rijo - 17 Years Ago
                                                     Hi Trent, Following my working with the ListView, I noticed that when...
Edhy Rijo - 17 Years Ago
                                                         Generally I do not allow access to the Toolstrip item if there is not...
Trent L. Taylor - 17 Years Ago
                                                             [quote][b]Trent L. Taylor (04/29/2008)[/b][hr]It is possible to add...
Edhy Rijo - 17 Years Ago
                                                                 Edhy,

You need to call the UpdateObjectStates() method...
Greg McGuffey - 17 Years Ago
                                                                     Oops, I've been sick and didn't read your post carefully enough. I...
Greg McGuffey - 17 Years Ago
                                                                         [quote][b]Greg McGuffey (04/29/2008)[/b][hr]The basic concept still...
Edhy Rijo - 17 Years Ago
                                                                         Greg is still right....there is no reason to even allow the ListView...
Trent L. Taylor - 17 Years Ago
                                                                             [quote][b]Trent L. Taylor (04/29/2008)[/b][hr]Greg is still...
Edhy Rijo - 17 Years Ago
                                                                                 Try this assembly. It also includes the changes I made to the...
Trent L. Taylor - 17 Years Ago
                                                                                     Edhy, This won't work until I make some other changes....this is why...
Trent L. Taylor - 17 Years Ago
                                                                                     [quote][b]Trent L. Taylor (04/30/2008)[/b][hr]Try this assembly. It...
Edhy Rijo - 17 Years Ago
                                                                                         Actually, I just tested it and it DOES fix the problem. Your program...
Trent L. Taylor - 17 Years Ago
                                                                                             [quote][b]Trent L. Taylor (04/30/2008)[/b][hr]Actually, I just tested...
Edhy Rijo - 17 Years Ago
                                                                                                 Sure, I just changed the UpdateObjectStates method to this:...
Trent L. Taylor - 17 Years Ago
                                                                                                     Thanks Trent.
Edhy Rijo - 17 Years Ago
                                                                                                         Trent, The DeleteChildRecord() method of the ListView is marking the...
Edhy Rijo - 17 Years Ago
                                                                                                             Your error has less to do with the delete than it does binding it...
Trent L. Taylor - 17 Years Ago
                                                                                                                 I did the test as follow and it worked just fine, of coursepassing the...
Edhy Rijo - 17 Years Ago
                                                                                                                     Edhy, Let me just point out something when we address a problem...we...
Trent L. Taylor - 17 Years Ago
                                                                                                                         Trent, [quote]Just because you get an error to go away doesn't mean...
Edhy Rijo - 17 Years Ago
                                                                                                                             Hi Trent, I have another situation with the ListView, I guess :D I...
Edhy Rijo - 17 Years Ago
                                                                                                                                 That cancel flag doesn't logically tie into the BOs BeforeAddNew...so...
Trent L. Taylor - 17 Years Ago
                                                                                                                                     [quote][b]Trent L. Taylor (05/21/2008)[/b][hr]...and FYI...saving...
Edhy Rijo - 17 Years Ago
                                                                                                                                         [quote]Point taken, then where to put the save code then? In the...
Trent L. Taylor - 17 Years Ago
                                                                                                                                             [quote][b]Trent L. Taylor (05/21/2008)[/b][hr]In one maintenance form...
Edhy Rijo - 17 Years Ago
                                                                                                                                                 [quote]So basically all child BO should be Saved when clicking the...
Trent L. Taylor - 17 Years Ago
                                                                                                                                                     Hi Trent, After your post, I when to check the SF Samples and after...
Edhy Rijo - 17 Years Ago
                                                                                                                                                         Really, we didn't even do that in VFP (bad word, I know :D). We used...
Trent L. Taylor - 17 Years Ago
                                                                                                                                                             Trent, Refactoring my child forms,i have a situation with my current...
Edhy Rijo - 17 Years Ago
                                                                                                                                                                 Just call the CheckRules method, not the CheckRulesOnRow. For example:...
Trent L. Taylor - 17 Years Ago
                                                                                                                                                                     Hi Trent, In the latest update 1.6.6 a new event...
Edhy Rijo - 17 Years Ago
                                                                                                                                                                         Oh, I suppose we could add a cancel parm. It was created so that there...
Trent L. Taylor - 17 Years Ago
                                                                                                                                                                             Hi Trent, [quote][b]Trent L. Taylor (06/24/2008)[/b][hr]Oh, I suppose...
Edhy Rijo - 17 Years Ago
                                                                                                                                                                                 Done, it will be in the next update. We will post a 1.6.7 beta build...
Trent L. Taylor - 17 Years Ago
                                                                                                                                                                                     Excellent! this much more than what I asked. Thanks :P
Edhy Rijo - 17 Years Ago
                                         [quote]Thanks Greg, much appreciated.:)[/quote]
Any time!
Greg McGuffey - 17 Years Ago
Guillermo Vilas - 17 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search