Beta 1.6.5.1: ListView enhanced features....


Author
Message
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Trent L. Taylor (04/29/2008)
Greg is still right....there is no reason to even allow the ListView to Requery itself if there is no parent record.  More than likely you already have something in the Navigated event of the parent BO that calls a Refresh on the child list...if there are no parent records, the you can just clear the list and ensure that your form method is called:

Trent, if you look at my previous message, you will notice that I am only calling the ListView.Refresh() method in the ParentBO.Navigated() event.  The ListView is being populated by MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromDefaultView, see the code below.

Private Sub lvPolicy_ListPopulating(ByVal e As MicroFour.StrataFrame.UI.ListPopulatingEventArgs) Handles lvPolicy.ListPopulating

     '-- Use the already populated business object on the form to load the list.

     e.Parameters(0).Value = Me.Child_PolicyBO1

     '-- Tell the business object that will be used in the listview (creates a new instance)

     '-- to clear itself and load from the forms default view on the Customers business object.

     e.Parameters(1).Value = MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromDefaultView

End Sub

This is a bit frustrating BigGrin  As you can see, I am not calling the ListView.Refresh() in any other place other than the ParentBO.Navigated() event and I still believe that the problem is in the ListView code which will be called after all other events has occurred and it is setting the Add button Enabled=True.

I hope you can see this and if possible test it.

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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 (116 views, 743.00 KB)
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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 (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K 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 (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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 (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K 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 (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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 (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Thanks Trent.

Edhy Rijo

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K 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 (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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)

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