Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Business rules messages
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Business rules messages
Miscellaneous
Thread ID:
00847469
Message ID:
00847469
Views:
57
I am playing with the business rules classes and trying to get the messaging mechanism to come forward to indicate a problem. The web page seems to validate correctly, but instead of stopping it proceeds throught the error without any indication that the update failed. Here's the basic setup I'm using and most of it seems to be working as expected.

I'm sure I'm missing something, and I suspect it is that I should do someting, or capture the return value from the SaveDataSet method and respond. However, I can't find any samples of this in the web app docs or in the windows app docs. It seems it might be automatic, but it'snot acting "automatically". <g>

Please lead me to "the way"...

TIA,
Chris.

Some sample code working backward...

//In editcompany.aspx.cs:

private void btnSave_Click(object sender, System.EventArgs e)
{
// Retrieve the original DataSet from the Session variable
DataSet dsCompany = (DataSet)Session["dsCompany"];

// Call the Company object's SaveDataSet method, passing the original data.
// The business object raises a Saving event and all bound Web controls
// bind their data back into the DataSet
this.oCompany.SaveDataSet(dsCompany);

// perhaps I should do something here to pass a value beck to the mmControls?
// CompanyRules oCompanyRules = (CompanyRules)oCompany.GetBusinessRuleObject();
// if (oCompanyRules.BrokenRuleCount > 0)
// {
// // do something...
// }

// Redirect to a different page
Response.Redirect("Companies.aspx");

}

// in company.cs:

protected override mmBusinessRule CreateBusinessRuleObject()
{
return new CompanyRules(this);
}



// in companyrules.cs:

public override bool CheckRulesHook(DataSet ds, string tableName)
{
DataRow dr = ds.Tables[tableName].Rows[0];

this.ValidateCompanyName(dr["Company"].ToString());
this.ValidateAdd1(dr["add1"].ToString());

return this.ErrorProviderBrokenRuleCount == 0;
}

public string ValidateCompanyName(string CompanyName)
{
string message = null;

// cj chgd this because the CompanyName == "" wasn't working
string lcString = CompanyName.Trim();

if (lcString.Length == 0)
{
message = "Must specify a company name";
// this.AddErrorProviderBrokenRule("Company", message);
this.AddBrokenRule(message);
}
return message;
}

public string ValidateAdd1(string Add1)
{
string message = null;

// cj chgd this because the Add1 == "" wasn't working
string lcString = Add1.Trim();

if (lcString.Length == 0)
{
message = "Must specify an address 1";
// this.AddErrorProviderBrokenRule("Add1", message);
this.AddBrokenRule(message);
}
return message;
}

chris jefferies
chris@freeranger.com
Next
Reply
Map
View

Click here to load this message in the networking platform