﻿<?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 / Business Objects and Data Access (How do I?)  / Saving of Business object / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>forum@strataframe.net</webMaster><lastBuildDate>Sat, 11 Oct 2008 05:46:09 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Saving of Business object</title><link>http://forum.strataframe.net/Topic185-6-1.aspx</link><description>No, John, when you save, if there are broken rules on any of the rows, none of the rows will save.  (Unless of course, you tell it to ignore the broken rules, then everything will save.)</description><pubDate>Wed, 30 Nov 2005 08:21:39 GMT</pubDate><dc:creator>Ben Chase</dc:creator></item><item><title>RE: Saving of Business object</title><link>http://forum.strataframe.net/Topic185-6-1.aspx</link><description>The help documentation has a flow chart that shows the exact save sequence.  I just pulled this image from the help documentation, but for more information read [ &lt;FONT color=#1111ff&gt;&lt;STRONG&gt;Business Layer -&amp;gt; Common Business Object Tasks -&amp;gt; Saving Data&lt;/STRONG&gt;&lt;/FONT&gt; ] in the help and this should clear some things up.&lt;/P&gt;&lt;P&gt;&lt;IMG src="http://forum.strataframe.net/Uploads/Images/f9858de6-ec0b-4723-9124-61c1.JPG"&gt;&lt;/P&gt;&lt;P&gt;When a Save is called, the business rules are checked on each row within the  DataTable.  As the business object checks each row, it raises the CheckRulesOnCurrentRow event (where the business logic resides).  If there is even one broken rule on any row, no data will be saved back to the server until all of the rules have been corrected. &lt;/P&gt;&lt;P&gt;If the AutoNavigateToFirstBrokenRow property on the business object is set to true, the business object will automatically position itself on the first broken record.&lt;/P&gt;&lt;P&gt;You can access the broken rules one of two ways, first you can use the BrokenRules property:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;BrokenRules Example&lt;/STRONG&gt;&lt;BR&gt;Dim loRule As MicroFour.StrataFrame.Business.BrokenRule&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;For Each loRule In Customers.BrokenRules.ToArray()&lt;BR&gt;        '-- Show the rule&lt;BR&gt;        Console.WriteLine(loRule.Description)&lt;BR&gt;Next&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;The other method is to capture the BusinessRulesChecked event on a business object &lt;U&gt;or a form&lt;/U&gt; and use the event arguments passed to that event.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;BusinessRulesCheckedEvent Example&lt;BR&gt;&lt;/STRONG&gt;Private Sub Customers_BusinessRulesChecked(ByVal e As StrataFrame.Business.BusinessRulesCheckedEventArgs) Handles Customers.BusinessRulesChecked&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;        '-- Establish Locals&lt;BR&gt;        Dim loBO As MicroFour.StrataFrame.Business.BusinessLayer&lt;BR&gt;        Dim loRule As MicroFour.StrataFrame.Business.BrokenRule&lt;BR&gt;&lt;/EM&gt;&lt;EM&gt;&lt;BR&gt;&lt;/EM&gt;&lt;EM&gt;       '-- When captured on a form, there may be more than one business object with broken rules&lt;BR&gt;       '   this is how to cycle through all of the business objects with broken rules&lt;/EM&gt;&lt;EM&gt;&lt;BR&gt;        For Each loBO In e.AllBrokenRules.Keys&lt;BR&gt;            For Each loRule In loBO.BrokenRules.ToArray()&lt;BR&gt;                '-- Show the broken rule&lt;BR&gt;                Console.WriteLine(loRule.Description)&lt;BR&gt;            Next&lt;BR&gt;        Next&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;    End Sub&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;You can also determine how many broken rules there are on the current row, all other rows, and an accumulation of all rows using the same event arguments in the BusinessRulesChecked event:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Broken Rules Counters&lt;BR&gt;&lt;/STRONG&gt;Private Sub Customers_BusinessRulesChecked(ByVal e As StrataFrame.Business.BusinessRulesCheckedEventArgs) Handles Customers.BusinessRulesChecked&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;        Console.WriteLine("Broken rules on this row: {0}", e.CountOfBrokenRulesCurrentRow)&lt;BR&gt;        Console.WriteLine("Broken rules on other rows: {0}", e.CountOfBrokenRulesAdditionalRows)&lt;BR&gt;        Console.WriteLine("Broken rules on all rows: {0}", e.CountOfBrokenRulesTotal)&lt;BR&gt;&lt;BR&gt;&lt;/EM&gt;&lt;EM&gt;End Sub&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;You can also force the save and ignore all broken rules.  When this is done, the data will be saved back to the server regardless of the broken rules.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Ignoring Broken Rules&lt;/EM&gt;&lt;BR&gt;&lt;/STRONG&gt;&lt;EM&gt;Private Sub Customers_BusinessRulesChecked(ByVal e As StrataFrame.Business.BusinessRulesCheckedEventArgs) Handles Customers.BusinessRulesChecked&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;        '-- Ignore the broken rules and force the save&lt;BR&gt;        e.IgnoreRulesAndForceSave = True&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;    End Sub&lt;/EM&gt;</description><pubDate>Tue, 29 Nov 2005 20:14:34 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>Saving of Business object</title><link>http://forum.strataframe.net/Topic185-6-1.aspx</link><description>It is my understanding that a business object has an underlying ADO-DATABLE as the source of record storage.&lt;/P&gt;&lt;P&gt;I would like to understand what happens when you call the Save method of the Business Object when there are multiple records in the DataTable and there are broken rules for some of the records.&lt;/P&gt;&lt;P&gt;I assume only those records that don't have broken rules are saved or do all the records of the datatable have to be valid for the Business object to be saved?</description><pubDate>Tue, 29 Nov 2005 19:12:16 GMT</pubDate><dc:creator>John Frankewicz</dc:creator></item></channel></rss>