﻿<?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 » Business Objects and Data Access (How do I?)  » Strange Problem when checking business rules</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Mon, 08 Jun 2026 23:48:14 GMT</lastBuildDate><ttl>20</ttl><item><title>Strange Problem when checking business rules</title><link>http://forum.strataframe.net/FindPost14427.aspx</link><description>I've been fighting this and I know it must be something I'm doing, but I can't seem to figure out what's causing it. I have a business object that has several date fields. Some of the date fields indicate a start date and an end date.&lt;br&gt;
&lt;br&gt;
In the business object's CheckRulesOnCurrentRow event, I have a rule that makes sure the start date doesn't occur after the end date. When I save a record, it correctly makes this check and saves the data if I get it right the first time. If I set the start date after the end date, it adds a broken rule and lets the user correct the problem.&lt;br&gt;
&lt;br&gt;
I set the start date earlier, and save. I get the same message and the bound control is reset to the same later value. I keep making the change and it always switches back to the old value. The only thing I can do is click my cancel button to undo everything and start from scratch.&lt;br&gt;
&lt;br&gt;
So far, I've tried...&lt;br&gt;
&lt;br&gt;
... checking my code and I don't have a RejectChanges() or Refresh() call anywhere in the save process. The Undo() is only called from the Undo/Cancel process.&lt;br&gt;
&lt;br&gt;
... Adding this.BrokenRules.Clear() to the beginning of the CheckBusinessRulesOnCurrentRow event for the business object.&lt;br&gt;
&lt;br&gt;
Anything else I might try? Any ideas?</description><pubDate>Tue, 19 Feb 2008 14:59:36 GMT</pubDate><dc:creator>PeterA</dc:creator></item><item><title>RE: Strange Problem when checking business rules</title><link>http://forum.strataframe.net/FindPost14448.aspx</link><description>[quote][b]Greg McGuffey (02/19/2008)[/b][hr]Ah, I see. I don't think this stomps out all hope. :D&lt;br&gt;
&lt;br&gt;
You might try to eliminate the little pop-up thingy (comment out the code in the prerender event) and see if the textbox by itself exhibits this behavior.  I don't see how this could be the problem, but... plus, this should be a quick test so you could eliminate that part of your code immediately as the problem.  Quick tests are good :D&lt;br&gt;
&lt;br&gt;
And as Trent said and as I've found, a simple app that can reproduce the problem is invaluable, especially when the problem is being an elusive little bugger. (I'm sure you know this...but I resist it every time and it always ends up being the quickest way to the solution in these sort of situations).&lt;br&gt;
&lt;br&gt;
Good luck!&lt;br&gt;
&lt;br&gt;
P.S.  I'm about to leave (within an hour or so) for a little vacation, so I won't be posting for 11-14 days.  Until then....asta la pasta![/quote]&lt;br&gt;
&lt;br&gt;
Yea, I eliminated the onFocus event addition in the PreRender event. It didn't solve the problem. &lt;br&gt;
&lt;br&gt;
Honestly, this whole application is pretty simple. One Web page with several fields bound to two business objects. I've been having this problem since before I added any of the extra JavaScript items.&lt;br&gt;
&lt;br&gt;
Thanks!&lt;br&gt;</description><pubDate>Tue, 19 Feb 2008 14:59:36 GMT</pubDate><dc:creator>PeterA</dc:creator></item><item><title>RE: Strange Problem when checking business rules</title><link>http://forum.strataframe.net/FindPost14442.aspx</link><description>Ah, I see. I don't think this stomps out all hope. :D&lt;br&gt;
&lt;br&gt;
You might try to eliminate the little pop-up thingy (comment out the code in the prerender event) and see if the textbox by itself exhibits this behavior.  I don't see how this could be the problem, but... plus, this should be a quick test so you could eliminate that part of your code immediately as the problem.  Quick tests are good :D&lt;br&gt;
&lt;br&gt;
And as Trent said and as I've found, a simple app that can reproduce the problem is invaluable, especially when the problem is being an elusive little bugger. (I'm sure you know this...but I resist it every time and it always ends up being the quickest way to the solution in these sort of situations).&lt;br&gt;
&lt;br&gt;
Good luck!&lt;br&gt;
&lt;br&gt;
P.S.  I'm about to leave (within an hour or so) for a little vacation, so I won't be posting for 11-14 days.  Until then....asta la pasta!</description><pubDate>Tue, 19 Feb 2008 13:00:21 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Strange Problem when checking business rules</title><link>http://forum.strataframe.net/FindPost14439.aspx</link><description>[quote][b]Greg McGuffey (02/19/2008)[/b][hr][quote]Greg will be glad to know that we have found his issue relating to the DateTimePicker and we are working on a fix now. [/quote]&lt;br&gt;
&lt;br&gt;
:D  Very good news.  &lt;br&gt;
&lt;br&gt;
I only mentioned the DateTimePicker as there was the possibility it was control related, based on my experience, rather than binding/BO/Database related issue. Trying another control could quickly narrow that down.[/quote]&lt;br&gt;
&lt;br&gt;
The only thing is that I'm on a Web-based application and not a WinForm. I'm not using a date picker control, but a popup window with a modified calendar control to set the value of the text boxes to which I bound data.&lt;br&gt;
&lt;br&gt;
Hopefully I'm not stomping on any glimmers of hope. :D</description><pubDate>Tue, 19 Feb 2008 11:58:37 GMT</pubDate><dc:creator>PeterA</dc:creator></item><item><title>RE: Strange Problem when checking business rules</title><link>http://forum.strataframe.net/FindPost14435.aspx</link><description>[quote]Greg will be glad to know that we have found his issue relating to the DateTimePicker and we are working on a fix now. [/quote]&lt;br&gt;
&lt;br&gt;
:D  Very good news.  &lt;br&gt;
&lt;br&gt;
I only mentioned the DateTimePicker as there was the possibility it was control related, based on my experience, rather than binding/BO/Database related issue. Trying another control could quickly narrow that down.</description><pubDate>Tue, 19 Feb 2008 11:25:29 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Strange Problem when checking business rules</title><link>http://forum.strataframe.net/FindPost14434.aspx</link><description>[quote][b]Greg McGuffey (02/19/2008)[/b][hr]Are you using a DateTimePicker?  If so, you might try a TextBox (for test) and see if the problem still occurs.[/quote]&lt;br&gt;
&lt;br&gt;
I was using a textbox already. It's a Web-based application (I probably should have mentioned that). I've pseudo-disabled the text boxes by adding an onFocus attribute in the PreRender event that switches focus away from the text box. I was setting the values of the textboxes by bringing up a small window that mimicked a date picker's functionality and called a JavaScript that set the textbox value to a valid date (otherwise, we'd have people entering bad dates and lots of yellow screens :D).&lt;br&gt;
&lt;br&gt;
Thanks!&lt;br&gt;
Peter</description><pubDate>Tue, 19 Feb 2008 11:21:06 GMT</pubDate><dc:creator>PeterA</dc:creator></item><item><title>RE: Strange Problem when checking business rules</title><link>http://forum.strataframe.net/FindPost14433.aspx</link><description>[quote]Does the CheckRules event fire before assigning values to the business object?&lt;BR&gt;[/quote]&lt;/P&gt;&lt;P&gt;No.&amp;nbsp; The bound controls should have updated their bindings by this point.&amp;nbsp; I will see if I can reproduce.&amp;nbsp; Greg will be glad to know that we have found his issue relating to the DateTimePicker and we are working on a fix now.&amp;nbsp; And it only has to do with NULL values...so past that, that is the only known issue with this control...and we use it a lot.&amp;nbsp; So without a sample or a reproduction, this is one of those, "the compiler must have been having a bad day" issues :).&amp;nbsp; I totally believe you, but liek anything else, we have to get it in a reproducable state before we can do anything.</description><pubDate>Tue, 19 Feb 2008 11:19:58 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Strange Problem when checking business rules</title><link>http://forum.strataframe.net/FindPost14431.aspx</link><description>Ok. Now I'm really confused. I've got it to work, but I don't understand why this is working and my original method wasn't. Here's the original code snippet I was using on my save button's click event (cmdSave_Click).&lt;br&gt;
&lt;br&gt;
[codesnippet]            if (PurchaseOrderSchedules.EditingState != BusinessEditingState.Idle)&lt;br&gt;
            {&lt;br&gt;
                SaveUndoResult loSaveResult = SaveUndoResult.Cancelled;&lt;br&gt;
&lt;br&gt;
                try&lt;br&gt;
                {&lt;br&gt;
                    //TODO: Fix problem with locking user into form after picking invalid dates&lt;br&gt;
                    // Handle calculated fields&lt;br&gt;
                    decimal loResult = 0;&lt;br&gt;
&lt;br&gt;
                    // Percent Cut to date&lt;br&gt;
                    loResult = &lt;br&gt;
                        (((Decimal)PurchaseOrderSchedules.QTY_CUT_TOD_UNT &lt;br&gt;
                        / (Decimal)PurchaseOrders.QTY_PO_TOT_LT) * 100);&lt;br&gt;
                    PurchaseOrderSchedules.PCT_CUT_UNT = loResult;&lt;br&gt;
&lt;br&gt;
                    // Percent Stitched to date&lt;br&gt;
                    loResult =&lt;br&gt;
                        (((Decimal)PurchaseOrderSchedules.QTY_STC_TOT_UNT &lt;br&gt;
                        / (Decimal)PurchaseOrders.QTY_PO_TOT_LT) * 100);&lt;br&gt;
                    PurchaseOrderSchedules.PCT_STC_UNT = loResult;&lt;br&gt;
&lt;br&gt;
                    // Percent Assembled to date&lt;br&gt;
                    loResult =&lt;br&gt;
                        (((Decimal)PurchaseOrderSchedules.QTY_ASM_TOT_UNT &lt;br&gt;
                        / (Decimal)PurchaseOrders.QTY_PO_TOT_LT) * 100);&lt;br&gt;
                    PurchaseOrderSchedules.PCT_ASM_UNT = loResult;&lt;br&gt;
&lt;br&gt;
                    // Try saving the changes&lt;br&gt;
                    loSaveResult = PurchaseOrderSchedules.Save();&lt;br&gt;
                    #region Unsuccessful Save&lt;br&gt;
                    if (loSaveResult == SaveUndoResult.AbortedWithBrokenRules)&lt;br&gt;
                    {&lt;br&gt;
                        // Broken business rules. Tell the user which ones and let them&lt;br&gt;
                        // change their input.&lt;br&gt;
                        lbError.Visible = true;&lt;br&gt;
                        lbError.Text = this.GenerateWarningTable(&lt;br&gt;
                            Global.CreateErrorLabelContents(PurchaseOrderSchedules.BrokenRules),&lt;br&gt;
                            Global.Config["ImageUri"]&lt;br&gt;
                        );&lt;br&gt;
                    }&lt;br&gt;
                    else if (loSaveResult != SaveUndoResult.Success)&lt;br&gt;
                    {&lt;br&gt;
                        // Something else happened, have the user contact the help desk&lt;br&gt;
                        lbError.Visible = true;&lt;br&gt;
                        lbError.Text = this.GenerateWarningTable(&lt;br&gt;
                            "An error has occurred while saving the schedule" + Environment.NewLine +&lt;br&gt;
                            "information. Please send an e-mail to" + Environment.NewLine +&lt;br&gt;
                            "&lt;a href='mailto:CustomCoders@payless.com'&gt;CustomCoders@payless.com" +&lt;br&gt;
                            "&lt;/a&gt; if you continue to experience this " + Environment.NewLine +&lt;br&gt;
                            "problem.",&lt;br&gt;
                            Global.Config["ImageUri"]&lt;br&gt;
                        );&lt;br&gt;
                    }&lt;br&gt;
                    #endregion&lt;br&gt;
                }&lt;br&gt;
                #region Exceptions&lt;br&gt;
                catch (BusinessLayerException blex)&lt;br&gt;
                {&lt;br&gt;
                    this.HandleException(blex);&lt;br&gt;
                }&lt;br&gt;
                catch (ThreadAbortException tex)&lt;br&gt;
                {&lt;br&gt;
                    // do nothing&lt;br&gt;
                }&lt;br&gt;
                catch (Exception ex)&lt;br&gt;
                {&lt;br&gt;
                    this.HandleException(ex);&lt;br&gt;
                }&lt;br&gt;
                #endregion&lt;br&gt;
&lt;br&gt;
                if (loSaveResult == SaveUndoResult.Success)&lt;br&gt;
                {&lt;br&gt;
                    // Enable what should be enabled&lt;br&gt;
                    lbError.Visible = false;&lt;br&gt;
                    EnableButtonSaveCancel(false);&lt;br&gt;
                    EnableDatePickers(false);&lt;br&gt;
                    EnableToolbar(true);&lt;br&gt;
&lt;br&gt;
                    try&lt;br&gt;
                    {&lt;br&gt;
                        // Connect Schedule information to the current purchase order&lt;br&gt;
                        GetScheduleInformation();&lt;br&gt;
                    }&lt;br&gt;
                    #region Exceptions&lt;br&gt;
                    catch (BusinessLayerException blex)&lt;br&gt;
                    {&lt;br&gt;
                        this.HandleException(blex);&lt;br&gt;
                    }&lt;br&gt;
                    catch (ThreadAbortException tex)&lt;br&gt;
                    {&lt;br&gt;
                        // do nothing&lt;br&gt;
                    }&lt;br&gt;
                    catch (Exception ex)&lt;br&gt;
                    {&lt;br&gt;
                        this.HandleException(ex);&lt;br&gt;
                    }&lt;br&gt;
                    #endregion&lt;br&gt;
                }&lt;br&gt;
            }&lt;br&gt;
