473,327 Members | 2,118 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Passing "Are you sure" message across layer boundaries

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
3 1273
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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: goinoutwest | last post by:
On July 3, I started noticing some page errors in my web application. All of the erroring clients where using Windows XP - MSIE 6.0. It seems these clients were passing the bookmark (fragment...
17
by: Nollie | last post by:
Say you have a struct: struct MYSTRUCT { int x; int y; int w; int h; };
0
by: katheo via AccessMonster.com | last post by:
Hello, I am using a data access page on a local secure server. As the user changes information, the data updates automatically in the database. But when the user goes to close the page, they get a...
2
by: HmFireBall | last post by:
Hi, This is a question about a shared property in ASP.NET Imagine there's an assembly called my.dll that is in the /bin directory of several websites. This assembly contains a class with a...
45
by: Gregory Petrosyan | last post by:
1) From 2.4.2 documentation: There are two new valid (semantic) forms for the raise statement: raise Class, instance raise instance 2) In python: >>> raise NameError Traceback (most recent...
6
by: Alex Maghen | last post by:
Let's say I have a web forms button which performs a Delete or something. I'd like a click on the button to pop an "Are you Sure" dialog on the client side and then only execute the button's...
3
by: rickeringill | last post by:
Hi comp.lang.javascript, I'm throwing this in for discussion. First up I don't claim to be any sort of authority on the ecmascript language spec - in fact I'm a relative newb to these more...
7
by: runsun pan | last post by:
I wanna check if an object is the *arguments* object of a function, is that possible? When we do: typeof(arguments) it always returns "object", doesn't seem to be helpful.
2
by: Mr. SweatyFinger | last post by:
how can i get an "are you sure" message before delete? thanks
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.