Jeff,
>I ran the program, selected Customer ANATR and Invoice 10308. When I went to the Properties page, I changed the Qty in the first line to 6 and hit Save. It gave me an error that the discount could not be 0 (IsEmpty() issues are another story). I changed it to 1 and it saved fine. I moved to the second line, changed the Qty to 6 and hit save, and did not get an error for the Discount being 0. I got curious. I set a breakpoint in OrderDetailRules.CheckRulesHook to see what is happening. It turns out that this.CurrentRow stays at 0. So when I enter data in row 1, it validates row 0 again. I sure hope I'm missing something here. I realize that the demo does not contain bulletproof validation, but this has me concerned.
>
>I look forward to you pointing out the error of my ways,
The code in the OrderDetail business object demonstrates how to check rules on a single DataRow. To check rules on all rows, you just need to loop through each DataRow in the CheckRulesHook() method. For example:
public override bool CheckRulesHook(DataSet ds, string tableName)
{
if (ds.Tables[tableName].Rows.Count > 0)
{
foreach (DataRow Row in ds.Tables[tableName].Rows)
{
OrdersEntity Entity = new OrdersEntity();
Entity.SetDataRow(Row);
this.ValidateCustomerID(Entity.CustomerID);
this.ValidateShipName(Entity.ShipName);
}
}
return this.ErrorProviderBrokenRuleCount == 0;
}
Best Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com