By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,312 Members | 1,850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,312 IT Pros & Developers. It's quick & easy.

Passing "Are you sure" message across layer boundaries

P: n/a
I would like a particular business object to ask for validation when a
property is set to a specific value. In this case, I have a TimeStart
property and a TimeEnd property. When creating a new object, the default for
these properties is Now. However, saving the data with both values set to now
would be highly unusual, so I'd want the class to ask for verification. I
think this rule should be maintained by the class and not the UI (a windows
form).

One thought I had is to expose a boolean property called ZeroTimeAllowed.
The default would be False. If the rule found that ZeroTimeAllowed is false
and the time properties are the same, I would throw an exception. The UI
could then show a messagebox and then change the ZeroTimeAllowed to True if
the response is Yes.

I'm not crazy about this idea, because there would be nothing stopping the
UI developer (in this case, myself) from always setting ZeroTimeAllowed to
True.

Any advice would be helpful.

Thanks,
Barry
Apr 17 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I would do it the way you're not crazy about. Doing MessageBoxes in the
business layer is just icky. (Yes, that's a technical term.)

One would hope the UI developer (in this case, yourself) would not set
ZeroTimeAllowed to true all the time, but if you needed to, it would give
you that flexibility.

Robin S.
---------------------------------------
"Barry Gilbert" <Ba**********@discussions.microsoft.comwrote in message
news:59**********************************@microsof t.com...
>I would like a particular business object to ask for validation when a
property is set to a specific value. In this case, I have a TimeStart
property and a TimeEnd property. When creating a new object, the default
for
these properties is Now. However, saving the data with both values set to
now
would be highly unusual, so I'd want the class to ask for verification. I
think this rule should be maintained by the class and not the UI (a
windows
form).

One thought I had is to expose a boolean property called ZeroTimeAllowed.
The default would be False. If the rule found that ZeroTimeAllowed is
false
and the time properties are the same, I would throw an exception. The UI
could then show a messagebox and then change the ZeroTimeAllowed to True
if
the response is Yes.

I'm not crazy about this idea, because there would be nothing stopping
the
UI developer (in this case, myself) from always setting ZeroTimeAllowed
to
True.

Any advice would be helpful.

Thanks,
Barry

Apr 17 '07 #2

P: n/a

You can throw in another hacky fix to get it to work.

a
private int m_verifyWasRunCounter = 0 ; // int
Use this so they don't just set ZeroTimeAllowed to true, and move on.
if m_verifyWasRunCounter is 0, then you know they just set it to true.
if you increment it, then at least you know they tried once, and then
manually set it.

??
I think that might work.



"Barry Gilbert" <Ba**********@discussions.microsoft.comwrote in message
news:59**********************************@microsof t.com...
I would like a particular business object to ask for validation when a
property is set to a specific value. In this case, I have a TimeStart
property and a TimeEnd property. When creating a new object, the default
for
these properties is Now. However, saving the data with both values set to
now
would be highly unusual, so I'd want the class to ask for verification. I
think this rule should be maintained by the class and not the UI (a
windows
form).

One thought I had is to expose a boolean property called ZeroTimeAllowed.
The default would be False. If the rule found that ZeroTimeAllowed is
false
and the time properties are the same, I would throw an exception. The UI
could then show a messagebox and then change the ZeroTimeAllowed to True
if
the response is Yes.

I'm not crazy about this idea, because there would be nothing stopping the
UI developer (in this case, myself) from always setting ZeroTimeAllowed to
True.

Any advice would be helpful.

Thanks,
Barry

Apr 17 '07 #3

P: n/a
Thanks for your replies.

I'm using Rocky Lhotka's CSLA framework. It maintains a list of broken rules
and warnings in the BO's base class. In my UI, I can check whether there are
any warnings and display a msgbox with the warning descriptions. The business
object maintains the warnings, but the UI does the alert logic.

Barry

"sloan" wrote:
>
You can throw in another hacky fix to get it to work.

a
private int m_verifyWasRunCounter = 0 ; // int
Use this so they don't just set ZeroTimeAllowed to true, and move on.
if m_verifyWasRunCounter is 0, then you know they just set it to true.
if you increment it, then at least you know they tried once, and then
manually set it.

??
I think that might work.



"Barry Gilbert" <Ba**********@discussions.microsoft.comwrote in message
news:59**********************************@microsof t.com...
I would like a particular business object to ask for validation when a
property is set to a specific value. In this case, I have a TimeStart
property and a TimeEnd property. When creating a new object, the default
for
these properties is Now. However, saving the data with both values set to
now
would be highly unusual, so I'd want the class to ask for verification. I
think this rule should be maintained by the class and not the UI (a
windows
form).

One thought I had is to expose a boolean property called ZeroTimeAllowed.
The default would be False. If the rule found that ZeroTimeAllowed is
false
and the time properties are the same, I would throw an exception. The UI
could then show a messagebox and then change the ZeroTimeAllowed to True
if
the response is Yes.

I'm not crazy about this idea, because there would be nothing stopping the
UI developer (in this case, myself) from always setting ZeroTimeAllowed to
True.

Any advice would be helpful.

Thanks,
Barry


Apr 18 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.