Instructions on Showing Severity Rules (information, warning, Eritical Error) in Developer Express XTRAGrid

Instructions on Showing Severity Rules (information, warning, Eritical Error) in Developer Express XTRAGrid

Old forum URL: forums.lhotka.net/forums/t/2887.aspx


Plum posted on Wednesday, May 16, 2007

Hi Everyone

I was I figured out how to impliment the diferent severity rules in CSLA 2.14 into Developer Express XtraGrid. For instance if you have a severity rule that is marked as a warning, a little warning icon will appear next to the record in the grid and a description of the warning.  This is cool !!

You will need to have at least V7.1.2.0 of the XtraGrid installed on your Machine.

1. Open up the CSLA frame work code in Visual Studio 2005.

2. Make a reference to DEvExpress.Data.v7.1 .

3. Locate the abstract BusinessBase Class (

public abstract class BusinessBase : )

4. Place this (

using DevExpress.XtraEditors.DXErrorProvider; ) in the using section of the code.

5.  Make the BusinessBase class use the interface IDXDataErrorInfo. Your code should look like the following :

  public abstract class BusinessBase :

Csla.Core.UndoableBase, IEditableBusinessObject,

System.ComponentModel.IEditableObject, System.ComponentModel.IDataErrorInfo, IDXDataErrorInfo,

ICloneable, Csla.Security.IAuthorizeReadWrite

 6. Copy and Paste the following code snippet into the body of the BusinessBase Class and compile.

 

#region IDXDataErrorInfo

void IDXDataErrorInfo.GetPropertyError(string propertyName, ErrorInfo info)

{

if (!IsValid)

{

Validation.BrokenRule rule =

ValidationRules.GetBrokenRules().GetFirstBrokenRule(propertyName);

if (rule != null)

{

info.ErrorText = rule.Description;

info.ErrorType = ErrorType.Critical;

}

return;

}

if (ValidationRules.GetBrokenRules().WarningCount > 0)

{

Validation.BrokenRule rule = ValidationRules.GetBrokenRules().GetFirstMessage(propertyName, Csla.Validation.RuleSeverity.Warning);

if (rule != null)

{

info.ErrorText = rule.Description;

info.ErrorType = ErrorType.Warning;

}

return;

}

if (ValidationRules.GetBrokenRules().InformationCount > 0)

{

Validation.BrokenRule rule = ValidationRules.GetBrokenRules().GetFirstMessage(propertyName, Csla.Validation.RuleSeverity.Information);

if (rule != null)

{

info.ErrorText = rule.Description;

info.ErrorType = ErrorType.Information;

}

return;

}

return;

}

void IDXDataErrorInfo.GetError(ErrorInfo info) { }

//</gridControl1>

#endregion

csanchez replied on Tuesday, November 27, 2007

Great.

I'm using it right now and it's fantastic.

Thanks.

DocJames replied on Tuesday, November 27, 2007

Just what I needed. Thanks for Sharing! :)

Jimmy

Copyright (c) Marimer LLC