﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » Delete on a Maintenance Form</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Wed, 09 Sep 2026 18:37:44 GMT</lastBuildDate><ttl>20</ttl><item><title>Delete on a Maintenance Form</title><link>http://forum.strataframe.net/FindPost30170.aspx</link><description>When I delete a row from within a Maintanance Form, I notice it deletes from the Database immediaitely, unlike when I edit rows, I can Undo before I save.&lt;br/&gt;&lt;br/&gt;Is there a way of 'Holding' the deletes until I click on Save, so that any Deletes/ Edits are all done at the same time , an I am also given an option to 'Undo', for deletes</description><pubDate>Fri, 22 Jul 2011 05:27:48 GMT</pubDate><dc:creator>Ger Cannoll</dc:creator></item><item><title>RE: Delete on a Maintenance Form</title><link>http://forum.strataframe.net/FindPost30185.aspx</link><description>It was coming twice because you are&amp;nbsp;issuing delete twice.&amp;nbsp;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.&lt;br/&gt;&lt;br/&gt;Glad you got it working!</description><pubDate>Fri, 22 Jul 2011 05:27:48 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: Delete on a Maintenance Form</title><link>http://forum.strataframe.net/FindPost30184.aspx</link><description>Hi Ivan.&lt;br/&gt;&lt;br/&gt;I set the switch and inserted my own code , which works fien. Many thanks.&lt;br/&gt;&lt;br/&gt;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.</description><pubDate>Fri, 22 Jul 2011 03:14:48 GMT</pubDate><dc:creator>Ger Cannoll</dc:creator></item><item><title>RE: Delete on a Maintenance Form</title><link>http://forum.strataframe.net/FindPost30183.aspx</link><description>Good to know, glad we moved on. &lt;br/&gt;&lt;br/&gt;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.</description><pubDate>Thu, 21 Jul 2011 07:31:22 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: Delete on a Maintenance Form</title><link>http://forum.strataframe.net/FindPost30182.aspx</link><description>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:&lt;br/&gt;&lt;br/&gt;&lt;font size=2 face=Consolas&gt;&lt;font size=2 face=Consolas&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#008000 size=2 face=Consolas&gt;&lt;font color=#008000 size=2 face=Consolas&gt;&lt;font color=#008000 size=2 face=Consolas&gt;[quote]// Set up a variable to prevent an infinite loop as we are calling DeleteCurrentRow from inside DeleteCurrentRow event&lt;br/&gt;private bool _CurrentlyDeleting = false;&lt;br/&gt;private void scpBO1_BeforeDelete(MicroFour.StrataFrame.Business.BeforeDeleteEventArgs e)&lt;br/&gt;{&lt;br/&gt;if (_CurrentlyDeleting == true)&lt;br/&gt;{ return; }&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#008000 size=2 face=Consolas&gt;&lt;font color=#008000 size=2 face=Consolas&gt;&lt;font color=#008000 size=2 face=Consolas&gt;&lt;br/&gt;_CurrentlyDeleting = true;&lt;br/&gt;e.BusinessObject.DeleteCurrentRow(true);&lt;br/&gt;e.Cancel = true;&lt;br/&gt;// Reset flag once done&lt;br/&gt;_CurrentlyDeleting = false;&lt;br/&gt;}[/quote]&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2 face=Consolas&gt;&lt;font size=2 face=Consolas&gt;&lt;/font&gt;&lt;/font&gt;Any ideas on why it is asking twice</description><pubDate>Thu, 21 Jul 2011 06:34:32 GMT</pubDate><dc:creator>Ger Cannoll</dc:creator></item><item><title>RE: Delete on a Maintenance Form</title><link>http://forum.strataframe.net/FindPost30181.aspx</link><description>But Edhy, the original Delete is being Canceled just fine. What is triggering the other BeforeDelete is de DeleteRow that was coded&amp;nbsp;inside it. This one will&amp;nbsp;also&amp;nbsp;trigger a BeforeDelete.</description><pubDate>Thu, 21 Jul 2011 04:38:36 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: Delete on a Maintenance Form</title><link>http://forum.strataframe.net/FindPost30180.aspx</link><description>Hi Ivan,&lt;br/&gt;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.&lt;br/&gt;Ex:&lt;br/&gt;&lt;ol&gt;&lt;li&gt;Click Delete Button in Toolbar&lt;/li&gt;&lt;ul&gt;&lt;li&gt;BeforeDelete method is called in the Form.&lt;/li&gt;&lt;/ul&gt;&lt;ol&gt;&lt;ul&gt;&lt;li&gt;BeforeDelete method in the BO is raised.&amp;nbsp; 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?&lt;/li&gt;&lt;/ul&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;br/&gt;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.</description><pubDate>Wed, 20 Jul 2011 19:00:24 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Delete on a Maintenance Form</title><link>http://forum.strataframe.net/FindPost30179.aspx</link><description>Hey Edhy!&lt;br/&gt;&lt;br/&gt;Not really a bug. Remember we are starting a brand new Delete command right inside the BeforeDelete. This brand new Delete will call&amp;nbsp;its own&amp;nbsp;BeforeDelete, which is... this same BeforeDelete where we are. And then it will again hit the Delete call, which&amp;nbsp;will trigger another one, and another one, and... </description><pubDate>Wed, 20 Jul 2011 18:05:20 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: Delete on a Maintenance Form</title><link>http://forum.strataframe.net/FindPost30178.aspx</link><description>Hi Ivan,&lt;br/&gt;&lt;br/&gt;Thanks for the clarification and the flag idea, it makes sense.&lt;br/&gt;&lt;br/&gt;[quote][b]Ivan George Borges (7/20/2011)[/b][hr]&lt;span&gt;Gerard, you are getting an infinite loop because you are calling a Delete inside the BeforeDelete, which will trigger another BeforeDelete and so on.&lt;/span&gt;&lt;span&gt;[/quote]&lt;/span&gt;&lt;br/&gt;That looks like a minor bug somewhere since the e.Cancel = True should be stopping any delete process, right?&lt;br/&gt;&lt;span&gt;&lt;/span&gt;</description><pubDate>Wed, 20 Jul 2011 16:10:43 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Delete on a Maintenance Form</title><link>http://forum.strataframe.net/FindPost30177.aspx</link><description>&lt;span&gt;&lt;div&gt;&lt;span&gt;Gerard, you are getting an infinite loop because you are calling a Delete inside the BeforeDelete, which will trigger another BeforeDelete and so on.&lt;br/&gt;&lt;br/&gt;You can either create your own Delete button and hide the one from the toolbar, or still use the BeforeDelete with the help of a flag. Something like:&lt;br/&gt;&lt;br/&gt;&lt;/span&gt;[codesnippet]#Region " &amp;nbsp;Private Fields &amp;nbsp;"&lt;br/&gt;&lt;br/&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Private _WeAreDeleting As Boolean = False&lt;br/&gt;&lt;br/&gt;&lt;div&gt;#End Region&lt;br/&gt;&lt;br/&gt;&lt;div&gt;#Region " &amp;nbsp;Handled Events &amp;nbsp;"&lt;br/&gt;&lt;br/&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Private Sub MyBO_BeforeDelete(ByVal e As MicroFour.StrataFrame.Business.BeforeDeleteEventArgs) Handles MyBO.BeforeDelete&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'-- if we are currently deleting, exit&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;If _WeAreDeleting = True Then&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Exit Sub&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;End If&lt;br/&gt;&lt;br/&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'-- set flag so we won't get into a looping&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;_WeAreDeleting = True&lt;br/&gt;&lt;br/&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'-- mark for deletion&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MyBO.DeleteCurrentRow(True)&lt;br/&gt;&lt;br/&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'-- cancel standard deleting procedure&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;e.Cancel = True&lt;br/&gt;&lt;br/&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'-- reset flag, since we are done&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;_WeAreDeleting = False&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;End Sub&lt;br/&gt;&lt;br/&gt;&lt;div&gt;#End Region[/codesnippet]&lt;/span&gt;</description><pubDate>Wed, 20 Jul 2011 15:55:39 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: Delete on a Maintenance Form</title><link>http://forum.strataframe.net/FindPost30176.aspx</link><description>Hi Edhy.&lt;br/&gt;&lt;br/&gt;I was using the two overloads to 'Future Proof' tha app (I dont have Security switched on right now but do intend to )&lt;br/&gt;&lt;br/&gt;I chnged just to have one overload and same thing... just keeps looping asking If I am sure I want to delete</description><pubDate>Wed, 20 Jul 2011 15:43:35 GMT</pubDate><dc:creator>Ger Cannoll</dc:creator></item><item><title>RE: Delete on a Maintenance Form</title><link>http://forum.strataframe.net/FindPost30175.aspx</link><description>Hi Gerard,&lt;br/&gt;&lt;br/&gt;Why are you using the 2 overloads?&amp;nbsp; are you checking security for deleting the record? if not, just use one parameter of True to mark the record as deleted without saving it to the database.</description><pubDate>Wed, 20 Jul 2011 15:13:16 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Delete on a Maintenance Form</title><link>http://forum.strataframe.net/FindPost30174.aspx</link><description>Hi Edhy.&lt;br/&gt;&lt;br/&gt;I put following code into the BeforeDeleteEvent:&lt;br/&gt;&lt;br/&gt;&lt;font size=2 face=Consolas&gt;&lt;font size=2 face=Consolas&gt;[quote]e.BusinessObject.DeleteCurrentRow(true, true);&lt;br/&gt;e.Cancel = true;[/quote]&lt;/font&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font size=2 face=Consolas&gt;&lt;font size=2 face=Consolas&gt;It goes round in an infinite loop with following question: Are you sure you wish to delete the current record ? where I can select a yes or No button. My table only has about 10 records .&lt;/font&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font size=2 face=Consolas&gt;&lt;font size=2 face=Consolas&gt;This is on a Standard maintenance form and I dont have any other code in there.&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;/font&gt;</description><pubDate>Wed, 20 Jul 2011 14:58:52 GMT</pubDate><dc:creator>Ger Cannoll</dc:creator></item><item><title>RE: Delete on a Maintenance Form</title><link>http://forum.strataframe.net/FindPost30173.aspx</link><description>Hi Gerard,&lt;br/&gt;&lt;br/&gt;[quote][b]Gerard O Carroll (7/20/2011)[/b][hr]How do I access the DeleteCurrentRow method with the various over-rides from a SF Maintanace Form ?[/quote]&lt;br/&gt;&lt;br/&gt;You can handle the BO.BeforeDelete event and manipulate the delete routine as you wish and then set the e.Cancel to True as shown in the code below:&lt;br/&gt;&lt;span&gt;[code]&lt;br/&gt;&lt;/span&gt;&lt;pre style="font-family:Consolas;font-size:13;color:black;background:white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;Private&lt;/span&gt;&amp;nbsp;&lt;span style="color:blue;"&gt;Sub&lt;/span&gt;&amp;nbsp;BizVendor1_BeforeDelete(e&amp;nbsp;&lt;span style="color:blue;"&gt;As&lt;/span&gt;&amp;nbsp;MicroFour.StrataFrame.Business.&lt;span style="color:#2b91af;"&gt;BeforeDeleteEventArgs&lt;/span&gt;)&amp;nbsp;&lt;span style="color:blue;"&gt;Handles&lt;/span&gt;&amp;nbsp;BizVendor1.BeforeDelete&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.BusinessObject.DeleteCurrentRow(&lt;span style="color:blue;"&gt;True&lt;/span&gt;)&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.Cancel&amp;nbsp;=&amp;nbsp;&lt;span style="color:blue;"&gt;True&lt;/span&gt;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;End&lt;/span&gt;&amp;nbsp;&lt;span style="color:blue;"&gt;Sub&lt;/span&gt;&lt;br/&gt;&lt;/pre&gt;&lt;span&gt;[/code]&lt;/span&gt;</description><pubDate>Wed, 20 Jul 2011 14:32:05 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Delete on a Maintenance Form</title><link>http://forum.strataframe.net/FindPost30172.aspx</link><description>Hi Ivan. Tnaks for replying.&lt;br/&gt;&lt;br/&gt;How do I access the DeleteCurrentRow method with the various over-rides from a SF Maintanace Form ?</description><pubDate>Wed, 20 Jul 2011 14:09:17 GMT</pubDate><dc:creator>Ger Cannoll</dc:creator></item><item><title>RE: Delete on a Maintenance Form</title><link>http://forum.strataframe.net/FindPost30171.aspx</link><description>Hi Gerard.&lt;br/&gt;&lt;br/&gt;Have a look at the following:&lt;br/&gt;&lt;br/&gt;&lt;li style="font-weight: normal;" class="kadov-p-Cbullet-diamond-blue-simple"&gt;&lt;span style="color: rgb(65, 105, 225); font-weight: bold;"&gt;DeleteCurrentRow()&lt;/span&gt; - There are three overloads to this method.  Depending on the parameters passed, this method will behave differently.&lt;/li&gt;&lt;ol&gt;&lt;ul&gt;&lt;li class="kadov-p-Cbullet-square-blue-simple"&gt;&lt;p class="bullet-square-blue-simple"&gt;&lt;span style="color: rgb(65, 105, 225); font-weight: bold;"&gt;DeleteCurrentRow()&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; -&lt;/span&gt; When this overload is called, the record being deleted is immediately removed from the server and the internal data table is updated.&lt;/p&gt;&lt;li class="kadov-p-Cbullet-square-blue-simple"&gt;&lt;p class="bullet-square-blue-simple"&gt;&lt;span style="color: rgb(65, 105, 225); font-weight: bold;"&gt;DeleteCurrentRow(OnlyMarkAsDeleted)&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; - &lt;/span&gt;When &lt;span style="font-style: italic;"&gt;OnlyMarkAsDeleted&lt;/span&gt; is given a value of &lt;span style="font-style: italic;"&gt;True&lt;/span&gt;, the current row is deleted within the internal data table only and a &lt;span style="font-style: italic;"&gt;Save()&lt;/span&gt; must be executed before the changes are reflected back to the server.  This is recommended when deleting a large number of records.&lt;/p&gt;&lt;li class="kadov-p-Cbullet-square-blue-simple"&gt;&lt;p class="bullet-square-blue-simple"&gt;&lt;span style="color: rgb(65, 105, 225); font-weight: bold;"&gt;DeleteCurrentRow(CheckSecurity, OnlyMarkAsDeleted)&lt;/span&gt; - When a value of &lt;span style="font-style: italic;"&gt;True&lt;/span&gt; is passed to the &lt;span style="font-style: italic;"&gt;CheckSecurity&lt;/span&gt; parameter, a security check will be forced by raising the &lt;span style="font-style: italic;"&gt;&lt;a href="ms-its:C:\Program Files (x86)\MicroFour\StrataFrame\Documentation\StrataFrame Help.chm::/CheckSecurity.html"&gt;CheckSecurity event on the business object, allowing the developer to place any Security on Delete code.  The &lt;/a&gt;&lt;/span&gt;&lt;a href="ms-its:C:\Program Files (x86)\MicroFour\StrataFrame\Documentation\StrataFrame Help.chm::/CheckSecurity.html"&gt;&lt;/a&gt;&lt;span style="font-style: italic;"&gt;OnlyMarkAsDeleted&lt;/span&gt; parameter behaves identically to the &lt;span style="font-style: italic;"&gt;DeleteCurrentRow(OnlyMarkAsDeleted) &lt;/span&gt;overload described above.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ol&gt;&lt;p style="margin-left: 40px;" class="Notes"&gt;&lt;span style="font-weight: bold;"&gt;Note:&lt;/span&gt; All deletion methods return the number of records affected by the deletion.  If a zero is returned, no records were deleted from the server.&lt;/p&gt;</description><pubDate>Wed, 20 Jul 2011 11:42:01 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item></channel></rss>