StrataFrame Forum

Messaging and Adding Broken Rules

http://forum.strataframe.net/Topic13633.aspx

By Bill Cunnien - 1/22/2008

I have decided to put my duplicate part number checking in the business object.  Well, that's where it belongs, anyway, right?

Here is my code:

private void PartsBO_CheckRulesOnCurrentRow(CheckRulesEventArgs e)
{
   
if (IsDuplicatePartNumber())
    {
       
this.AddBrokenRuleByKey(this.partnum, "DuplicatePartNumber");
    }
}

private Boolean IsDuplicatePartNumber()
{
   
SqlCommand mCommand = new SqlCommand();
    mCommand.CommandText =
"SELECT COUNT(*) FROM PartsMaster WHERE partnum = @partnum AND partindex != @partindex";
    mCommand.Parameters.Add(
new SqlParameter("@partnum", SqlDbType.VarChar));
    mCommand.Parameters.Add(
new SqlParameter("@partindex", SqlDbType.Int));
    mCommand.Parameters[
"@partnum"].Value = this.partnum;
    mCommand.Parameters[
"@partindex"].Value = this.partindex;
   
return ((int)ExecuteScalar(mCommand) > 0);
}

The window will let me know that a rule is broken.  But it does not say which rule, which field, nor does my beautifully crafted message pop up.  How do I get the window to do two things:  1)  Mark the field that is having the problem; and 2)  show my message.

Thanks!
Bill

By Ivan George Borges - 1/22/2008

Hi Bill.

On this line:

        this.AddBrokenRuleByKey(this.partnum, "DuplicatePartNumber");

try this:

        this.AddBrokenRuleByKey(PartsBOFieldNames.partnum, "DuplicatePartNumber");

Hope it helps.

By Bill Cunnien - 1/22/2008

Great!  That helps for part one.  Now, how do I get the window to recognize the localization message involved?  It has the alert icon next to the field now, which alerts the user.  The tooltip looks like it is trying to present my custom message, but it is filled with some coding that will scare the average user.

Thanks, again, Ivan!  You are a big help!
Bill

By Ivan George Borges - 1/22/2008

Hi Bill.

I'm glad it is working, you are welcome. Cool

Regarding the message, I think you should be passing a "Text values" key, not a
"Messages key" from your Messaging Project. Is that the case?

By Bill Cunnien - 1/22/2008

Uh...that was it...Blush

Embarassing.

Hey...at least, I am learning!  w00t w00t w00t

By Ivan George Borges - 1/22/2008

Nothing to feel embarassed at all. I'm really glad it worked for you.

Trent once almost made me wear a chicken suit on one of his classes. How is that for an embarassing situation? BigGrin

By Trent L. Taylor - 1/22/2008

Trent once almost made me wear a chicken suit on one of his classes. How is that for an embarassing situation?

Yeah...but let's lay the foundation as of why...Ivan had offered to all attendees that I buy the beer...or something along those lines...isn't that right, Ivan? Wink

By Greg McGuffey - 1/22/2008

Trent once...made me wear a chicken suit on one of his classes.




Oh? And how is this is different from your normal dress? Blink w00t Wink
By Ivan George Borges - 1/23/2008

Trent L. Taylor (01/22/2008)
Yeah...but let's lay the foundation as of why...Ivan had offered to all attendees that I buy the beer...or something along those lines...isn't that right, Ivan? Wink

Hum... I was tempted to say that I didn't know what you were talking about, but then I realized I don't have administrative priviledges to delete posts on the forum. Tongue

By Ivan George Borges - 1/23/2008

Greg McGuffey (01/22/2008)
Oh? And how is this is different from your normal dress? Blink w00t Wink

Well, usually I don't wear any... Tongue

By Trent L. Taylor - 1/23/2008

I was tempted to say that I didn't know what you were talking about, but then I realized I don't have administrative priviledges to delete posts on the forum

LOL...good thinking here...otherwise I might have been forced to find all of the links BigGrin