Delete on a Maintenance Form


Author
Message
Edhy Rijo
E
StrataFrame VIP (4.5K reputation)StrataFrame VIP (4.5K reputation)StrataFrame VIP (4.5K reputation)StrataFrame VIP (4.5K reputation)StrataFrame VIP (4.5K reputation)StrataFrame VIP (4.5K reputation)StrataFrame VIP (4.5K reputation)StrataFrame VIP (4.5K reputation)StrataFrame VIP (4.5K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Ivan,
I will check out the source when I have some time because I still believe that canceling the before event should stop the delete from continue.
Ex:
  1. Click Delete Button in Toolbar
    • BeforeDelete method is called in the Form.
      • BeforeDelete method in the BO is raised.  At this point setting e.Cancel = True should stop the chain reaction, so I don't understand why the BeforeDelete is being called again and again and again?

Since I use the StrataFlix logic in all my applications, I have not seen this problem because this logic uses a custom Delete method and it works just fine as expected.

Edhy Rijo

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
But Edhy, the original Delete is being Canceled just fine. What is triggering the other BeforeDelete is de DeleteRow that was coded inside it. This one will also trigger a BeforeDelete.
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Ivan. Thanks for the code, and it has got over the infinite loop. However, it asks me TWICE now if I want to delete. My Code is:

// Set up a variable to prevent an infinite loop as we are calling DeleteCurrentRow from inside DeleteCurrentRow event
private bool _CurrentlyDeleting = false;
private void scpBO1_BeforeDelete(MicroFour.StrataFrame.Business.BeforeDeleteEventArgs e)
{
if (_CurrentlyDeleting == true)
{ return; }

_CurrentlyDeleting = true;
e.BusinessObject.DeleteCurrentRow(true);
e.Cancel = true;
// Reset flag once done
_CurrentlyDeleting = false;
}


Any ideas on why it is asking twice
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Good to know, glad we moved on.

I am out of the office right now and I have to be quick, but basically you need to switch the form's automatic delete question (set the AutoShowDeleteConfirmation to False) and roll your own and use it inside the BeforeDelete, checking if the user confirmed the action before you mark the row for deletion.
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Ivan.

I set the switch and inserted my own code , which works fien. Many thanks.

I am curious to know whey the the SF message was coming up twice though. As a general priciple, my preference is to let the fremawork do Most Stuff, and avoid any 'Custom Coding' where possible. As I will proabbaly use this Delete Functionality in a good number of forms, Ids like to understand why the message is coming up twice, and avoid it if possible without additional coding.
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
It was coming twice because you are issuing delete twice. The message will come up before the BeforeDelete event, so it came for the Delete you clicked on the toolbar and then afterwards for the Delete you coded inside the BeforeDelete.

Glad you got it working!
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