[/codesnippet]&lt;br&gt;
&lt;br&gt;
Here's the modified version that worked (with the change in bold):&lt;br&gt;
&lt;br&gt;
[codesnippet]            if (PurchaseOrderSchedules.EditingState != BusinessEditingState.Idle)&lt;br&gt;
            {&lt;br&gt;
                SaveUndoResult loSaveResult = SaveUndoResult.Cancelled;&lt;br&gt;
&lt;br&gt;
                try&lt;br&gt;
                {&lt;br&gt;
                    //TODO: Fix problem with locking user into form after picking invalid dates&lt;br&gt;
                    // Handle calculated fields&lt;br&gt;
                    decimal loResult = 0;&lt;br&gt;
&lt;br&gt;
                    // Percent Cut to date&lt;br&gt;
                    loResult = &lt;br&gt;
                        (((Decimal)PurchaseOrderSchedules.QTY_CUT_TOD_UNT &lt;br&gt;
                        / (Decimal)PurchaseOrders.QTY_PO_TOT_LT) * 100);&lt;br&gt;
                    PurchaseOrderSchedules.PCT_CUT_UNT = loResult;&lt;br&gt;
&lt;br&gt;
                    // Percent Stitched to date&lt;br&gt;
                    loResult =&lt;br&gt;
                        (((Decimal)PurchaseOrderSchedules.QTY_STC_TOT_UNT &lt;br&gt;
                        / (Decimal)PurchaseOrders.QTY_PO_TOT_LT) * 100);&lt;br&gt;
                    PurchaseOrderSchedules.PCT_STC_UNT = loResult;&lt;br&gt;
&lt;br&gt;
                    // Percent Assembled to date&lt;br&gt;
                    loResult =&lt;br&gt;
                        (((Decimal)PurchaseOrderSchedules.QTY_ASM_TOT_UNT &lt;br&gt;
                        / (Decimal)PurchaseOrders.QTY_PO_TOT_LT) * 100);&lt;br&gt;
                    PurchaseOrderSchedules.PCT_ASM_UNT = loResult;&lt;br&gt;
&lt;br&gt;
                    [b]// Manually assign dates&lt;br&gt;
                    PurchaseOrderSchedules.DT_CUT_STA = DateTime.Parse(txtDateCut.Text);&lt;br&gt;
                    PurchaseOrderSchedules.DT_CUT_END = DateTime.Parse(txtDateCutEnd.Text);&lt;br&gt;
&lt;br&gt;
                    PurchaseOrderSchedules.DT_STC_STA = DateTime.Parse(txtDateStitch.Text);&lt;br&gt;
                    PurchaseOrderSchedules.DT_STC_END = DateTime.Parse(txtDateStitchEnd.Text);&lt;br&gt;
&lt;br&gt;
                    PurchaseOrderSchedules.DT_ASM_STA = DateTime.Parse(txtDateAssembly.Text);&lt;br&gt;
                    PurchaseOrderSchedules.DT_ASM_END = DateTime.Parse(txtDateAssemblyEnd.Text);[/b]&lt;br&gt;
                    &lt;br&gt;
                    // Try saving the changes&lt;br&gt;
                    loSaveResult = PurchaseOrderSchedules.Save();&lt;br&gt;
                    #region Unsuccessful Save&lt;br&gt;
                    if (loSaveResult == SaveUndoResult.AbortedWithBrokenRules)&lt;br&gt;
                    {&lt;br&gt;
                        // Broken business rules. Tell the user which ones and let them&lt;br&gt;
                        // change their input.&lt;br&gt;
                        lbError.Visible = true;&lt;br&gt;
                        lbError.Text = this.GenerateWarningTable(&lt;br&gt;
                            Global.CreateErrorLabelContents(PurchaseOrderSchedules.BrokenRules),&lt;br&gt;
                            Global.Config["ImageUri"]&lt;br&gt;
                        );&lt;br&gt;
                    }&lt;br&gt;
                    else if (loSaveResult != SaveUndoResult.Success)&lt;br&gt;
                    {&lt;br&gt;
                        // Something else happened, have the user contact the help desk&lt;br&gt;
                        lbError.Visible = true;&lt;br&gt;
                        lbError.Text = this.GenerateWarningTable(&lt;br&gt;
                            "An error has occurred while saving the schedule" + Environment.NewLine +&lt;br&gt;
                            "information. Please send an e-mail to" + Environment.NewLine +&lt;br&gt;
                            "&lt;a href='mailto:CustomCoders@payless.com'&gt;CustomCoders@payless.com" +&lt;br&gt;
                            "&lt;/a&gt; if you continue to experience this " + Environment.NewLine +&lt;br&gt;
                            "problem.",&lt;br&gt;
                            Global.Config["ImageUri"]&lt;br&gt;
                        );&lt;br&gt;
                    }&lt;br&gt;
                    #endregion&lt;br&gt;
                }&lt;br&gt;
                #region Exceptions&lt;br&gt;
                catch (BusinessLayerException blex)&lt;br&gt;
                {&lt;br&gt;
                    this.HandleException(blex);&lt;br&gt;
                }&lt;br&gt;
                catch (ThreadAbortException tex)&lt;br&gt;
                {&lt;br&gt;
                    // do nothing&lt;br&gt;
                }&lt;br&gt;
                catch (Exception ex)&lt;br&gt;
                {&lt;br&gt;
                    this.HandleException(ex);&lt;br&gt;
                }&lt;br&gt;
                #endregion&lt;br&gt;
&lt;br&gt;
                if (loSaveResult == SaveUndoResult.Success)&lt;br&gt;
                {&lt;br&gt;
                    // Enable what should be enabled&lt;br&gt;
                    lbError.Visible = false;&lt;br&gt;
                    EnableButtonSaveCancel(false);&lt;br&gt;
                    EnableDatePickers(false);&lt;br&gt;
                    EnableToolbar(true);&lt;br&gt;
&lt;br&gt;
                    try&lt;br&gt;
                    {&lt;br&gt;
                        // Connect Schedule information to the current purchase order&lt;br&gt;
                        GetScheduleInformation();&lt;br&gt;
                    }&lt;br&gt;
                    #region Exceptions&lt;br&gt;
                    catch (BusinessLayerException blex)&lt;br&gt;
                    {&lt;br&gt;
                        this.HandleException(blex);&lt;br&gt;
                    }&lt;br&gt;
                    catch (ThreadAbortException tex)&lt;br&gt;
                    {&lt;br&gt;
                        // do nothing&lt;br&gt;
                    }&lt;br&gt;
                    catch (Exception ex)&lt;br&gt;
                    {&lt;br&gt;
                        this.HandleException(ex);&lt;br&gt;
                    }&lt;br&gt;
                    #endregion&lt;br&gt;
                }&lt;br&gt;
            }&lt;br&gt;
[/codesnippet]&lt;br&gt;
&lt;br&gt;
If the fields are bound (they initial assignment works), then why am I needing to manually assign the values to the fields if they change? Does the CheckRules event fire before assigning values to the business object?&lt;br&gt;
&lt;br&gt;
Thanks!</description><pubDate>Tue, 19 Feb 2008 11:01:35 GMT</pubDate><dc:creator>PeterA</dc:creator></item><item><title>RE: Strange Problem when checking business rules</title><link>http://forum.strataframe.net/FindPost14429.aspx</link><description>Are you using a DateTimePicker?  If so, you might try a TextBox (for test) and see if the problem still occurs.</description><pubDate>Tue, 19 Feb 2008 10:59:59 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item></channel></rss>